All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] KVM: arm64: Emulate the OS lock
@ 2021-11-23 21:01 ` Oliver Upton
  0 siblings, 0 replies; 36+ messages in thread
From: Oliver Upton @ 2021-11-23 21:01 UTC (permalink / raw)
  To: kvmarm
  Cc: kvm, Marc Zyngier, James Morse, Alexandru Elisei,
	Suzuki K Poulose, linux-arm-kernel, Andrew Jones, Peter Shier,
	Ricardo Koller, Reiji Watanabe, Oliver Upton

KVM does not implement the debug architecture to the letter of the
specification. One such issue is the fact that KVM treats the OS Lock as
RAZ/WI, rather than emulating its behavior on hardware. This series adds
emulation support for the OS Lock to KVM. Emulation is warranted as the
OS Lock affects debug exceptions taken from all ELs, and is not limited
to only the context of the guest.

The 1st patch is a correctness fix for the OSLSR register, ensuring
the trap handler actually is written to suggest WO behavior. Note that
the changed code should never be reached on a correct implementation, as
hardware should generate the undef, not KVM.

The 2nd patch adds the necessary context to track guest values of the
OS Lock bit and exposes the value to userspace for the sake of
migration.

The 3rd patch makes the OSLK bit writable in OSLAR_EL1 (from the guest)
and OSLSR_EL1 (from userspace), but does nothing with its value.

The 4th patch actually implements the OS Lock behavior, disabling all
debug exceptions (except breakpoint instructions) from the perspective
of the guest. This is done by disabling MDE and SS in MDSCR_EL1.

The 5th patch asserts that OSLSR_EL1 is exposed by KVM to userspace
through the KVM_GET_REG_LIST ioctl. Lastly, the 6th patch asserts that
no debug exceptions are routed to the guest when the OSLK bit is set.

This series applies cleanly to 5.16-rc2. Tested on an Ampere Altra
machine with the included selftests patches.

Oliver Upton (6):
  KVM: arm64: Correctly treat writes to OSLSR_EL1 as undefined
  KVM: arm64: Stash OSLSR_EL1 in the cpu context
  KVM: arm64: Allow guest to set the OSLK bit
  KVM: arm64: Emulate the OS Lock
  selftests: KVM: Add OSLSR_EL1 to the list of blessed regs
  selftests: KVM: Test OS lock behavior

 arch/arm64/include/asm/kvm_host.h             |  6 ++
 arch/arm64/include/asm/sysreg.h               |  6 ++
 arch/arm64/kvm/debug.c                        | 27 +++++--
 arch/arm64/kvm/sys_regs.c                     | 70 ++++++++++++++-----
 .../selftests/kvm/aarch64/debug-exceptions.c  | 58 ++++++++++++++-
 .../selftests/kvm/aarch64/get-reg-list.c      |  1 +
 6 files changed, 145 insertions(+), 23 deletions(-)

-- 
2.34.0.rc2.393.gf8c9666880-goog


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

end of thread, other threads:[~2021-12-06 18:49 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 21:01 [PATCH v3 0/6] KVM: arm64: Emulate the OS lock Oliver Upton
2021-11-23 21:01 ` Oliver Upton
2021-11-23 21:01 ` Oliver Upton
2021-11-23 21:01 ` [PATCH v3 1/6] KVM: arm64: Correctly treat writes to OSLSR_EL1 as undefined Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01 ` [PATCH v3 2/6] KVM: arm64: Stash OSLSR_EL1 in the cpu context Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01 ` [PATCH v3 3/6] KVM: arm64: Allow guest to set the OSLK bit Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-29 11:50   ` Marc Zyngier
2021-11-29 11:50     ` Marc Zyngier
2021-11-29 11:50     ` Marc Zyngier
2021-12-06 17:39     ` Oliver Upton
2021-12-06 17:39       ` Oliver Upton
2021-12-06 17:39       ` Oliver Upton
2021-12-06 18:47       ` Marc Zyngier
2021-12-06 18:47         ` Marc Zyngier
2021-12-06 18:47         ` Marc Zyngier
2021-11-23 21:01 ` [PATCH v3 4/6] KVM: arm64: Emulate the OS Lock Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-29 14:15   ` Marc Zyngier
2021-11-29 14:15     ` Marc Zyngier
2021-11-29 14:15     ` Marc Zyngier
2021-12-06 17:34     ` Oliver Upton
2021-12-06 17:34       ` Oliver Upton
2021-12-06 17:34       ` Oliver Upton
2021-11-23 21:01 ` [PATCH v3 5/6] selftests: KVM: Add OSLSR_EL1 to the list of blessed regs Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01 ` [PATCH v3 6/6] selftests: KVM: Test OS lock behavior Oliver Upton
2021-11-23 21:01   ` Oliver Upton
2021-11-23 21:01   ` Oliver Upton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.