Skip to content

KVM: arm64: De-specialise the timer UAPI

Marc Zyngier kvm kvmarm linux-arm-kernel 1 version Applied

Status from this message: Applied to fixes, thanks!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest13 patches 9 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/13KVM: arm64: Hide CNTHV_*_EL2 from userspace for nVHE guestsarch/arm64/kvm/sys_regs.c+13 -132 replies
2/13KVM: arm64: Introduce timer_context_to_vcpu() helperarch/arm64/kvm/arch_timer.c include/kvm/arm_arch_timer.h+14 -130 replies
3/13KVM: arm64: Replace timer context vcpu pointer with timer_idarch/arm64/kvm/arch_timer.c include/kvm/arm_arch_timer.h+8 -71 reply
4/13KVM: arm64: Make timer_set_offset() generally accessiblearch/arm64/kvm/arch_timer.c include/kvm/arm_arch_timer.h+10 -100 replies
5/13KVM: arm64: Add timer UAPI workaround to sysreg infrastructurearch/arm64/kvm/sys_regs.c arch/arm64/kvm/sys_regs.h+36 -32 replies
6/13KVM: arm64: Move CNT*_CTL_EL0 userspace accessors to generic infrastructurearch/arm64/kvm/guest.c arch/arm64/kvm/sys_regs.c+31 -90 replies
7/13KVM: arm64: Move CNT*_CVAL_EL0 userspace accessors to generic infrastructurearch/arm64/kvm/guest.c arch/arm64/kvm/sys_regs.c+4 -80 replies
8/13KVM: arm64: Move CNT*CT_EL0 userspace accessors to generic infrastructurearch/arm64/kvm/guest.c arch/arm64/kvm/sys_regs.c+31 -103 replies
9/13KVM: arm64: Fix WFxT handling of nested virtarch/arm64/kvm/handle_exit.c+6 -10 replies
10/13KVM: arm64: Kill leftovers of ad-hoc timer userspace accessarch/arm64/kvm/arch_timer.c arch/arm64/kvm/guest.c include/kvm/arm_arch_timer.h+0 -1260 replies
11/13KVM: arm64: selftests: Make dependencies on VHE-specific registers explicittools/testing/selftests/kvm/arm64/get-reg-list.c+3 -00 replies
12/13KVM: arm64: selftests: Add an E2H=0-specific configuration to get_reg_listtools/testing/selftests/kvm/arm64/get-reg-list.c+79 -00 replies
13/13KVM: arm64: selftest: Fix misleading comment about virtual timer encodingtools/testing/selftests/kvm/arm64/get-reg-list.c+14 -30 replies

Reviews trailers per patch

2 of 13 patches have a Reviewed-by or Acked-by.

PatchJoey Gouly
1/13
2/13
3/13R-b
4/13
5/13
6/13
7/13
8/13R-b
9/13
10/13
11/13
12/13
13/13

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/13] KVM: arm64: De-specialise the timer UAPI

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(-)
Signature · 1 line
2.47.3