]> git.dujemihanovic.xyz Git - linux.git/commit
KVM: arm64: nv: Fix relative priorities of exceptions generated by ERETAx
authorMarc Zyngier <maz@kernel.org>
Tue, 28 May 2024 10:06:31 +0000 (11:06 +0100)
committerMarc Zyngier <maz@kernel.org>
Thu, 30 May 2024 16:36:22 +0000 (17:36 +0100)
commit41011e2de3480f9adb6420b35b67628b2d903355
tree4b26fc2e9f1f5dc5673d23009dbfea7651a75ab0
parentc92e8b9eacebb4060634ebd9395bba1b29aadc68
KVM: arm64: nv: Fix relative priorities of exceptions generated by ERETAx

ERETAx can fail in multiple ways:

(1) ELR_EL2 points lalaland
(2) we get a PAC failure
(3) SPSR_EL2 has the wrong mode

(1) is easy, as we just let the CPU do its thing and deliver an
Instruction Abort. However, (2) and (3) are interesting, because
the PAC failure priority is way below that of the Illegal Execution
State exception.

Which means that if we have detected a PAC failure (and that we have
FPACCOMBINE), we must be careful to give priority to the Illegal
Execution State exception, should one be pending.

Solving this involves hoisting the SPSR calculation earlier and
testing for the IL bit before injecting the FPAC exception.

In the extreme case of a ERETAx returning to an invalid mode *and*
failing its PAC check, we end up with an Instruction Abort (due
to the new PC being mangled by the failed Auth) *and* PSTATE.IL
being set. Which matches the requirements of the architecture.

Whilst we're at it, remove a stale comment that states the obvious
and only confuses the reader.

Fixes: 213b3d1ea161 ("KVM: arm64: nv: Handle ERETA[AB] instructions")
Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Reviewed-by: Oliver Upton <oliver.upton@linux.dev>
Link: https://lore.kernel.org/r/20240528100632.1831995-2-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/emulate-nested.c