Skip to content

Commit 37b05b6

Browse files
author
Russell King
committed
ARM: hotplug cpu: setup 1:1 map for entire kernel image for secondary CPUs
Make the entire kernel image available for secondary CPUs rather than just the first MB of memory. This allows the startup code to appear in the cpuinit sections. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
1 parent f131a08 commit 37b05b6

1 file changed

Lines changed: 55 additions & 8 deletions

File tree

‎arch/arm/kernel/smp.c‎

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <asm/pgtable.h>
3434
#include <asm/pgalloc.h>
3535
#include <asm/processor.h>
36+
#include <asm/sections.h>
3637
#include <asm/tlbflush.h>
3738
#include <asm/ptrace.h>
3839
#include <asm/localtimer.h>
@@ -67,12 +68,47 @@ enum ipi_msg_type {
6768
IPI_CPU_STOP,
6869
};
6970

71+
static inline void identity_mapping_add(pgd_t *pgd, unsigned long start,
72+
unsigned long end)
73+
{
74+
unsigned long addr, prot;
75+
pmd_t *pmd;
76+
77+
prot = PMD_TYPE_SECT | PMD_SECT_AP_WRITE;
78+
if (cpu_architecture() <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale())
79+
prot |= PMD_BIT4;
80+
81+
for (addr = start & PGDIR_MASK; addr < end;) {
82+
pmd = pmd_offset(pgd + pgd_index(addr), addr);
83+
pmd[0] = __pmd(addr | prot);
84+
addr += SECTION_SIZE;
85+
pmd[1] = __pmd(addr | prot);
86+
addr += SECTION_SIZE;
87+
flush_pmd_entry(pmd);
88+
outer_clean_range(__pa(pmd), __pa(pmd + 1));
89+
}
90+
}
91+
92+
static inline void identity_mapping_del(pgd_t *pgd, unsigned long start,
93+
unsigned long end)
94+
{
95+
unsigned long addr;
96+
pmd_t *pmd;
97+
98+
for (addr = start & PGDIR_MASK; addr < end; addr += PGDIR_SIZE) {
99+
pmd = pmd_offset(pgd + pgd_index(addr), addr);
100+
pmd[0] = __pmd(0);
101+
pmd[1] = __pmd(0);
102+
clean_pmd_entry(pmd);
103+
outer_clean_range(__pa(pmd), __pa(pmd + 1));
104+
}
105+
}
106+
70107
int __cpuinit __cpu_up(unsigned int cpu)
71108
{
72109
struct cpuinfo_arm *ci = &per_cpu(cpu_data, cpu);
73110
struct task_struct *idle = ci->idle;
74111
pgd_t *pgd;
75-
pmd_t *pmd;
76112
int ret;
77113

78114
/*
@@ -101,11 +137,16 @@ int __cpuinit __cpu_up(unsigned int cpu)
101137
* a 1:1 mapping for the physical address of the kernel.
102138
*/
103139
pgd = pgd_alloc(&init_mm);
104-
pmd = pmd_offset(pgd + pgd_index(PHYS_OFFSET), PHYS_OFFSET);
105-
*pmd = __pmd((PHYS_OFFSET & PGDIR_MASK) |
106-
PMD_TYPE_SECT | PMD_SECT_AP_WRITE);
107-
flush_pmd_entry(pmd);
108-
outer_clean_range(__pa(pmd), __pa(pmd + 1));
140+
if (!pgd)
141+
return -ENOMEM;
142+
143+
if (PHYS_OFFSET != PAGE_OFFSET) {
144+
#ifndef CONFIG_HOTPLUG_CPU
145+
identity_mapping_add(pgd, __pa(__init_begin), __pa(__init_end));
146+
#endif
147+
identity_mapping_add(pgd, __pa(_stext), __pa(_etext));
148+
identity_mapping_add(pgd, __pa(_sdata), __pa(_edata));
149+
}
109150

110151
/*
111152
* We need to tell the secondary core where to find
@@ -143,8 +184,14 @@ int __cpuinit __cpu_up(unsigned int cpu)
143184
secondary_data.stack = NULL;
144185
secondary_data.pgdir = 0;
145186

146-
*pmd = __pmd(0);
147-
clean_pmd_entry(pmd);
187+
if (PHYS_OFFSET != PAGE_OFFSET) {
188+
#ifndef CONFIG_HOTPLUG_CPU
189+
identity_mapping_del(pgd, __pa(__init_begin), __pa(__init_end));
190+
#endif
191+
identity_mapping_del(pgd, __pa(_stext), __pa(_etext));
192+
identity_mapping_del(pgd, __pa(_sdata), __pa(_edata));
193+
}
194+
148195
pgd_free(&init_mm, pgd);
149196

150197
if (ret) {

0 commit comments

Comments
 (0)