aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2011-11-23 07:26:25 -0500
committerWill Deacon <will.deacon@arm.com>2011-12-06 09:04:15 -0500
commit4e8ee7de227e3ab9a72040b448ad728c5428a042 (patch)
treeffaf8492fd359d3281a55ff6e751504e905cc27c /arch
parent72662e01088394577be4a3f14da94cf87bea2591 (diff)
ARM: SMP: use idmap_pgd for mapping MMU enable during secondary booting
The ARM SMP booting code allocates a temporary set of page tables containing an identity mapping of the kernel image and provides this to secondary CPUs for initial booting. In reality, we only need to include the __turn_mmu_on function in the identity mapping since the rest of the kernel is executing from virtual addresses after this point. This patch adds __turn_mmu_on to the .idmap.text section, allowing the SMP booting code to use the idmap_pgd directly and not have to populate its own set of page table. As a result of this patch, we can make the identity_mapping_add function static (since it is only used within mm/idmap.c) and also remove the identity_mapping_del function. The identity map population is moved to an early initcall so that it is setup in time for secondary CPU bringup. Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/include/asm/idmap.h3
-rw-r--r--arch/arm/kernel/head.S4
-rw-r--r--arch/arm/kernel/smp.c31
-rw-r--r--arch/arm/mm/idmap.c34
4 files changed, 6 insertions, 66 deletions
diff --git a/arch/arm/include/asm/idmap.h b/arch/arm/include/asm/idmap.h
index 62e3d19c9ad..bf863edb517 100644
--- a/arch/arm/include/asm/idmap.h
+++ b/arch/arm/include/asm/idmap.h
@@ -9,9 +9,6 @@
9 9
10extern pgd_t *idmap_pgd; 10extern pgd_t *idmap_pgd;
11 11
12void identity_mapping_add(pgd_t *, unsigned long, unsigned long);
13void identity_mapping_del(pgd_t *, unsigned long, unsigned long);
14
15void setup_mm_for_reboot(void); 12void setup_mm_for_reboot(void);
16 13
17#endif /* __ASM_IDMAP_H */ 14#endif /* __ASM_IDMAP_H */
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
index 43e3aa3b057..64e9943ea4f 100644
--- a/arch/arm/kernel/head.S
+++ b/arch/arm/kernel/head.S
@@ -398,7 +398,8 @@ ENDPROC(__enable_mmu)
398 * other registers depend on the function called upon completion 398 * other registers depend on the function called upon completion
399 */ 399 */
400 .align 5 400 .align 5
401__turn_mmu_on: 401 .pushsection .idmap.text, "ax"
402ENTRY(__turn_mmu_on)
402 mov r0, r0 403 mov r0, r0
403 mcr p15, 0, r0, c1, c0, 0 @ write control reg 404 mcr p15, 0, r0, c1, c0, 0 @ write control reg
404 mrc p15, 0, r3, c0, c0, 0 @ read id reg 405 mrc p15, 0, r3, c0, c0, 0 @ read id reg
@@ -407,6 +408,7 @@ __turn_mmu_on:
407 mov pc, r3 408 mov pc, r3
408__turn_mmu_on_end: 409__turn_mmu_on_end:
409ENDPROC(__turn_mmu_on) 410ENDPROC(__turn_mmu_on)
411 .popsection
410 412
411 413
412#ifdef CONFIG_SMP_ON_UP 414#ifdef CONFIG_SMP_ON_UP
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index 8afadda3745..76ff28d87bf 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -62,7 +62,6 @@ int __cpuinit __cpu_up(unsigned int cpu)
62{ 62{
63 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu); 63 struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
64 struct task_struct *idle = ci->idle; 64 struct task_struct *idle = ci->idle;
65 pgd_t *pgd;
66 int ret; 65 int ret;
67 66
68 /* 67 /*
@@ -85,29 +84,11 @@ int __cpuinit __cpu_up(unsigned int cpu)
85 } 84 }
86 85
87 /* 86 /*
88 * Allocate initial page tables to allow the new CPU to
89 * enable the MMU safely. This essentially means a set
90 * of our "standard" page tables, with the addition of
91 * a 1:1 mapping for the physical address of the kernel.
92 */
93 pgd = pgd_alloc(&init_mm);
94 if (!pgd)
95 return -ENOMEM;
96
97 if (PHYS_OFFSET != PAGE_OFFSET) {
98#ifndef CONFIG_HOTPLUG_CPU
99 identity_mapping_add(pgd, __pa(__init_begin), __pa(__init_end));
100#endif
101 identity_mapping_add(pgd, __pa(_stext), __pa(_etext));
102 identity_mapping_add(pgd, __pa(_sdata), __pa(_edata));
103 }
104
105 /*
106 * We need to tell the secondary core where to find 87 * We need to tell the secondary core where to find
107 * its stack and the page tables. 88 * its stack and the page tables.
108 */ 89 */
109 secondary_data.stack = task_stack_page(idle) + THREAD_START_SP; 90 secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
110 secondary_data.pgdir = virt_to_phys(pgd); 91 secondary_data.pgdir = virt_to_phys(idmap_pgd);
111 secondary_data.swapper_pg_dir = virt_to_phys(swapper_pg_dir); 92 secondary_data.swapper_pg_dir = virt_to_phys(swapper_pg_dir);
112 __cpuc_flush_dcache_area(&secondary_data, sizeof(secondary_data)); 93 __cpuc_flush_dcache_area(&secondary_data, sizeof(secondary_data));
113 outer_clean_range(__pa(&secondary_data), __pa(&secondary_data + 1)); 94 outer_clean_range(__pa(&secondary_data), __pa(&secondary_data + 1));
@@ -143,16 +124,6 @@ int __cpuinit __cpu_up(unsigned int cpu)
143 secondary_data.stack = NULL; 124 secondary_data.stack = NULL;
144 secondary_data.pgdir = 0; 125 secondary_data.pgdir = 0;
145 126
146 if (PHYS_OFFSET != PAGE_OFFSET) {
147#ifndef CONFIG_HOTPLUG_CPU
148 identity_mapping_del(pgd, __pa(__init_begin), __pa(__init_end));
149#endif
150 identity_mapping_del(pgd, __pa(_stext), __pa(_etext));
151 identity_mapping_del(pgd, __pa(_sdata), __pa(_edata));
152 }
153
154 pgd_free(&init_mm, pgd);
155
156 return ret; 127 return ret;
157} 128}
158 129
diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c
index b01760e6da1..660f1bc68f9 100644
--- a/arch/arm/mm/idmap.c
+++ b/arch/arm/mm/idmap.c
@@ -32,7 +32,7 @@ static void idmap_add_pud(pgd_t *pgd, unsigned long addr, unsigned long end,
32 } while (pud++, addr = next, addr != end); 32 } while (pud++, addr = next, addr != end);
33} 33}
34 34
35void identity_mapping_add(pgd_t *pgd, unsigned long addr, unsigned long end) 35static void identity_mapping_add(pgd_t *pgd, unsigned long addr, unsigned long end)
36{ 36{
37 unsigned long prot, next; 37 unsigned long prot, next;
38 38
@@ -47,36 +47,6 @@ void identity_mapping_add(pgd_t *pgd, unsigned long addr, unsigned long end)
47 } while (pgd++, addr = next, addr != end); 47 } while (pgd++, addr = next, addr != end);
48} 48}
49 49
50#ifdef CONFIG_SMP
51static void idmap_del_pmd(pud_t *pud, unsigned long addr, unsigned long end)
52{
53 pmd_t *pmd = pmd_offset(pud, addr);
54 pmd_clear(pmd);
55}
56
57static void idmap_del_pud(pgd_t *pgd, unsigned long addr, unsigned long end)
58{
59 pud_t *pud = pud_offset(pgd, addr);
60 unsigned long next;
61
62 do {
63 next = pud_addr_end(addr, end);
64 idmap_del_pmd(pud, addr, next);
65 } while (pud++, addr = next, addr != end);
66}
67
68void identity_mapping_del(pgd_t *pgd, unsigned long addr, unsigned long end)
69{
70 unsigned long next;
71
72 pgd += pgd_index(addr);
73 do {
74 next = pgd_addr_end(addr, end);
75 idmap_del_pud(pgd, addr, next);
76 } while (pgd++, addr = next, addr != end);
77}
78#endif
79
80extern char __idmap_text_start[], __idmap_text_end[]; 50extern char __idmap_text_start[], __idmap_text_end[];
81 51
82static int __init init_static_idmap(void) 52static int __init init_static_idmap(void)
@@ -97,7 +67,7 @@ static int __init init_static_idmap(void)
97 67
98 return 0; 68 return 0;
99} 69}
100arch_initcall(init_static_idmap); 70early_initcall(init_static_idmap);
101 71
102/* 72/*
103 * In order to soft-boot, we need to switch to a 1:1 mapping for the 73 * In order to soft-boot, we need to switch to a 1:1 mapping for the