Commit 64eedcef authored by Marc Zyngier's avatar Marc Zyngier Committed by Lee Jones
Browse files

UPSTREAM: KVM: arm64: Use shadow SPSR_EL1 when injecting exceptions on !VHE



Injecting an exception into a guest with non-VHE is risky business.
Instead of writing in the shadow register for the switch code to
restore it, we override the CPU register instead. Which gets
overriden a few instructions later by said restore code.

The result is that although the guest correctly gets the exception,
it will return to the original context in some random state,
depending on what was there the first place... Boo.

Fix the issue by writing to the shadow register. The original code
is absolutely fine on VHE, as the state is already loaded, and writing
to the shadow register in that case would actually be a bug.

Bug: 254441685
Fixes: bb666c47 ("KVM: arm64: Inject AArch64 exceptions from HYP")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
Reviewed-by: default avatarFuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20220121184207.423426-1-maz@kernel.org


(cherry picked from commit 27858305)
Signed-off-by: default avatarLee Jones <joneslee@google.com>
Change-Id: I5337f3d80d29b798b3cd078fe93fac666c4ae00c
parent 6c2c1020
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment