]> www.infradead.org Git - users/hch/misc.git/commitdiff
KVM: arm64: selftests: Fix misleading comment about virtual timer encoding
authorMarc Zyngier <maz@kernel.org>
Mon, 29 Sep 2025 16:04:57 +0000 (17:04 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 13 Oct 2025 13:43:12 +0000 (14:43 +0100)
The userspace-visible encoding for CNTV_CVAL_EL0 and CNTVCNT_EL0
have been swapped for as long as usersapce has had access to the
registers. This is documented in arch/arm64/include/uapi/asm/kvm.h.

Despite that, the get_reg_list test has unhelpful comments indicating
the wrong register for the encoding.

Replace this with definitions exposed in the include file, and
a comment explaining again the brokenness.

Signed-off-by: Marc Zyngier <maz@kernel.org>
tools/testing/selftests/kvm/arm64/get-reg-list.c

index 7a238755f072856a1bdab2203a6f51f2d5f93367..c9b84eeaab6b28220543678463adaf1a2fa31873 100644 (file)
@@ -348,9 +348,20 @@ static __u64 base_regs[] = {
        KVM_REG_ARM_FW_FEAT_BMAP_REG(1),        /* KVM_REG_ARM_STD_HYP_BMAP */
        KVM_REG_ARM_FW_FEAT_BMAP_REG(2),        /* KVM_REG_ARM_VENDOR_HYP_BMAP */
        KVM_REG_ARM_FW_FEAT_BMAP_REG(3),        /* KVM_REG_ARM_VENDOR_HYP_BMAP_2 */
-       ARM64_SYS_REG(3, 3, 14, 3, 1),  /* CNTV_CTL_EL0 */
-       ARM64_SYS_REG(3, 3, 14, 3, 2),  /* CNTV_CVAL_EL0 */
-       ARM64_SYS_REG(3, 3, 14, 0, 2),
+
+       /*
+        * EL0 Virtual Timer Registers
+        *
+        * WARNING:
+        * KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT are not defined
+        * with the appropriate register encodings.  Their values have been
+        * accidentally swapped.  As this is set API, the definitions here
+        * must be used, rather than ones derived from the encodings.
+        */
+       KVM_ARM64_SYS_REG(SYS_CNTV_CTL_EL0),
+       KVM_REG_ARM_TIMER_CVAL,
+       KVM_REG_ARM_TIMER_CNT,
+
        ARM64_SYS_REG(3, 0, 0, 0, 0),   /* MIDR_EL1 */
        ARM64_SYS_REG(3, 0, 0, 0, 6),   /* REVIDR_EL1 */
        ARM64_SYS_REG(3, 1, 0, 0, 1),   /* CLIDR_EL1 */