linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: arm/arm64: exception injection fixes
@ 2019-12-20 15:05 Mark Rutland
  2019-12-20 15:05 ` [PATCH 1/3] KVM: arm64: correct PSTATE on exception entry Mark Rutland
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Mark Rutland @ 2019-12-20 15:05 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, maz
  Cc: Mark Rutland, peter.maydell, drjones, suzuki.poulose, will,
	james.morse, alexandru.elisei, julien.thierry.kdev

Hi,

While looking at the KVM code, I realised that our exception injection handling
isn't quite right, as it generates the target PSTATE/CPSR from scratch, and
doesn't handle all bits which need to be (conditionally) cleared or set upon
taking an exception.

The first two patches address this for injecting exceptions into AArch64 and
AArch32 contexts respectively. I've tried to organise the code so that it can
easily be audited against the ARM ARM, and/or extended in future if/when new
bits are added to the SPSRs.

While writing the AArch32 portion I also realised that on an AArch64 host we
don't correctly synthesize the SPSR_{abt,und} seen by the guest, as we copy the
value of SPSR_EL2, and the layouts of those SPSRs differ. The third patch
addresses this by explicitly moving bits into the SPSR_{abt,und} layout.

I'd appreciate any testing people could offer, especially for AArch32 guests
and/or AArch32 hosts, which I'm currently ill equipped to test. Ideally we'd
have some unit tests for this.

These issues don't seem to upset contemporary guests, but they do mean that KVM
isn't providing an architecturally compliant environment in all cases, which is
liable to cause issues in future. Given that, and that the patches are fairly
self-contained, I've marked all three patches for stable.

All three patches can be found on my kvm/exception-state branch [1].

Thanks,
Mark.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.git/log/?h=kvm/exception-state

Mark Rutland (3):
  KVM: arm64: correct PSTATE on exception entry
  KVM: arm/arm64: correct CPSR on exception entry
  KVM: arm/arm64: correct AArch32 SPSR on exception entry

 arch/arm/include/asm/kvm_emulate.h   |  17 +++++
 arch/arm64/include/asm/kvm_emulate.h |  32 ++++++++++
 arch/arm64/include/asm/ptrace.h      |   1 +
 arch/arm64/include/uapi/asm/ptrace.h |   1 +
 arch/arm64/kvm/inject_fault.c        |  69 +++++++++++++++++++--
 virt/kvm/arm/aarch32.c               | 116 +++++++++++++++++++++++++++++++----
 6 files changed, 218 insertions(+), 18 deletions(-)

-- 
2.11.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-01-08 12:44 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-20 15:05 [PATCH 0/3] KVM: arm/arm64: exception injection fixes Mark Rutland
2019-12-20 15:05 ` [PATCH 1/3] KVM: arm64: correct PSTATE on exception entry Mark Rutland
2019-12-27 13:01   ` Alexandru Elisei
2019-12-29 15:17     ` Marc Zyngier
2020-01-08 11:15       ` Mark Rutland
2020-01-08 11:12     ` Mark Rutland
2020-01-08 12:44       ` Alexandru Elisei
2019-12-20 15:05 ` [PATCH 2/3] KVM: arm/arm64: correct CPSR " Mark Rutland
2019-12-27 15:42   ` Alexandru Elisei
2020-01-08 11:37     ` Mark Rutland
2019-12-20 15:05 ` [PATCH 3/3] KVM: arm/arm64: correct AArch32 SPSR " Mark Rutland
2019-12-20 15:36   ` Marc Zyngier
2019-12-20 15:44     ` Mark Rutland
2019-12-27 15:56   ` Alexandru Elisei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).