public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 0/2] KVM: arm64: nv: Fix sysreg RESx-ication
@ 2025-01-12 16:50 Marc Zyngier
  2025-01-12 16:50 ` [PATCH 1/2] KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors Marc Zyngier
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Marc Zyngier @ 2025-01-12 16:50 UTC (permalink / raw)
  To: kvmarm, kvm, linux-arm-kernel
  Cc: Joey Gouly, Suzuki K Poulose, Oliver Upton, Zenghui Yu

Joey recently reported that some rather basic tests were failing on
NV, and managed to track it down to critical register fields (such as
HCR_EL2.E2H) not having their expect value.

Further investigation has outlined a couple of critical issues:

- Evaluating HCR_EL2.E2H must always be done with a sanitising
  accessor, no ifs, no buts. Given that KVM assumes a fixed value for
  this bit, we cannot leave it to the guest to mess with.

- Resetting the sysreg file must result in the RESx bits taking
  effect. Otherwise, we may end-up making the wrong decision (see
  above), and we definitely expose invalid values to the guest. Note
  that because we compute the RESx masks very late in the VM setup, we
  need to apply these masks at that particular point as well.

The two patches in this series are enough to fix the current set of
issues, but __vcpu_sys_reg() needs some extra work as it is doing the
wrong thing when used as a lvalue. I'll post a separate series for
that, as the two problems are fairly orthogonal, and this results in a
significant amount of churn.

All kudos to Joey for patiently tracking that one down. This was
hidden behind a myriad of other issues, and nailing this sucker down
is nothing short of a debugging lesson. Drinks on me next time.

Unless someone shouts, I'll take this in for 6.14.

Marc Zyngier (2):
  KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors
  KVM: arm64: nv: Apply RESx settings to sysreg reset values

 arch/arm64/include/asm/kvm_emulate.h | 36 ++++++++++++----------------
 arch/arm64/include/asm/kvm_nested.h  |  2 +-
 arch/arm64/kvm/hyp/vhe/sysreg-sr.c   |  4 ++--
 arch/arm64/kvm/nested.c              |  9 +++++--
 arch/arm64/kvm/sys_regs.c            |  5 +++-
 5 files changed, 29 insertions(+), 27 deletions(-)

-- 
2.39.2



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

end of thread, other threads:[~2025-01-14 11:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-12 16:50 [PATCH 0/2] KVM: arm64: nv: Fix sysreg RESx-ication Marc Zyngier
2025-01-12 16:50 ` [PATCH 1/2] KVM: arm64: nv: Always evaluate HCR_EL2 using sanitising accessors Marc Zyngier
2025-01-12 16:50 ` [PATCH 2/2] KVM: arm64: nv: Apply RESx settings to sysreg reset values Marc Zyngier
2025-01-14 11:13 ` [PATCH 0/2] KVM: arm64: nv: Fix sysreg RESx-ication Joey Gouly
2025-01-14 11:37 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox