aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-x86_64/page.h
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@in.ibm.com>2007-05-02 13:27:07 -0400
committerAndi Kleen <andi@basil.nowhere.org>2007-05-02 13:27:07 -0400
commit1ab60e0f72f71ec54831e525a3e1154f1c092408 (patch)
treebd7dd8bbff43e3e2e3597f2b7780e82a856bb9d7 /include/asm-x86_64/page.h
parent0dbf7028c0c1f266c9631139450a1502d3cd457e (diff)
[PATCH] x86-64: Relocatable Kernel Support
This patch modifies the x86_64 kernel so that it can be loaded and run at any 2M aligned address, below 512G. The technique used is to compile the decompressor with -fPIC and modify it so the decompressor is fully relocatable. For the main kernel the page tables are modified so the kernel remains at the same virtual address. In addition a variable phys_base is kept that holds the physical address the kernel is loaded at. __pa_symbol is modified to add that when we take the address of a kernel symbol. When loaded with a normal bootloader the decompressor will decompress the kernel to 2M and it will run there. This both ensures the relocation code is always working, and makes it easier to use 2M pages for the kernel and the cpu. AK: changed to not make RELOCATABLE default in Kconfig Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com> Signed-off-by: Andi Kleen <ak@suse.de>
Diffstat (limited to 'include/asm-x86_64/page.h')
-rw-r--r--include/asm-x86_64/page.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/include/asm-x86_64/page.h b/include/asm-x86_64/page.h
index 4974433bbf34..40a24d0df090 100644
--- a/include/asm-x86_64/page.h
+++ b/include/asm-x86_64/page.h
@@ -61,6 +61,8 @@ typedef struct { unsigned long pgd; } pgd_t;
61 61
62typedef struct { unsigned long pgprot; } pgprot_t; 62typedef struct { unsigned long pgprot; } pgprot_t;
63 63
64extern unsigned long phys_base;
65
64#define pte_val(x) ((x).pte) 66#define pte_val(x) ((x).pte)
65#define pmd_val(x) ((x).pmd) 67#define pmd_val(x) ((x).pmd)
66#define pud_val(x) ((x).pud) 68#define pud_val(x) ((x).pud)
@@ -101,14 +103,14 @@ typedef struct { unsigned long pgprot; } pgprot_t;
101#define PAGE_OFFSET __PAGE_OFFSET 103#define PAGE_OFFSET __PAGE_OFFSET
102 104
103/* Note: __pa(&symbol_visible_to_c) should be always replaced with __pa_symbol. 105/* Note: __pa(&symbol_visible_to_c) should be always replaced with __pa_symbol.
104 Otherwise you risk miscompilation. */ 106 Otherwise you risk miscompilation. */
105#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) 107#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET)
106/* __pa_symbol should be used for C visible symbols. 108/* __pa_symbol should be used for C visible symbols.
107 This seems to be the official gcc blessed way to do such arithmetic. */ 109 This seems to be the official gcc blessed way to do such arithmetic. */
108#define __pa_symbol(x) \ 110#define __pa_symbol(x) \
109 ({unsigned long v; \ 111 ({unsigned long v; \
110 asm("" : "=r" (v) : "0" (x)); \ 112 asm("" : "=r" (v) : "0" (x)); \
111 (v - __START_KERNEL_map); }) 113 ((v - __START_KERNEL_map) + phys_base); })
112 114
113#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) 115#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
114#ifdef CONFIG_FLATMEM 116#ifdef CONFIG_FLATMEM