Re: [PATCH 6.13 8/8] KVM: arm64: Eagerly switch ZCR_EL{1,2}
From: Mark Rutland
Date: Wed Mar 19 2025 - 06:30:41 EST
On Wed, Mar 12, 2025 at 11:49:16PM +0000, Mark Brown wrote:
> diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> index 7262983c75fbc18ab44f52753bff1dd9167a68d3..84326765c66087d992a517a19fea94b04c39c994 100644
> --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c
> @@ -5,6 +5,7 @@
> */
>
> #include <hyp/adjust_pc.h>
> +#include <hyp/switch.h>
>
> #include <asm/pgtable-types.h>
> #include <asm/kvm_asm.h>
> @@ -178,8 +179,12 @@ static void handle___kvm_vcpu_run(struct kvm_cpu_context *host_ctxt)
> sync_hyp_vcpu(hyp_vcpu);
> pkvm_put_hyp_vcpu(hyp_vcpu);
> } else {
> + struct kvm_vcpu *vcpu = kern_hyp_va(host_vcpu);
> +
> /* The host is fully trusted, run its vCPU directly. */
> - ret = __kvm_vcpu_run(host_vcpu);
> + fpsimd_lazy_switch_to_guest(vcpu);
> + ret = __kvm_vcpu_run(vcpu);
> + fpsimd_lazy_switch_to_host(vcpu);
> }
As Gavin noted [1] for the v6.12 backport, the addition of kern_hyp_va()
is not correct, since 'host_vcpu' has already been converted to a hyp VA
at this point.
[1] https://lore.kernel.org/linux-arm-kernel/019afc2d-b047-4e33-971c-7debbbaec84d@xxxxxxxxxx/#t
Mark.