summaryrefslogtreecommitdiff
path: root/arch/arm64/kvm/fpsimd.c
diff options
context:
space:
mode:
authorOliver Upton <oliver.upton@linux.dev>2024-06-20 16:46:42 +0000
committerOliver Upton <oliver.upton@linux.dev>2024-06-20 19:02:40 +0000
commitb7e5c9426429aa64cacc2d804417e0e5f79b8b60 (patch)
tree2ef06af6d164331baa584540392a93fdae8838ff /arch/arm64/kvm/fpsimd.c
parent069da3ffdadfe108729fc9aafa3930da77711812 (diff)
downloadlwn-b7e5c9426429aa64cacc2d804417e0e5f79b8b60.tar.gz
lwn-b7e5c9426429aa64cacc2d804417e0e5f79b8b60.zip
KVM: arm64: nv: Save guest's ZCR_EL2 when in hyp context
When running a guest hypervisor, ZCR_EL2 is an alias for the counterpart EL1 state. Reviewed-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20240620164653.1130714-6-oliver.upton@linux.dev Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
Diffstat (limited to 'arch/arm64/kvm/fpsimd.c')
-rw-r--r--arch/arm64/kvm/fpsimd.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c
index 521b32868d0d..0815ff0347f5 100644
--- a/arch/arm64/kvm/fpsimd.c
+++ b/arch/arm64/kvm/fpsimd.c
@@ -178,7 +178,13 @@ void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
if (guest_owns_fp_regs()) {
if (vcpu_has_sve(vcpu)) {
- __vcpu_sys_reg(vcpu, ZCR_EL1) = read_sysreg_el1(SYS_ZCR);
+ u64 zcr = read_sysreg_el1(SYS_ZCR);
+
+ /*
+ * If the vCPU is in the hyp context then ZCR_EL1 is
+ * loaded with its vEL2 counterpart.
+ */
+ __vcpu_sys_reg(vcpu, vcpu_sve_zcr_elx(vcpu)) = zcr;
/*
* Restore the VL that was saved when bound to the CPU,