kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 0/3] KVM: arm/arm64: exception injection fixes
@ 2020-01-08 13:43 Mark Rutland
  2020-01-08 13:43 ` [PATCHv2 1/3] KVM: arm64: correct PSTATE on exception entry Mark Rutland
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Mark Rutland @ 2020-01-08 13:43 UTC (permalink / raw)
  To: linux-arm-kernel, kvmarm, maz, alexandru.elisei; +Cc: stable, will

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].

Since v1 [2]:
* Fix host_spsr_to_spsr32() bit preservation
* Fix SPAN polarity; tested with a modified arm64 guest
* Fix DIT preservation on 32-bit hosts
* Add Alex's Reviewed-by to patch 3

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        |  70 +++++++++++++++++++--
 virt/kvm/arm/aarch32.c               | 117 +++++++++++++++++++++++++++++++----
 6 files changed, 220 insertions(+), 18 deletions(-)

-- 
2.11.0

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-08 13:43 [PATCHv2 0/3] KVM: arm/arm64: exception injection fixes Mark Rutland
2020-01-08 13:43 ` [PATCHv2 1/3] KVM: arm64: correct PSTATE on exception entry Mark Rutland
2020-01-08 14:34   ` Alexandru Elisei
2020-01-08 13:43 ` [PATCHv2 2/3] KVM: arm/arm64: correct CPSR " Mark Rutland
2020-01-08 14:41   ` Alexandru Elisei
2020-01-08 15:50     ` Mark Rutland
2020-01-08 13:43 ` [PATCHv2 3/3] KVM: arm/arm64: correct AArch32 SPSR " Mark Rutland
2020-01-08 13:45 ` [PATCHv2 0/3] KVM: arm/arm64: exception injection fixes Mark Rutland

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).