Skip to content

Commit

Permalink
x86, boot: set up the decompression stack as early as possible
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
H. Peter Anvin committed May 9, 2009
1 parent 5b11f1c commit 0a13773
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
10 changes: 4 additions & 6 deletions arch/x86/boot/compressed/head_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -122,7 +125,7 @@ ENDPROC(startup_32)
relocated:

/*
* Clear BSS
* Clear BSS (stack is currently empty)
*/
xorl %eax, %eax
leal _bss(%ebx), %edi
Expand All @@ -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..
*/
Expand Down
16 changes: 8 additions & 8 deletions arch/x86/boot/compressed/head_64.S
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -273,7 +280,7 @@ ENTRY(startup_64)
relocated:

/*
* Clear BSS
* Clear BSS (stack is currently empty)
*/
xorq %rax, %rax
leaq _bss(%rbx), %rdi
Expand All @@ -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..
*/
Expand Down

0 comments on commit 0a13773

Please sign in to comment.