Skip to content

Commit eb08375

Browse files
committed
ARM: mpu: add MPU initialisation for secondary cores
The MPU initialisation on the primary core is performed in two stages, one minimal stage to ensure the CPU can boot and a second one after sanity_check_meminfo. As the memory configuration is known by the time we boot secondary cores only a single step is necessary, provided the values for DRSR are passed to secondaries. This patch implements this arrangement. The configuration generated for the MPU regions is made available to the secondary core, which can then use the asm MPU intialisation code to program a complete region configuration. This is necessary for SMP configurations without an MMU, as the MPU initialisation is the only way to ensure that memory is specified as 'shared'. Signed-off-by: Jonathan Austin <jonathan.austin@arm.com> Reviewed-by: Will Deacon <will.deacon@arm.com> CC: Nicolas Pitre <nico@linaro.org>
1 parent 9a27156 commit eb08375

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎arch/arm/include/asm/smp.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ asmlinkage void secondary_start_kernel(void);
6565
* Initial data for bringing up a secondary CPU.
6666
*/
6767
struct secondary_data {
68-
unsigned long pgdir;
68+
union {
69+
unsigned long mpu_rgn_szr;
70+
unsigned long pgdir;
71+
};
6972
unsigned long swapper_pg_dir;
7073
void *stack;
7174
};

‎arch/arm/kernel/head-nommu.S‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ ENTRY(secondary_startup)
107107

108108
adr r4, __secondary_data
109109
ldmia r4, {r7, r12}
110+
111+
#ifdef CONFIG_ARM_MPU
112+
/* Use MPU region info supplied by __cpu_up */
113+
ldr r6, [r7] @ get secondary_data.mpu_szr
114+
bl __setup_mpu @ Initialize the MPU
115+
#endif
116+
110117
adr lr, BSYM(__after_proc_init) @ return address
111118
mov r13, r12 @ __secondary_switched address
112119
ARM( add pc, r10, #PROCINFO_INITFUNC )

‎arch/arm/kernel/smp.c‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <asm/smp_plat.h>
4646
#include <asm/virt.h>
4747
#include <asm/mach/arch.h>
48+
#include <asm/mpu.h>
4849

4950
/*
5051
* as from 2.5, kernels no longer have an init_tasks structure
@@ -87,6 +88,10 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
8788
* its stack and the page tables.
8889
*/
8990
secondary_data.stack = task_stack_page(idle) + THREAD_START_SP;
91+
#ifdef CONFIG_ARM_MPU
92+
secondary_data.mpu_rgn_szr = mpu_rgn_info.rgns[MPU_RAM_REGION].drsr;
93+
#endif
94+
9095
#ifdef CONFIG_MMU
9196
secondary_data.pgdir = virt_to_phys(idmap_pgd);
9297
secondary_data.swapper_pg_dir = virt_to_phys(swapper_pg_dir);
@@ -114,9 +119,8 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *idle)
114119
pr_err("CPU%u: failed to boot: %d\n", cpu, ret);
115120
}
116121

117-
secondary_data.stack = NULL;
118-
secondary_data.pgdir = 0;
119122

123+
memset(&secondary_data, 0, sizeof(secondary_data));
120124
return ret;
121125
}
122126

0 commit comments

Comments
 (0)