kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] KVM: arm64: Fixes for the exposed debug architecture
@ 2021-10-29  0:31 Oliver Upton
  2021-10-29  0:32 ` [PATCH 1/3] KVM: arm64: Stash OSLSR_EL1 in the cpu context Oliver Upton
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Oliver Upton @ 2021-10-29  0:31 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

I had a conversation with Marc about some of the quirks around the debug
architecture on KVM and incorporated some of his suggestions into a
series here. Of course, any glaring mistakes/choices made in this series
is on me :-)

Anyhow:

KVM's implementation of the debug architecture is a bit deviant as it
stands. For one, KVM handles the OS Lock as RAZ/WI, even though the
architecture mandates it. Additionally, KVM advertises more than it can
actually support: FEAT_DoubleLock is exposed as implemented to the
guest, though OSDLR_EL1 is handled as RAZ/WI too.

Only v8.2+ revisions of the debug architecture permit implementations to
omit DoubleLock. Fortunately, the delta between v8.0 and v8.2 is
entirely focused on external debug, a feature that KVM does not support
and likely never will. So, there isn't much of a hurdle to bump KVM's
reported DebugVer to v8.2, thereby allowing KVM to omit DoubleLock from
ID_AA64DFR0_EL1. Of the remaining bits of external debug visible to the
guest, the only additional thing to address is the OSLAR_EL1 issue by
simply context switching the host/guest values.

Patch 1 changes the way KVM backs OSLSR_EL1 in the sys reg table.
Instead of returning a static value from its handler, stash a copy of it
in kvm_cpu_context and return that when read.

Patch 2 makes the material change of allowing a guest to actually toggle
the OSLK bit by redirecting writes to OSLAR_EL1.OSLK to OSLSR_EL1.OSLK.
When saving context, simply stash the value of OSLSR_EL1. On resume,
apply OSLSR_EL1.OSLK to OSLAR_EL1.OSLK.

Finally, Patch 3 raises the KVM debug architecture to v8.2 and exposes
FEAT_DoubleLock as NI to the guest. With the changes to OSLAR_EL1 in
this series, KVM now does what it says on the tin.

This series applies cleanly to 5.15-rc4, and was (lightly) tested by
booting 5.15-rc4 as a kvmtool guest on this kernel.

Oliver Upton (3):
  KVM: arm64: Stash OSLSR_EL1 in the cpu context
  KVM: arm64: Allow the guest to change the OS Lock status
  KVM: arm64: Raise KVM's reported debug architecture to v8.2

 arch/arm64/include/asm/kvm_host.h          |  1 +
 arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h |  5 +++
 arch/arm64/kvm/sys_regs.c                  | 42 ++++++++++++++++------
 3 files changed, 37 insertions(+), 11 deletions(-)

-- 
2.33.0.1079.g6e70778dc9-goog


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

end of thread, other threads:[~2021-11-01 10:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-29  0:31 [PATCH 0/3] KVM: arm64: Fixes for the exposed debug architecture Oliver Upton
2021-10-29  0:32 ` [PATCH 1/3] KVM: arm64: Stash OSLSR_EL1 in the cpu context Oliver Upton
2021-10-29 11:27   ` Marc Zyngier
2021-10-29  0:32 ` [PATCH 2/3] KVM: arm64: Allow the guest to change the OS Lock status Oliver Upton
2021-10-29 11:16   ` Marc Zyngier
2021-10-29  0:32 ` [PATCH 3/3] KVM: arm64: Raise KVM's reported debug architecture to v8.2 Oliver Upton
2021-10-29 11:31   ` Marc Zyngier
2021-10-29 18:18     ` Oliver Upton
2021-11-01 10:21       ` Marc Zyngier

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