diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-05-11 18:56:08 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-05-11 20:44:39 -0400 |
commit | 37ba7ab5e33cebc25c68fffe33e9f21e7c2014e8 (patch) | |
tree | 006ba60fcd29b8fdee844ee6d90b85104a254d0d /arch | |
parent | 99aa45595f45603526513d5e29fc00f8afbf3913 (diff) |
x86, boot: make kernel_alignment adjustable; new bzImage fields
Make the kernel_alignment field adjustable; this allows us to set it
to a large value (intended to be 16 MB to avoid ZONE_DMA contention,
memory holes and other weirdness) while a smart bootloader can still
force a loading at a lesser alignment if absolutely necessary.
Also export pref_address (preferred loading address, corresponding to
the link-time address) and init_size, the total amount of linear
memory the kernel will require during initialization.
[ Impact: allows better kernel placement, gives bootloader more info ]
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/boot/compressed/head_32.S | 7 | ||||
-rw-r--r-- | arch/x86/boot/compressed/head_64.S | 14 | ||||
-rw-r--r-- | arch/x86/boot/header.S | 15 | ||||
-rw-r--r-- | arch/x86/include/asm/boot.h | 15 | ||||
-rw-r--r-- | arch/x86/kernel/asm-offsets_32.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/asm-offsets_64.c | 1 |
6 files changed, 45 insertions, 8 deletions
diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S index 2b8e0dfa4b27..75e4f001e706 100644 --- a/arch/x86/boot/compressed/head_32.S +++ b/arch/x86/boot/compressed/head_32.S | |||
@@ -69,8 +69,11 @@ ENTRY(startup_32) | |||
69 | 69 | ||
70 | #ifdef CONFIG_RELOCATABLE | 70 | #ifdef CONFIG_RELOCATABLE |
71 | movl %ebp, %ebx | 71 | movl %ebp, %ebx |
72 | addl $(CONFIG_PHYSICAL_ALIGN - 1), %ebx | 72 | movl BP_kernel_alignment(%esi), %eax |
73 | andl $(~(CONFIG_PHYSICAL_ALIGN - 1)), %ebx | 73 | decl %eax |
74 | addl %eax, %ebx | ||
75 | notl %eax | ||
76 | andl %eax, %ebx | ||
74 | #else | 77 | #else |
75 | movl $LOAD_PHYSICAL_ADDR, %ebx | 78 | movl $LOAD_PHYSICAL_ADDR, %ebx |
76 | #endif | 79 | #endif |
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 2bb500af1bd7..f62c284db9eb 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S | |||
@@ -84,8 +84,11 @@ ENTRY(startup_32) | |||
84 | 84 | ||
85 | #ifdef CONFIG_RELOCATABLE | 85 | #ifdef CONFIG_RELOCATABLE |
86 | movl %ebp, %ebx | 86 | movl %ebp, %ebx |
87 | addl $(PMD_PAGE_SIZE -1), %ebx | 87 | movl BP_kernel_alignment(%esi), %eax |
88 | andl $PMD_PAGE_MASK, %ebx | 88 | decl %eax |
89 | addl %eax, %ebx | ||
90 | notl %eax | ||
91 | andl %eax, %ebx | ||
89 | #else | 92 | #else |
90 | movl $LOAD_PHYSICAL_ADDR, %ebx | 93 | movl $LOAD_PHYSICAL_ADDR, %ebx |
91 | #endif | 94 | #endif |
@@ -224,8 +227,11 @@ ENTRY(startup_64) | |||
224 | /* Start with the delta to where the kernel will run at. */ | 227 | /* Start with the delta to where the kernel will run at. */ |
225 | #ifdef CONFIG_RELOCATABLE | 228 | #ifdef CONFIG_RELOCATABLE |
226 | leaq startup_32(%rip) /* - $startup_32 */, %rbp | 229 | leaq startup_32(%rip) /* - $startup_32 */, %rbp |
227 | addq $(PMD_PAGE_SIZE - 1), %rbp | 230 | movl BP_kernel_alignment(%rsi), %eax |
228 | andq $PMD_PAGE_MASK, %rbp | 231 | decl %eax |
232 | addq %rax, %rbp | ||
233 | notq %rax | ||
234 | andq %rax, %rbp | ||
229 | #else | 235 | #else |
230 | movq $LOAD_PHYSICAL_ADDR, %rbp | 236 | movq $LOAD_PHYSICAL_ADDR, %rbp |
231 | #endif | 237 | #endif |
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 27285143adeb..a0b426978d55 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S | |||
@@ -116,7 +116,7 @@ _start: | |||
116 | # Part 2 of the header, from the old setup.S | 116 | # Part 2 of the header, from the old setup.S |
117 | 117 | ||
118 | .ascii "HdrS" # header signature | 118 | .ascii "HdrS" # header signature |
119 | .word 0x0209 # header version number (>= 0x0105) | 119 | .word 0x020a # header version number (>= 0x0105) |
120 | # or else old loadlin-1.5 will fail) | 120 | # or else old loadlin-1.5 will fail) |
121 | .globl realmode_swtch | 121 | .globl realmode_swtch |
122 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG | 122 | realmode_swtch: .word 0, 0 # default_switch, SETUPSEG |
@@ -201,7 +201,7 @@ relocatable_kernel: .byte 1 | |||
201 | #else | 201 | #else |
202 | relocatable_kernel: .byte 0 | 202 | relocatable_kernel: .byte 0 |
203 | #endif | 203 | #endif |
204 | pad2: .byte 0 | 204 | min_alignment: .byte MIN_KERNEL_ALIGN_LG2 # minimum alignment |
205 | pad3: .word 0 | 205 | pad3: .word 0 |
206 | 206 | ||
207 | cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line, | 207 | cmdline_size: .long COMMAND_LINE_SIZE-1 #length of the command line, |
@@ -220,6 +220,17 @@ setup_data: .quad 0 # 64-bit physical pointer to | |||
220 | # single linked list of | 220 | # single linked list of |
221 | # struct setup_data | 221 | # struct setup_data |
222 | 222 | ||
223 | pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr | ||
224 | |||
225 | #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_extract_offset) | ||
226 | #define VO_INIT_SIZE (VO__end - VO__text) | ||
227 | #if ZO_INIT_SIZE > VO_INIT_SIZE | ||
228 | #define INIT_SIZE ZO_INIT_SIZE | ||
229 | #else | ||
230 | #define INIT_SIZE VO_INIT_SIZE | ||
231 | #endif | ||
232 | init_size: .long INIT_SIZE # kernel initialization size | ||
233 | |||
223 | # End of setup header ##################################################### | 234 | # End of setup header ##################################################### |
224 | 235 | ||
225 | .section ".inittext", "ax" | 236 | .section ".inittext", "ax" |
diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h index 6ba23dd9fc92..418e632d4a80 100644 --- a/arch/x86/include/asm/boot.h +++ b/arch/x86/include/asm/boot.h | |||
@@ -8,11 +8,26 @@ | |||
8 | 8 | ||
9 | #ifdef __KERNEL__ | 9 | #ifdef __KERNEL__ |
10 | 10 | ||
11 | #include <asm/page_types.h> | ||
12 | |||
11 | /* Physical address where kernel should be loaded. */ | 13 | /* Physical address where kernel should be loaded. */ |
12 | #define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \ | 14 | #define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \ |
13 | + (CONFIG_PHYSICAL_ALIGN - 1)) \ | 15 | + (CONFIG_PHYSICAL_ALIGN - 1)) \ |
14 | & ~(CONFIG_PHYSICAL_ALIGN - 1)) | 16 | & ~(CONFIG_PHYSICAL_ALIGN - 1)) |
15 | 17 | ||
18 | /* Minimum kernel alignment, as a power of two */ | ||
19 | #ifdef CONFIG_x86_64 | ||
20 | #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT | ||
21 | #else | ||
22 | #define MIN_KERNEL_ALIGN_LG2 (PAGE_SHIFT+1) | ||
23 | #endif | ||
24 | #define MIN_KERNEL_ALIGN (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2) | ||
25 | |||
26 | #if (CONFIG_PHYSICAL_ALIGN & (CONFIG_PHYSICAL_ALIGN-1)) || \ | ||
27 | (CONFIG_PHYSICAL_ALIGN < (_AC(1, UL) << MIN_KERNEL_ALIGN_LG2)) | ||
28 | #error "Invalid value for CONFIG_PHYSICAL_ALIGN" | ||
29 | #endif | ||
30 | |||
16 | #ifdef CONFIG_KERNEL_BZIP2 | 31 | #ifdef CONFIG_KERNEL_BZIP2 |
17 | #define BOOT_HEAP_SIZE 0x400000 | 32 | #define BOOT_HEAP_SIZE 0x400000 |
18 | #else /* !CONFIG_KERNEL_BZIP2 */ | 33 | #else /* !CONFIG_KERNEL_BZIP2 */ |
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c index 5a6aa1c1162f..1a830cbd7015 100644 --- a/arch/x86/kernel/asm-offsets_32.c +++ b/arch/x86/kernel/asm-offsets_32.c | |||
@@ -146,4 +146,5 @@ void foo(void) | |||
146 | OFFSET(BP_loadflags, boot_params, hdr.loadflags); | 146 | OFFSET(BP_loadflags, boot_params, hdr.loadflags); |
147 | OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); | 147 | OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); |
148 | OFFSET(BP_version, boot_params, hdr.version); | 148 | OFFSET(BP_version, boot_params, hdr.version); |
149 | OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment); | ||
149 | } | 150 | } |
diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c index e72f062fb4b5..898ecc47e129 100644 --- a/arch/x86/kernel/asm-offsets_64.c +++ b/arch/x86/kernel/asm-offsets_64.c | |||
@@ -125,6 +125,7 @@ int main(void) | |||
125 | OFFSET(BP_loadflags, boot_params, hdr.loadflags); | 125 | OFFSET(BP_loadflags, boot_params, hdr.loadflags); |
126 | OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); | 126 | OFFSET(BP_hardware_subarch, boot_params, hdr.hardware_subarch); |
127 | OFFSET(BP_version, boot_params, hdr.version); | 127 | OFFSET(BP_version, boot_params, hdr.version); |
128 | OFFSET(BP_kernel_alignment, boot_params, hdr.kernel_alignment); | ||
128 | 129 | ||
129 | BLANK(); | 130 | BLANK(); |
130 | DEFINE(PAGE_SIZE_asm, PAGE_SIZE); | 131 | DEFINE(PAGE_SIZE_asm, PAGE_SIZE); |