Skip to content

Commit 5c7cf1e

Browse files
author
Marc Zyngier
committed
KVM: arm64: selftests: Fix misleading comment about virtual timer encoding
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>
1 parent 4da5a9a commit 5c7cf1e

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tools/testing/selftests/kvm/arm64/get-reg-list.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,20 @@ static __u64 base_regs[] = {
348348
KVM_REG_ARM_FW_FEAT_BMAP_REG(1), /* KVM_REG_ARM_STD_HYP_BMAP */
349349
KVM_REG_ARM_FW_FEAT_BMAP_REG(2), /* KVM_REG_ARM_VENDOR_HYP_BMAP */
350350
KVM_REG_ARM_FW_FEAT_BMAP_REG(3), /* KVM_REG_ARM_VENDOR_HYP_BMAP_2 */
351-
ARM64_SYS_REG(3, 3, 14, 3, 1), /* CNTV_CTL_EL0 */
352-
ARM64_SYS_REG(3, 3, 14, 3, 2), /* CNTV_CVAL_EL0 */
353-
ARM64_SYS_REG(3, 3, 14, 0, 2),
351+
352+
/*
353+
* EL0 Virtual Timer Registers
354+
*
355+
* WARNING:
356+
* KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT are not defined
357+
* with the appropriate register encodings. Their values have been
358+
* accidentally swapped. As this is set API, the definitions here
359+
* must be used, rather than ones derived from the encodings.
360+
*/
361+
KVM_ARM64_SYS_REG(SYS_CNTV_CTL_EL0),
362+
KVM_REG_ARM_TIMER_CVAL,
363+
KVM_REG_ARM_TIMER_CNT,
364+
354365
ARM64_SYS_REG(3, 0, 0, 0, 0), /* MIDR_EL1 */
355366
ARM64_SYS_REG(3, 0, 0, 0, 6), /* REVIDR_EL1 */
356367
ARM64_SYS_REG(3, 1, 0, 0, 1), /* CLIDR_EL1 */

0 commit comments

Comments
 (0)