Commit 7c539764 authored by Alexander van Heukelum's avatar Alexander van Heukelum Committed by Ingo Molnar

x86: cleanup boot-heap usage

The kernel decompressor wrapper uses memory located beyond the
end of the image. This might lead to hard to debug problems,
but even if it can be proven to be safe, it is at the very
least unclean. I don't see any advantages either, unless you
count it not being zeroed out as an advantage. This patch
moves the boot-heap area to the bss segment.
Signed-off-by: default avatarAlexander van Heukelum <heukelum@fastmail.fm>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 4c8337ac
...@@ -130,7 +130,7 @@ relocated: ...@@ -130,7 +130,7 @@ relocated:
/* /*
* Setup the stack for the decompressor * Setup the stack for the decompressor
*/ */
leal stack_end(%ebx), %esp leal boot_stack_end(%ebx), %esp
/* /*
* Do the decompression, and jump to the new kernel.. * Do the decompression, and jump to the new kernel..
...@@ -142,8 +142,8 @@ relocated: ...@@ -142,8 +142,8 @@ relocated:
pushl %eax # input_len pushl %eax # input_len
leal input_data(%ebx), %eax leal input_data(%ebx), %eax
pushl %eax # input_data pushl %eax # input_data
leal _end(%ebx), %eax leal boot_heap(%ebx), %eax
pushl %eax # end of the image as third argument pushl %eax # heap area as third argument
pushl %esi # real mode pointer as second arg pushl %esi # real mode pointer as second arg
call decompress_kernel call decompress_kernel
addl $20, %esp addl $20, %esp
...@@ -181,7 +181,10 @@ relocated: ...@@ -181,7 +181,10 @@ relocated:
jmp *%ebp jmp *%ebp
.bss .bss
/* Stack and heap for uncompression */
.balign 4 .balign 4
stack: boot_heap:
.fill 4096, 1, 0 .fill BOOT_HEAP_SIZE, 1, 0
stack_end: boot_stack:
.fill BOOT_STACK_SIZE, 1, 0
boot_stack_end:
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <asm/segment.h> #include <asm/segment.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/boot.h>
#include <asm/msr.h> #include <asm/msr.h>
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
...@@ -62,7 +63,7 @@ startup_32: ...@@ -62,7 +63,7 @@ startup_32:
subl $1b, %ebp subl $1b, %ebp
/* setup a stack and make sure cpu supports long mode. */ /* setup a stack and make sure cpu supports long mode. */
movl $user_stack_end, %eax movl $boot_stack_end, %eax
addl %ebp, %eax addl %ebp, %eax
movl %eax, %esp movl %eax, %esp
...@@ -274,7 +275,7 @@ relocated: ...@@ -274,7 +275,7 @@ relocated:
stosb stosb
/* Setup the stack */ /* Setup the stack */
leaq user_stack_end(%rip), %rsp leaq boot_stack_end(%rip), %rsp
/* zero EFLAGS after setting rsp */ /* zero EFLAGS after setting rsp */
pushq $0 pushq $0
...@@ -285,7 +286,7 @@ relocated: ...@@ -285,7 +286,7 @@ relocated:
*/ */
pushq %rsi # Save the real mode argument pushq %rsi # Save the real mode argument
movq %rsi, %rdi # real mode address movq %rsi, %rdi # real mode address
leaq _heap(%rip), %rsi # _heap leaq boot_heap(%rip), %rsi # malloc area for uncompression
leaq input_data(%rip), %rdx # input_data leaq input_data(%rip), %rdx # input_data
movl input_len(%rip), %eax movl input_len(%rip), %eax
movq %rax, %rcx # input_len movq %rax, %rcx # input_len
...@@ -310,9 +311,12 @@ gdt: ...@@ -310,9 +311,12 @@ gdt:
.quad 0x0080890000000000 /* TS descriptor */ .quad 0x0080890000000000 /* TS descriptor */
.quad 0x0000000000000000 /* TS continued */ .quad 0x0000000000000000 /* TS continued */
gdt_end: gdt_end:
.bss
/* Stack for uncompression */ .bss
.balign 4 /* Stack and heap for uncompression */
user_stack: .balign 4
.fill 4096,4,0 boot_heap:
user_stack_end: .fill BOOT_HEAP_SIZE, 1, 0
boot_stack:
.fill BOOT_STACK_SIZE, 1, 0
boot_stack_end:
...@@ -217,12 +217,6 @@ static void putstr(const char *); ...@@ -217,12 +217,6 @@ static void putstr(const char *);
static memptr free_mem_ptr; static memptr free_mem_ptr;
static memptr free_mem_end_ptr; static memptr free_mem_end_ptr;
#ifdef CONFIG_X86_64
#define HEAP_SIZE 0x7000
#else
#define HEAP_SIZE 0x4000
#endif
static char *vidmem; static char *vidmem;
static int vidport; static int vidport;
static int lines, cols; static int lines, cols;
...@@ -449,7 +443,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, ...@@ -449,7 +443,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
window = output; /* Output buffer (Normally at 1M) */ window = output; /* Output buffer (Normally at 1M) */
free_mem_ptr = heap; /* Heap */ free_mem_ptr = heap; /* Heap */
free_mem_end_ptr = heap + HEAP_SIZE; free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
inbuf = input_data; /* Input buffer */ inbuf = input_data; /* Input buffer */
insize = input_len; insize = input_len;
inptr = 0; inptr = 0;
......
...@@ -17,4 +17,12 @@ ...@@ -17,4 +17,12 @@
+ (CONFIG_PHYSICAL_ALIGN - 1)) \ + (CONFIG_PHYSICAL_ALIGN - 1)) \
& ~(CONFIG_PHYSICAL_ALIGN - 1)) & ~(CONFIG_PHYSICAL_ALIGN - 1))
#ifdef CONFIG_X86_64
#define BOOT_HEAP_SIZE 0x7000
#define BOOT_STACK_SIZE 0x4000
#else
#define BOOT_HEAP_SIZE 0x4000
#define BOOT_STACK_SIZE 0x1000
#endif
#endif /* _ASM_BOOT_H */ #endif /* _ASM_BOOT_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment