aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/paca.c
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2008-08-29 21:43:47 -0400
committerPaul Mackerras <paulus@samba.org>2008-09-15 14:08:38 -0400
commit549e8152de8039506f69c677a4546e5427aa6ae7 (patch)
treee03a4f46143a23045e456f96fc08beba12e73073 /arch/powerpc/kernel/paca.c
parente31aa453bbc4886a7bd33e5c2afa526d6f55bd7a (diff)
powerpc: Make the 64-bit kernel as a position-independent executable
This implements CONFIG_RELOCATABLE for 64-bit by making the kernel as a position-independent executable (PIE) when it is set. This involves processing the dynamic relocations in the image in the early stages of booting, even if the kernel is being run at the address it is linked at, since the linker does not necessarily fill in words in the image for which there are dynamic relocations. (In fact the linker does fill in such words for 64-bit executables, though not for 32-bit executables, so in principle we could avoid calling relocate() entirely when we're running a 64-bit kernel at the linked address.) The dynamic relocations are processed by a new function relocate(addr), where the addr parameter is the virtual address where the image will be run. In fact we call it twice; once before calling prom_init, and again when starting the main kernel. This means that reloc_offset() returns 0 in prom_init (since it has been relocated to the address it is running at), which necessitated a few adjustments. This also changes __va and __pa to use an equivalent definition that is simpler. With the relocatable kernel, PAGE_OFFSET and MEMORY_START are constants (for 64-bit) whereas PHYSICAL_START is a variable (and KERNELBASE ideally should be too, but isn't yet). With this, relocatable kernels still copy themselves down to physical address 0 and run there. Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel/paca.c')
-rw-r--r--arch/powerpc/kernel/paca.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/powerpc/kernel/paca.c b/arch/powerpc/kernel/paca.c
index 623e8c3c57f9..48a347133f41 100644
--- a/arch/powerpc/kernel/paca.c
+++ b/arch/powerpc/kernel/paca.c
@@ -12,6 +12,7 @@
12 12
13#include <asm/lppaca.h> 13#include <asm/lppaca.h>
14#include <asm/paca.h> 14#include <asm/paca.h>
15#include <asm/sections.h>
15 16
16/* This symbol is provided by the linker - let it fill in the paca 17/* This symbol is provided by the linker - let it fill in the paca
17 * field correctly */ 18 * field correctly */
@@ -79,7 +80,7 @@ void __init initialise_pacas(void)
79 new_paca->lock_token = 0x8000; 80 new_paca->lock_token = 0x8000;
80 new_paca->paca_index = cpu; 81 new_paca->paca_index = cpu;
81 new_paca->kernel_toc = kernel_toc; 82 new_paca->kernel_toc = kernel_toc;
82 new_paca->kernelbase = KERNELBASE; 83 new_paca->kernelbase = (unsigned long) _stext;
83 new_paca->kernel_msr = MSR_KERNEL; 84 new_paca->kernel_msr = MSR_KERNEL;
84 new_paca->hw_cpu_id = 0xffff; 85 new_paca->hw_cpu_id = 0xffff;
85 new_paca->slb_shadow_ptr = &slb_shadow[cpu]; 86 new_paca->slb_shadow_ptr = &slb_shadow[cpu];