linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/13] KVM: arm64: De-specialise the timer UAPI
@ 2025-09-29 16:04 Marc Zyngier
  2025-09-29 16:04 ` [PATCH 01/13] KVM: arm64: Hide CNTHV_*_EL2 from userspace for nVHE guests Marc Zyngier
                   ` (13 more replies)
  0 siblings, 14 replies; 23+ messages in thread
From: Marc Zyngier @ 2025-09-29 16:04 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, kvm
  Cc: Joey Gouly, Suzuki K Poulose, Oliver Upton, Zenghui Yu

Since the beginning of the KVM/arm64 port, the timer registers were
handled out of the normal sysreg flow when it came to userspace
access, leading to extra complexity and a bit of code duplication.

When NV was introduced, the decision was made early to handle the new
timer registers as part of the generic infrastructure. However, the
EL0 timers were left behind until someone could be bothered to
entangle that mess.

Said mess is more complicated than it looks, due to a nasty bug
documented in 290a6bb06de9e ("arm64: KVM: Add UAPI notes for swapped
registers"), where it was realised that CNTV_CVAL_EL0 and CNTVCT_EL0
have had their encoding swapped at the user interface level. Handling
of this issue is spread all over the place instead of being contained
in a single location, and it needs to be contained.

Finally, it was noticed that we expose the CNTHV_*_EL2 registers to
userspace for nVHE guest, while the architecture is clear that they do
not exist in that configuration.

This series aims at fixing all of the above, moving the handling of
the timer sysregs to sys_regs.c, fix a corner case with WFxT, handle
the nVHE issue described above, and finally improve the testing by
introducing an E2H==0 configuration.

If excluding the selftests, this is a net deletion of code. What's not
to like?

Marc Zyngier (13):
  KVM: arm64: Hide CNTHV_*_EL2 from userspace for nVHE guests
  KVM: arm64: Introduce timer_context_to_vcpu() helper
  KVM: arm64: Replace timer context vcpu pointer with timer_id
  KVM: arm64: Make timer_set_offset() generally accessible
  KVM: arm64: Add timer UAPI workaround to sysreg infrastructure
  KVM: arm64: Move CNT*_CTL_EL0 userspace accessors to generic
    infrastructure
  KVM: arm64: Move CNT*_CVAL_EL0 userspace accessors to generic
    infrastructure
  KVM: arm64: Move CNT*CT_EL0 userspace accessors to generic
    infrastructure
  KVM: arm64: Fix WFxT handling of nested virt
  KVM: arm64: Kill leftovers of ad-hoc timer userspace access
  KVM: arm64: selftests: Make dependencies on VHE-specific registers
    explicit
  KVM: arm64: selftests: Add an E2H=0-specific configuration to
    get_reg_list
  KVM: arm64: selftest: Fix misleading comment about virtual timer
    encoding

 arch/arm64/kvm/arch_timer.c                   | 105 ++-------------
 arch/arm64/kvm/guest.c                        |  70 ----------
 arch/arm64/kvm/handle_exit.c                  |   7 +-
 arch/arm64/kvm/sys_regs.c                     | 123 +++++++++++++++---
 arch/arm64/kvm/sys_regs.h                     |   6 +
 include/kvm/arm_arch_timer.h                  |  24 ++--
 .../selftests/kvm/arm64/get-reg-list.c        |  99 +++++++++++++-
 7 files changed, 240 insertions(+), 194 deletions(-)

-- 
2.47.3



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

end of thread, other threads:[~2025-10-13 16:56 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 16:04 [PATCH 00/13] KVM: arm64: De-specialise the timer UAPI Marc Zyngier
2025-09-29 16:04 ` [PATCH 01/13] KVM: arm64: Hide CNTHV_*_EL2 from userspace for nVHE guests Marc Zyngier
2025-09-30  0:35   ` Oliver Upton
2025-09-30  7:44     ` Marc Zyngier
2025-09-29 16:04 ` [PATCH 02/13] KVM: arm64: Introduce timer_context_to_vcpu() helper Marc Zyngier
2025-09-29 16:04 ` [PATCH 03/13] KVM: arm64: Replace timer context vcpu pointer with timer_id Marc Zyngier
2025-09-30 10:13   ` Joey Gouly
2025-09-29 16:04 ` [PATCH 04/13] KVM: arm64: Make timer_set_offset() generally accessible Marc Zyngier
2025-09-29 16:04 ` [PATCH 05/13] KVM: arm64: Add timer UAPI workaround to sysreg infrastructure Marc Zyngier
2025-09-30  0:41   ` Oliver Upton
2025-09-30  7:48     ` Marc Zyngier
2025-09-29 16:04 ` [PATCH 06/13] KVM: arm64: Move CNT*_CTL_EL0 userspace accessors to generic infrastructure Marc Zyngier
2025-09-29 16:04 ` [PATCH 07/13] KVM: arm64: Move CNT*_CVAL_EL0 " Marc Zyngier
2025-09-29 16:04 ` [PATCH 08/13] KVM: arm64: Move CNT*CT_EL0 " Marc Zyngier
2025-09-30 10:45   ` Joey Gouly
2025-09-30 12:05     ` Marc Zyngier
2025-09-30 12:41       ` Joey Gouly
2025-09-29 16:04 ` [PATCH 09/13] KVM: arm64: Fix WFxT handling of nested virt Marc Zyngier
2025-09-29 16:04 ` [PATCH 10/13] KVM: arm64: Kill leftovers of ad-hoc timer userspace access Marc Zyngier
2025-09-29 16:04 ` [PATCH 11/13] KVM: arm64: selftests: Make dependencies on VHE-specific registers explicit Marc Zyngier
2025-09-29 16:04 ` [PATCH 12/13] KVM: arm64: selftests: Add an E2H=0-specific configuration to get_reg_list Marc Zyngier
2025-09-29 16:04 ` [PATCH 13/13] KVM: arm64: selftest: Fix misleading comment about virtual timer encoding Marc Zyngier
2025-10-13 16:55 ` [PATCH 00/13] KVM: arm64: De-specialise the timer UAPI 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).