Skip to content

Commit ea3b27d

Browse files
author
Marc Zyngier
committed
KVM: arm64: nv: Expand ERET trap forwarding to handle FGT
We already handle ERET being trapped from a L1 guest in hyp context. However, with FGT, we can also have ERET being trapped from L2, and this needs to be reinjected into L1. Add the required exception routing. Signed-off-by: Marc Zyngier <maz@kernel.org> Reviewed-by: Jing Zhang <jingzhangos@google.com> Link: https://lore.kernel.org/r/20230815183903.2735724-25-maz@kernel.org
1 parent a77b31d commit ea3b27d

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

arch/arm64/kvm/handle_exit.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,22 @@ static int kvm_handle_eret(struct kvm_vcpu *vcpu)
222222
if (kvm_vcpu_get_esr(vcpu) & ESR_ELx_ERET_ISS_ERET)
223223
return kvm_handle_ptrauth(vcpu);
224224

225-
kvm_emulate_nested_eret(vcpu);
225+
/*
226+
* If we got here, two possibilities:
227+
*
228+
* - the guest is in EL2, and we need to fully emulate ERET
229+
*
230+
* - the guest is in EL1, and we need to reinject the
231+
* exception into the L1 hypervisor.
232+
*
233+
* If KVM ever traps ERET for its own use, we'll have to
234+
* revisit this.
235+
*/
236+
if (is_hyp_ctxt(vcpu))
237+
kvm_emulate_nested_eret(vcpu);
238+
else
239+
kvm_inject_nested_sync(vcpu, kvm_vcpu_get_esr(vcpu));
240+
226241
return 1;
227242
}
228243

0 commit comments

Comments
 (0)