Skip to content

Commit 290a6bb

Browse files
Andrew JonesMarc Zyngier
authored andcommitted
arm64: KVM: Add UAPI notes for swapped registers
Two UAPI system register IDs do not derive their values from the ARM system register encodings. This is because their values were accidentally swapped. As the IDs are API, they cannot be changed. Add WARNING notes to point them out. Suggested-by: Marc Zyngier <[email protected]> Signed-off-by: Andrew Jones <[email protected]> [maz: turned XXX into WARNING] Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0e20f5e commit 290a6bb

File tree

2 files changed

+19
-2
lines changed
  • Documentation/virt/kvm
  • arch/arm64/include/uapi/asm

2 files changed

+19
-2
lines changed

Documentation/virt/kvm/api.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,15 @@ arm64 CCSIDR registers are demultiplexed by CSSELR value:
21962196
arm64 system registers have the following id bit patterns:
21972197
0x6030 0000 0013 <op0:2> <op1:3> <crn:4> <crm:4> <op2:3>
21982198

2199+
WARNING:
2200+
Two system register IDs do not follow the specified pattern. These
2201+
are KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT, which map to
2202+
system registers CNTV_CVAL_EL0 and CNTVCT_EL0 respectively. These
2203+
two had their values accidentally swapped, which means TIMER_CVAL is
2204+
derived from the register encoding for CNTVCT_EL0 and TIMER_CNT is
2205+
derived from the register encoding for CNTV_CVAL_EL0. As this is
2206+
API, it must remain this way.
2207+
21992208
arm64 firmware pseudo-registers have the following bit pattern:
22002209
0x6030 0000 0014 <regno:16>
22012210

arch/arm64/include/uapi/asm/kvm.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,18 @@ struct kvm_vcpu_events {
220220
#define KVM_REG_ARM_PTIMER_CVAL ARM64_SYS_REG(3, 3, 14, 2, 2)
221221
#define KVM_REG_ARM_PTIMER_CNT ARM64_SYS_REG(3, 3, 14, 0, 1)
222222

223-
/* EL0 Virtual Timer Registers */
223+
/*
224+
* EL0 Virtual Timer Registers
225+
*
226+
* WARNING:
227+
* KVM_REG_ARM_TIMER_CVAL and KVM_REG_ARM_TIMER_CNT are not defined
228+
* with the appropriate register encodings. Their values have been
229+
* accidentally swapped. As this is set API, the definitions here
230+
* must be used, rather than ones derived from the encodings.
231+
*/
224232
#define KVM_REG_ARM_TIMER_CTL ARM64_SYS_REG(3, 3, 14, 3, 1)
225-
#define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2)
226233
#define KVM_REG_ARM_TIMER_CVAL ARM64_SYS_REG(3, 3, 14, 0, 2)
234+
#define KVM_REG_ARM_TIMER_CNT ARM64_SYS_REG(3, 3, 14, 3, 2)
227235

228236
/* KVM-as-firmware specific pseudo-registers */
229237
#define KVM_REG_ARM_FW (0x0014 << KVM_REG_ARM_COPROC_SHIFT)

0 commit comments

Comments
 (0)