Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: Add boot time configuration of Intermediate Physical Address size

ARMv8 supports a range of physical address bit sizes. The PARange bits
from ID_AA64MMFR0_EL1 register are read during boot-time and the
intermediate physical address size bits are written in the translation
control registers (TCR_EL1 and VTCR_EL2).

There is no change in the VA bits and levels of translation.

Signed-off-by: Radha Mohan Chintakuntla <rchintakuntla@cavium.com>
Reviewed-by: Will Deacon <Will.deacon@arm.com>
Acked-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

authored by

Radha Mohan Chintakuntla and committed by
Catalin Marinas
87366d8c 71fdb6bf

+21 -13
+6 -9
arch/arm64/include/asm/kvm_arm.h
··· 106 106 107 107 /* VTCR_EL2 Registers bits */ 108 108 #define VTCR_EL2_PS_MASK (7 << 16) 109 - #define VTCR_EL2_PS_40B (2 << 16) 110 109 #define VTCR_EL2_TG0_MASK (1 << 14) 111 110 #define VTCR_EL2_TG0_4K (0 << 14) 112 111 #define VTCR_EL2_TG0_64K (1 << 14) ··· 128 129 * 64kB pages (TG0 = 1) 129 130 * 2 level page tables (SL = 1) 130 131 */ 131 - #define VTCR_EL2_FLAGS (VTCR_EL2_PS_40B | VTCR_EL2_TG0_64K | \ 132 - VTCR_EL2_SH0_INNER | VTCR_EL2_ORGN0_WBWA | \ 133 - VTCR_EL2_IRGN0_WBWA | VTCR_EL2_SL0_LVL1 | \ 134 - VTCR_EL2_T0SZ_40B) 132 + #define VTCR_EL2_FLAGS (VTCR_EL2_TG0_64K | VTCR_EL2_SH0_INNER | \ 133 + VTCR_EL2_ORGN0_WBWA | VTCR_EL2_IRGN0_WBWA | \ 134 + VTCR_EL2_SL0_LVL1 | VTCR_EL2_T0SZ_40B) 135 135 #define VTTBR_X (38 - VTCR_EL2_T0SZ_40B) 136 136 #else 137 137 /* ··· 140 142 * 4kB pages (TG0 = 0) 141 143 * 3 level page tables (SL = 1) 142 144 */ 143 - #define VTCR_EL2_FLAGS (VTCR_EL2_PS_40B | VTCR_EL2_TG0_4K | \ 144 - VTCR_EL2_SH0_INNER | VTCR_EL2_ORGN0_WBWA | \ 145 - VTCR_EL2_IRGN0_WBWA | VTCR_EL2_SL0_LVL1 | \ 146 - VTCR_EL2_T0SZ_40B) 145 + #define VTCR_EL2_FLAGS (VTCR_EL2_TG0_4K | VTCR_EL2_SH0_INNER | \ 146 + VTCR_EL2_ORGN0_WBWA | VTCR_EL2_IRGN0_WBWA | \ 147 + VTCR_EL2_SL0_LVL1 | VTCR_EL2_T0SZ_40B) 147 148 #define VTTBR_X (37 - VTCR_EL2_T0SZ_40B) 148 149 #endif 149 150
+2 -3
arch/arm64/include/asm/pgtable-hwdef.h
··· 100 100 #define PTE_HYP PTE_USER 101 101 102 102 /* 103 - * 40-bit physical address supported. 103 + * Highest possible physical address supported. 104 104 */ 105 - #define PHYS_MASK_SHIFT (40) 105 + #define PHYS_MASK_SHIFT (48) 106 106 #define PHYS_MASK ((UL(1) << PHYS_MASK_SHIFT) - 1) 107 107 108 108 /* ··· 122 122 #define TCR_SHARED ((UL(3) << 12) | (UL(3) << 28)) 123 123 #define TCR_TG0_64K (UL(1) << 14) 124 124 #define TCR_TG1_64K (UL(1) << 30) 125 - #define TCR_IPS_40BIT (UL(2) << 32) 126 125 #define TCR_ASID16 (UL(1) << 36) 127 126 #define TCR_TBI0 (UL(1) << 37) 128 127
+6
arch/arm64/kvm/hyp-init.S
··· 68 68 msr tcr_el2, x4 69 69 70 70 ldr x4, =VTCR_EL2_FLAGS 71 + /* 72 + * Read the PARange bits from ID_AA64MMFR0_EL1 and set the PS bits in 73 + * VTCR_EL2. 74 + */ 75 + mrs x5, ID_AA64MMFR0_EL1 76 + bfi x4, x5, #16, #3 71 77 msr vtcr_el2, x4 72 78 73 79 mrs x4, mair_el1
+7 -1
arch/arm64/mm/proc.S
··· 209 209 * Set/prepare TCR and TTBR. We use 512GB (39-bit) address range for 210 210 * both user and kernel. 211 211 */ 212 - ldr x10, =TCR_TxSZ(VA_BITS) | TCR_FLAGS | TCR_IPS_40BIT | \ 212 + ldr x10, =TCR_TxSZ(VA_BITS) | TCR_FLAGS | \ 213 213 TCR_ASID16 | TCR_TBI0 | (1 << 31) 214 + /* 215 + * Read the PARange bits from ID_AA64MMFR0_EL1 and set the IPS bits in 216 + * TCR_EL1. 217 + */ 218 + mrs x9, ID_AA64MMFR0_EL1 219 + bfi x10, x9, #32, #3 214 220 #ifdef CONFIG_ARM64_64K_PAGES 215 221 orr x10, x10, TCR_TG0_64K 216 222 orr x10, x10, TCR_TG1_64K