Skip to content

Commit 3c5b1d9

Browse files
Tirumalesh ChalamarlaMarc Zyngier
Tirumalesh Chalamarla
authored and
Marc Zyngier
committed
arm64: KVM: Configure TCR_EL2.PS at runtime
Setting TCR_EL2.PS to 40 bits is wrong on systems with less that less than 40 bits of physical addresses. and breaks KVM on systems where the RAM is above 40 bits. This patch uses ID_AA64MMFR0_EL1.PARange to set TCR_EL2.PS dynamically, just like we already do for VTCR_EL2.PS. [Marc: rewrote commit message, patch tidy up] Reviewed-by: Marc Zyngier <[email protected]> Signed-off-by: Tirumalesh Chalamarla <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent b3aff6c commit 3c5b1d9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

arch/arm64/include/asm/kvm_arm.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@
107107
#define TCR_EL2_MASK (TCR_EL2_TG0 | TCR_EL2_SH0 | \
108108
TCR_EL2_ORGN0 | TCR_EL2_IRGN0 | TCR_EL2_T0SZ)
109109

110-
#define TCR_EL2_FLAGS (TCR_EL2_RES1 | TCR_EL2_PS_40B)
111-
112110
/* VTCR_EL2 Registers bits */
113111
#define VTCR_EL2_RES1 (1 << 31)
114112
#define VTCR_EL2_PS_MASK (7 << 16)

arch/arm64/kvm/hyp-init.S

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ __do_hyp_init:
6464
mrs x4, tcr_el1
6565
ldr x5, =TCR_EL2_MASK
6666
and x4, x4, x5
67-
ldr x5, =TCR_EL2_FLAGS
67+
mov x5, #TCR_EL2_RES1
6868
orr x4, x4, x5
6969

7070
#ifndef CONFIG_ARM64_VA_BITS_48
@@ -85,15 +85,17 @@ __do_hyp_init:
8585
ldr_l x5, idmap_t0sz
8686
bfi x4, x5, TCR_T0SZ_OFFSET, TCR_TxSZ_WIDTH
8787
#endif
88-
msr tcr_el2, x4
89-
90-
ldr x4, =VTCR_EL2_FLAGS
9188
/*
9289
* Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in
93-
* VTCR_EL2.
90+
* TCR_EL2 and VTCR_EL2.
9491
*/
9592
mrs x5, ID_AA64MMFR0_EL1
9693
bfi x4, x5, #16, #3
94+
95+
msr tcr_el2, x4
96+
97+
ldr x4, =VTCR_EL2_FLAGS
98+
bfi x4, x5, #16, #3
9799
/*
98100
* Read the VMIDBits bits from ID_AA64MMFR1_EL1 and set the VS bit in
99101
* VTCR_EL2.

0 commit comments

Comments
 (0)