diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-09-04 05:47:48 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-10-04 15:23:36 -0400 |
commit | f00ec48fadf5e37e7889f14cff900aa70d18b644 (patch) | |
tree | 421cbce97167a78532aa825624f380caade3c0d2 /arch/arm/kernel | |
parent | 067173526c3bbc2eaeefcf6b7b2a9d998b9e8042 (diff) |
ARM: Allow SMP kernels to boot on UP systems
UP systems do not implement all the instructions that SMP systems have,
so in order to boot a SMP kernel on a UP system, we need to rewrite
parts of the kernel.
Do this using an 'alternatives' scheme, where the kernel code and data
is modified prior to initialization to replace the SMP instructions,
thereby rendering the problematical code ineffectual. We use the linker
to generate a list of 32-bit word locations and their replacement values,
and run through these replacements when we detect a UP system.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r-- | arch/arm/kernel/entry-armv.S | 11 | ||||
-rw-r--r-- | arch/arm/kernel/head.S | 50 | ||||
-rw-r--r-- | arch/arm/kernel/setup.c | 4 | ||||
-rw-r--r-- | arch/arm/kernel/vmlinux.lds.S | 11 |
4 files changed, 69 insertions, 7 deletions
diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index bb8e93a76407..c09e3573c5de 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S | |||
@@ -46,7 +46,8 @@ | |||
46 | * this macro assumes that irqstat (r6) and base (r5) are | 46 | * this macro assumes that irqstat (r6) and base (r5) are |
47 | * preserved from get_irqnr_and_base above | 47 | * preserved from get_irqnr_and_base above |
48 | */ | 48 | */ |
49 | test_for_ipi r0, r6, r5, lr | 49 | ALT_SMP(test_for_ipi r0, r6, r5, lr) |
50 | ALT_UP_B(9997f) | ||
50 | movne r0, sp | 51 | movne r0, sp |
51 | adrne lr, BSYM(1b) | 52 | adrne lr, BSYM(1b) |
52 | bne do_IPI | 53 | bne do_IPI |
@@ -57,6 +58,7 @@ | |||
57 | adrne lr, BSYM(1b) | 58 | adrne lr, BSYM(1b) |
58 | bne do_local_timer | 59 | bne do_local_timer |
59 | #endif | 60 | #endif |
61 | 9997: | ||
60 | #endif | 62 | #endif |
61 | 63 | ||
62 | .endm | 64 | .endm |
@@ -965,11 +967,8 @@ kuser_cmpxchg_fixup: | |||
965 | beq 1b | 967 | beq 1b |
966 | rsbs r0, r3, #0 | 968 | rsbs r0, r3, #0 |
967 | /* beware -- each __kuser slot must be 8 instructions max */ | 969 | /* beware -- each __kuser slot must be 8 instructions max */ |
968 | #ifdef CONFIG_SMP | 970 | ALT_SMP(b __kuser_memory_barrier) |
969 | b __kuser_memory_barrier | 971 | ALT_UP(usr_ret lr) |
970 | #else | ||
971 | usr_ret lr | ||
972 | #endif | ||
973 | 972 | ||
974 | #endif | 973 | #endif |
975 | 974 | ||
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index eb62bf947212..b44d21e1e344 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S | |||
@@ -86,6 +86,9 @@ ENTRY(stext) | |||
86 | movs r8, r5 @ invalid machine (r5=0)? | 86 | movs r8, r5 @ invalid machine (r5=0)? |
87 | beq __error_a @ yes, error 'a' | 87 | beq __error_a @ yes, error 'a' |
88 | bl __vet_atags | 88 | bl __vet_atags |
89 | #ifdef CONFIG_SMP_ON_UP | ||
90 | bl __fixup_smp | ||
91 | #endif | ||
89 | bl __create_page_tables | 92 | bl __create_page_tables |
90 | 93 | ||
91 | /* | 94 | /* |
@@ -333,4 +336,51 @@ __create_page_tables: | |||
333 | ENDPROC(__create_page_tables) | 336 | ENDPROC(__create_page_tables) |
334 | .ltorg | 337 | .ltorg |
335 | 338 | ||
339 | #ifdef CONFIG_SMP_ON_UP | ||
340 | __fixup_smp: | ||
341 | mov r7, #0x00070000 | ||
342 | orr r6, r7, #0xff000000 @ mask 0xff070000 | ||
343 | orr r7, r7, #0x41000000 @ val 0x41070000 | ||
344 | and r0, r9, r6 | ||
345 | teq r0, r7 @ ARM CPU and ARMv6/v7? | ||
346 | bne __fixup_smp_on_up @ no, assume UP | ||
347 | |||
348 | orr r6, r6, #0x0000ff00 | ||
349 | orr r6, r6, #0x000000f0 @ mask 0xff07fff0 | ||
350 | orr r7, r7, #0x0000b000 | ||
351 | orr r7, r7, #0x00000020 @ val 0x4107b020 | ||
352 | and r0, r9, r6 | ||
353 | teq r0, r7 @ ARM 11MPCore? | ||
354 | moveq pc, lr @ yes, assume SMP | ||
355 | |||
356 | mrc p15, 0, r0, c0, c0, 5 @ read MPIDR | ||
357 | tst r0, #1 << 31 | ||
358 | movne pc, lr @ bit 31 => SMP | ||
359 | |||
360 | __fixup_smp_on_up: | ||
361 | adr r0, 1f | ||
362 | ldmia r0, {r3, r6, r7} | ||
363 | sub r3, r0, r3 | ||
364 | add r6, r6, r3 | ||
365 | add r7, r7, r3 | ||
366 | 2: cmp r6, r7 | ||
367 | ldmia r6!, {r0, r4} | ||
368 | strlo r4, [r0, r3] | ||
369 | blo 2b | ||
370 | mov pc, lr | ||
371 | ENDPROC(__fixup_smp) | ||
372 | |||
373 | 1: .word . | ||
374 | .word __smpalt_begin | ||
375 | .word __smpalt_end | ||
376 | |||
377 | .pushsection .data | ||
378 | .globl smp_on_up | ||
379 | smp_on_up: | ||
380 | ALT_SMP(.long 1) | ||
381 | ALT_UP(.long 0) | ||
382 | .popsection | ||
383 | |||
384 | #endif | ||
385 | |||
336 | #include "head-common.S" | 386 | #include "head-common.S" |
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index d5231ae7355a..5a82c39ca85e 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <asm/procinfo.h> | 36 | #include <asm/procinfo.h> |
37 | #include <asm/sections.h> | 37 | #include <asm/sections.h> |
38 | #include <asm/setup.h> | 38 | #include <asm/setup.h> |
39 | #include <asm/smp_plat.h> | ||
39 | #include <asm/mach-types.h> | 40 | #include <asm/mach-types.h> |
40 | #include <asm/cacheflush.h> | 41 | #include <asm/cacheflush.h> |
41 | #include <asm/cachetype.h> | 42 | #include <asm/cachetype.h> |
@@ -825,7 +826,8 @@ void __init setup_arch(char **cmdline_p) | |||
825 | request_standard_resources(&meminfo, mdesc); | 826 | request_standard_resources(&meminfo, mdesc); |
826 | 827 | ||
827 | #ifdef CONFIG_SMP | 828 | #ifdef CONFIG_SMP |
828 | smp_init_cpus(); | 829 | if (is_smp()) |
830 | smp_init_cpus(); | ||
829 | #endif | 831 | #endif |
830 | reserve_crashkernel(); | 832 | reserve_crashkernel(); |
831 | 833 | ||
diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index b16c07914b55..fd5750b8ac84 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S | |||
@@ -40,6 +40,11 @@ SECTIONS | |||
40 | __tagtable_begin = .; | 40 | __tagtable_begin = .; |
41 | *(.taglist.init) | 41 | *(.taglist.init) |
42 | __tagtable_end = .; | 42 | __tagtable_end = .; |
43 | #ifdef CONFIG_SMP_ON_UP | ||
44 | __smpalt_begin = .; | ||
45 | *(.alt.smp.init) | ||
46 | __smpalt_end = .; | ||
47 | #endif | ||
43 | 48 | ||
44 | INIT_SETUP(16) | 49 | INIT_SETUP(16) |
45 | 50 | ||
@@ -237,6 +242,12 @@ SECTIONS | |||
237 | 242 | ||
238 | /* Default discards */ | 243 | /* Default discards */ |
239 | DISCARDS | 244 | DISCARDS |
245 | |||
246 | #ifndef CONFIG_SMP_ON_UP | ||
247 | /DISCARD/ : { | ||
248 | *(.alt.smp.init) | ||
249 | } | ||
250 | #endif | ||
240 | } | 251 | } |
241 | 252 | ||
242 | /* | 253 | /* |