KVM: arm64: nv: Fast-track 'InHost' exception returns
authorMarc Zyngier <maz@kernel.org>
Fri, 19 Apr 2024 10:29:27 +0000 (11:29 +0100)
committerMarc Zyngier <maz@kernel.org>
Sat, 20 Apr 2024 11:42:50 +0000 (12:42 +0100)
commitdd0717a998f77f449c70bee82626cbf9913fe78d
tree3f1da812e9904ff0d3a41789ef324b879c0bb492
parent95537f06b9e826766f32e513d714e1cda468ef15
KVM: arm64: nv: Fast-track 'InHost' exception returns

A significant part of the FEAT_NV extension is to trap ERET
instructions so that the hypervisor gets a chance to switch
from a vEL2 L1 guest to an EL1 L2 guest.

But this also has the unfortunate consequence of trapping ERET
in unsuspecting circumstances, such as staying at vEL2 (interrupt
handling while being in the guest hypervisor), or returning to host
userspace in the case of a VHE guest.

Although we already make some effort to handle these ERET quicker
by not doing the put/load dance, it is still way too far down the
line for it to be efficient enough.

For these cases, it would ideal to ERET directly, no question asked.
Of course, we can't do that. But the next best thing is to do it as
early as possible, in fixup_guest_exit(), much as we would handle
FPSIMD exceptions.

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