diff options
author | Michael Brown | 2015-04-20 16:07:24 +0200 |
---|---|---|
committer | Michael Brown | 2015-04-20 22:28:15 +0200 |
commit | 2deedd22f1a9f889c0377094b02cf81b479ca778 (patch) | |
tree | 060ae93c76117661a6aa92ec2517559944fa84e1 | |
parent | [build] Remove reference to private upload server (diff) | |
download | memtest86-2deedd22f1a9f889c0377094b02cf81b479ca778.tar.gz memtest86-2deedd22f1a9f889c0377094b02cf81b479ca778.tar.xz memtest86-2deedd22f1a9f889c0377094b02cf81b479ca778.zip |
[build] Allow sufficient stack space for memsize_e820()
The functions memsize_e820() (and its inlined sanitize_e820_map()) use
around 9.5kb of stack space, which overflows the 8kB per-CPU stack and
so overwrites random variables in .bss, leading to undefined
behaviour.
Fix by reordering the per-CPU stacks so that the boot processor uses
the highest stack. This provides additional space during the
start-of-day call to memsize_e820(), using stack space which will
subsequently be reused for other CPUs' stacks.
Note that we cannot simply increase the per-CPU stack size to 16kB,
since that would cause the .bss section to exceed the limits of base
memory.
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r-- | main.c | 6 |
1 files changed, 2 insertions, 4 deletions
@@ -231,11 +231,9 @@ switch_to_main_stack(unsigned cpu_num) extern uintptr_t boot_stack_top; uintptr_t *src, *dst; int offs; - uint8_t * stackAddr, *stackTop; + uint8_t *stackTop; - stackAddr = (uint8_t *) &stacks[cpu_num][0]; - - stackTop = stackAddr + STACKSIZE; + stackTop = (uint8_t *) &stacks[MAX_CPUS - cpu_num][0]; src = (uintptr_t*)&boot_stack_top; dst = (uintptr_t*)stackTop; |