Commit 5c7cf1e4 authored by Marc Zyngier's avatar Marc Zyngier
Browse files

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: default avatarMarc Zyngier <maz@kernel.org>
parent 4da5a9af
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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 */