aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm64/mm
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2015-03-19 12:42:27 -0400
committerWill Deacon <will.deacon@arm.com>2015-03-23 07:35:29 -0400
commitdd006da21646f1c86f0242eb8f527d093303127a (patch)
treeb67ea3943e04f7d6b643b0f38c4cba7f3db42ace /arch/arm64/mm
parent6232cfd0fa01fe392df0b18a3a06628f130b83b2 (diff)
arm64: mm: increase VA range of identity map
The page size and the number of translation levels, and hence the supported virtual address range, are build-time configurables on arm64 whose optimal values are use case dependent. However, in the current implementation, if the system's RAM is located at a very high offset, the virtual address range needs to reflect that merely because the identity mapping, which is only used to enable or disable the MMU, requires the extended virtual range to map the physical memory at an equal virtual offset. This patch relaxes that requirement, by increasing the number of translation levels for the identity mapping only, and only when actually needed, i.e., when system RAM's offset is found to be out of reach at runtime. Tested-by: Laura Abbott <lauraa@codeaurora.org> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Tested-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/mm')
-rw-r--r--arch/arm64/mm/mmu.c7
-rw-r--r--arch/arm64/mm/proc-macros.S10
-rw-r--r--arch/arm64/mm/proc.S3
3 files changed, 19 insertions, 1 deletions
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index c9267acb699c..428aaf86c95b 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -40,6 +40,8 @@
40 40
41#include "mm.h" 41#include "mm.h"
42 42
43u64 idmap_t0sz = TCR_T0SZ(VA_BITS);
44
43/* 45/*
44 * Empty_zero_page is a special page that is used for zero-initialized data 46 * Empty_zero_page is a special page that is used for zero-initialized data
45 * and COW. 47 * and COW.
@@ -454,6 +456,7 @@ void __init paging_init(void)
454 */ 456 */
455 cpu_set_reserved_ttbr0(); 457 cpu_set_reserved_ttbr0();
456 flush_tlb_all(); 458 flush_tlb_all();
459 cpu_set_default_tcr_t0sz();
457} 460}
458 461
459/* 462/*
@@ -461,8 +464,10 @@ void __init paging_init(void)
461 */ 464 */
462void setup_mm_for_reboot(void) 465void setup_mm_for_reboot(void)
463{ 466{
464 cpu_switch_mm(idmap_pg_dir, &init_mm); 467 cpu_set_reserved_ttbr0();
465 flush_tlb_all(); 468 flush_tlb_all();
469 cpu_set_idmap_tcr_t0sz();
470 cpu_switch_mm(idmap_pg_dir, &init_mm);
466} 471}
467 472
468/* 473/*
diff --git a/arch/arm64/mm/proc-macros.S b/arch/arm64/mm/proc-macros.S
index 005d29e2977d..4c4d93c4bf65 100644
--- a/arch/arm64/mm/proc-macros.S
+++ b/arch/arm64/mm/proc-macros.S
@@ -52,3 +52,13 @@
52 mov \reg, #4 // bytes per word 52 mov \reg, #4 // bytes per word
53 lsl \reg, \reg, \tmp // actual cache line size 53 lsl \reg, \reg, \tmp // actual cache line size
54 .endm 54 .endm
55
56/*
57 * tcr_set_idmap_t0sz - update TCR.T0SZ so that we can load the ID map
58 */
59 .macro tcr_set_idmap_t0sz, valreg, tmpreg
60#ifndef CONFIG_ARM64_VA_BITS_48
61 ldr_l \tmpreg, idmap_t0sz
62 bfi \valreg, \tmpreg, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
63#endif
64 .endm
diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S
index 28eebfb6af76..cdd754e19b9b 100644
--- a/arch/arm64/mm/proc.S
+++ b/arch/arm64/mm/proc.S
@@ -156,6 +156,7 @@ ENTRY(cpu_do_resume)
156 msr cpacr_el1, x6 156 msr cpacr_el1, x6
157 msr ttbr0_el1, x1 157 msr ttbr0_el1, x1
158 msr ttbr1_el1, x7 158 msr ttbr1_el1, x7
159 tcr_set_idmap_t0sz x8, x7
159 msr tcr_el1, x8 160 msr tcr_el1, x8
160 msr vbar_el1, x9 161 msr vbar_el1, x9
161 msr mdscr_el1, x10 162 msr mdscr_el1, x10
@@ -233,6 +234,8 @@ ENTRY(__cpu_setup)
233 */ 234 */
234 ldr x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \ 235 ldr x10, =TCR_TxSZ(VA_BITS) | TCR_CACHE_FLAGS | TCR_SMP_FLAGS | \
235 TCR_TG_FLAGS | TCR_ASID16 | TCR_TBI0 236 TCR_TG_FLAGS | TCR_ASID16 | TCR_TBI0
237 tcr_set_idmap_t0sz x10, x9
238
236 /* 239 /*
237 * Read the PARange bits from ID_AA64MMFR0_EL1 and set the IPS bits in 240 * Read the PARange bits from ID_AA64MMFR0_EL1 and set the IPS bits in
238 * TCR_EL1. 241 * TCR_EL1.