KVM: arm64: nv: Honor HFGITR_EL2.ERET being set
authorMarc Zyngier <maz@kernel.org>
Fri, 19 Apr 2024 10:29:28 +0000 (11:29 +0100)
committerMarc Zyngier <maz@kernel.org>
Sat, 20 Apr 2024 11:42:51 +0000 (12:42 +0100)
If the L1 hypervisor decides to trap ERETs while running L2,
make sure we don't try to emulate it, just like we wouldn't
if it had its NV bit set.

The exception will be reinjected from the core handler.

Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240419102935.1935571-9-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/hyp/vhe/switch.c

index 390c7d99f617067c8561b334b0174d0c356fd3a4..26395171621ba70289489b48a1a130e30934b6e0 100644 (file)
@@ -220,7 +220,8 @@ static bool kvm_hyp_handle_eret(struct kvm_vcpu *vcpu, u64 *exit_code)
         * Unless the trap has to be forwarded further down the line,
         * of course...
         */
-       if (__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_NV)
+       if ((__vcpu_sys_reg(vcpu, HCR_EL2) & HCR_NV) ||
+           (__vcpu_sys_reg(vcpu, HFGITR_EL2) & HFGITR_EL2_ERET))
                return false;
 
        spsr = read_sysreg_el1(SYS_SPSR);