]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Use shadow SPSR_EL1 when injecting exceptions on !VHE
authorMarc Zyngier <maz@kernel.org>
Fri, 21 Jan 2022 18:42:07 +0000 (18:42 +0000)
committerMarc Zyngier <maz@kernel.org>
Mon, 24 Jan 2022 09:39:03 +0000 (09:39 +0000)
commit7b45c51b161dc35a8dd2b0478f7db1c56fe56913
tree0c2b24b8f85d87427dbabcfe8f0cae8635e55685
parente35e6f5b1ed601ea9180fcef3c376e75970cddf7
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.

Fixes: 998f296d3215 ("KVM: arm64: Inject AArch64 exceptions from HYP")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Fuad Tabba <tabba@google.com>
Link: https://lore.kernel.org/r/20220121184207.423426-1-maz@kernel.org
arch/arm64/kvm/hyp/exception.c