diff options
author | Anton Blanchard <anton@samba.org> | 2012-11-26 12:41:08 -0500 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-01-10 01:00:31 -0500 |
commit | 1fbe9cf2598dae3bd464d860bd89c67b1ff8682b (patch) | |
tree | c07f1fe789777669466bc3077a5f0afa70cf83b6 /arch/powerpc/kernel/head_64.S | |
parent | 5827d4165ac608d7c26fa68701391e80824ee5c9 (diff) |
powerpc: Build kernel with -mcmodel=medium
Finally remove the two level TOC and build with -mcmodel=medium.
Unfortunately we can't build modules with -mcmodel=medium due to
the tricks the kernel module loader plays with percpu data:
# -mcmodel=medium breaks modules because it uses 32bit offsets from
# the TOC pointer to create pointers where possible. Pointers into the
# percpu data area are created by this method.
#
# The kernel module loader relocates the percpu data section from the
# original location (starting with 0xd...) to somewhere in the base
# kernel percpu data space (starting with 0xc...). We need a full
# 64bit relocation for this to work, hence -mcmodel=large.
On older kernels we fall back to the two level TOC (-mminimal-toc)
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/kernel/head_64.S')
-rw-r--r-- | arch/powerpc/kernel/head_64.S | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S index 116f0868695b..1697a25ebe91 100644 --- a/arch/powerpc/kernel/head_64.S +++ b/arch/powerpc/kernel/head_64.S | |||
@@ -169,6 +169,7 @@ _GLOBAL(generic_secondary_thread_init) | |||
169 | 169 | ||
170 | /* get a valid TOC pointer, wherever we're mapped at */ | 170 | /* get a valid TOC pointer, wherever we're mapped at */ |
171 | bl .relative_toc | 171 | bl .relative_toc |
172 | tovirt(r2,r2) | ||
172 | 173 | ||
173 | #ifdef CONFIG_PPC_BOOK3E | 174 | #ifdef CONFIG_PPC_BOOK3E |
174 | /* Book3E initialization */ | 175 | /* Book3E initialization */ |
@@ -195,6 +196,7 @@ _GLOBAL(generic_secondary_smp_init) | |||
195 | 196 | ||
196 | /* get a valid TOC pointer, wherever we're mapped at */ | 197 | /* get a valid TOC pointer, wherever we're mapped at */ |
197 | bl .relative_toc | 198 | bl .relative_toc |
199 | tovirt(r2,r2) | ||
198 | 200 | ||
199 | #ifdef CONFIG_PPC_BOOK3E | 201 | #ifdef CONFIG_PPC_BOOK3E |
200 | /* Book3E initialization */ | 202 | /* Book3E initialization */ |
@@ -531,6 +533,7 @@ _GLOBAL(pmac_secondary_start) | |||
531 | 533 | ||
532 | /* get TOC pointer (real address) */ | 534 | /* get TOC pointer (real address) */ |
533 | bl .relative_toc | 535 | bl .relative_toc |
536 | tovirt(r2,r2) | ||
534 | 537 | ||
535 | /* Copy some CPU settings from CPU 0 */ | 538 | /* Copy some CPU settings from CPU 0 */ |
536 | bl .__restore_cpu_ppc970 | 539 | bl .__restore_cpu_ppc970 |
@@ -665,6 +668,13 @@ _GLOBAL(enable_64b_mode) | |||
665 | * This puts the TOC pointer into r2, offset by 0x8000 (as expected | 668 | * This puts the TOC pointer into r2, offset by 0x8000 (as expected |
666 | * by the toolchain). It computes the correct value for wherever we | 669 | * by the toolchain). It computes the correct value for wherever we |
667 | * are running at the moment, using position-independent code. | 670 | * are running at the moment, using position-independent code. |
671 | * | ||
672 | * Note: The compiler constructs pointers using offsets from the | ||
673 | * TOC in -mcmodel=medium mode. After we relocate to 0 but before | ||
674 | * the MMU is on we need our TOC to be a virtual address otherwise | ||
675 | * these pointers will be real addresses which may get stored and | ||
676 | * accessed later with the MMU on. We use tovirt() at the call | ||
677 | * sites to handle this. | ||
668 | */ | 678 | */ |
669 | _GLOBAL(relative_toc) | 679 | _GLOBAL(relative_toc) |
670 | mflr r0 | 680 | mflr r0 |
@@ -681,8 +691,9 @@ p_toc: .llong __toc_start + 0x8000 - 0b | |||
681 | * This is where the main kernel code starts. | 691 | * This is where the main kernel code starts. |
682 | */ | 692 | */ |
683 | _INIT_STATIC(start_here_multiplatform) | 693 | _INIT_STATIC(start_here_multiplatform) |
684 | /* set up the TOC (real address) */ | 694 | /* set up the TOC */ |
685 | bl .relative_toc | 695 | bl .relative_toc |
696 | tovirt(r2,r2) | ||
686 | 697 | ||
687 | /* Clear out the BSS. It may have been done in prom_init, | 698 | /* Clear out the BSS. It may have been done in prom_init, |
688 | * already but that's irrelevant since prom_init will soon | 699 | * already but that's irrelevant since prom_init will soon |