]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86, boot: set up the decompression stack as early as possible
authorH. Peter Anvin <hpa@zytor.com>
Fri, 8 May 2009 23:27:41 +0000 (16:27 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 9 May 2009 00:18:47 +0000 (17:18 -0700)
Set up the decompression stack as soon as we know where it needs to
go.  That way we have a full-service stack as soon as possible, rather
than relying on the BP_scratch field.

Note that the stack does need to be empty during bss zeroing (or
else the stack needs to be moved out of the bss segment, which is also
an option.)

[ Impact: cleanup, minor paranoia ]

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
arch/x86/boot/compressed/head_32.S
arch/x86/boot/compressed/head_64.S

index 59425e157df3b43907eea26127ada3786d41fd25..d7245cf80261773336d6c927392e481a37eb80c4 100644 (file)
@@ -88,6 +88,9 @@ ENTRY(startup_32)
        addl    $4095, %ebx
        andl    $~4095, %ebx
 
+       /* Set up the stack */
+       leal    boot_stack_end(%ebx), %esp
+
 /*
  * Copy the compressed kernel to the end of our buffer
  * where decompression in place becomes safe.
@@ -122,7 +125,7 @@ ENDPROC(startup_32)
 relocated:
 
 /*
- * Clear BSS
+ * Clear BSS (stack is currently empty)
  */
        xorl    %eax, %eax
        leal    _bss(%ebx), %edi
@@ -131,11 +134,6 @@ relocated:
        cld
        rep     stosb
 
-/*
- * Setup the stack for the decompressor
- */
-       leal    boot_stack_end(%ebx), %esp
-
 /*
  * Do the decompression, and jump to the new kernel..
  */
index 5bc9052615b6dba4f39fb6470c5d871b7d24db29..a0b18426069a17a4ff7dfda0acf8f08a7876ed0a 100644 (file)
@@ -249,6 +249,13 @@ ENTRY(startup_64)
        addq    $(32768 + 18 + 4095), %rbx
        andq    $~4095, %rbx
 
+       /* Set up the stack */
+       leaq    boot_stack_end(%rbx), %rsp
+
+       /* Zero EFLAGS */
+       pushq   $0
+       popfq
+
 /*
  * Copy the compressed kernel to the end of our buffer
  * where decompression in place becomes safe.
@@ -273,7 +280,7 @@ ENTRY(startup_64)
 relocated:
 
 /*
- * Clear BSS
+ * Clear BSS (stack is currently empty)
  */
        xorq    %rax, %rax
        leaq    _bss(%rbx), %rdi
@@ -282,13 +289,6 @@ relocated:
        cld
        rep     stosb
 
-       /* Setup the stack */
-       leaq    boot_stack_end(%rip), %rsp
-
-       /* zero EFLAGS after setting rsp */
-       pushq   $0
-       popfq
-
 /*
  * Do the decompression, and jump to the new kernel..
  */