Commit 8ef44be3 authored by Arvind Sankar's avatar Arvind Sankar Committed by Ingo Molnar

x86/boot/compressed/32: Save the output address instead of recalculating it

In preparation for being able to decompress into a buffer starting at a
different address than startup_32, save the calculated output address
instead of recalculating it later.

We now keep track of three addresses:

	%edx: startup_32 as we were loaded by bootloader
	%ebx: new location of compressed kernel
	%ebp: start of decompression buffer
Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20200303221205.4048668-2-nivedita@alum.mit.edu
Link: https://lore.kernel.org/r/20200308080859.21568-16-ardb@kernel.org
parent f3fa0efc
...@@ -75,11 +75,11 @@ SYM_FUNC_START(startup_32) ...@@ -75,11 +75,11 @@ SYM_FUNC_START(startup_32)
*/ */
leal (BP_scratch+4)(%esi), %esp leal (BP_scratch+4)(%esi), %esp
call 1f call 1f
1: popl %ebp 1: popl %edx
subl $1b, %ebp subl $1b, %edx
/* Load new GDT */ /* Load new GDT */
leal gdt(%ebp), %eax leal gdt(%edx), %eax
movl %eax, 2(%eax) movl %eax, 2(%eax)
lgdt (%eax) lgdt (%eax)
...@@ -92,13 +92,14 @@ SYM_FUNC_START(startup_32) ...@@ -92,13 +92,14 @@ SYM_FUNC_START(startup_32)
movl %eax, %ss movl %eax, %ss
/* /*
* %ebp contains the address we are loaded at by the boot loader and %ebx * %edx contains the address we are loaded at by the boot loader and %ebx
* contains the address where we should move the kernel image temporarily * contains the address where we should move the kernel image temporarily
* for safe in-place decompression. * for safe in-place decompression. %ebp contains the address that the kernel
* will be decompressed to.
*/ */
#ifdef CONFIG_RELOCATABLE #ifdef CONFIG_RELOCATABLE
movl %ebp, %ebx movl %edx, %ebx
movl BP_kernel_alignment(%esi), %eax movl BP_kernel_alignment(%esi), %eax
decl %eax decl %eax
addl %eax, %ebx addl %eax, %ebx
...@@ -110,10 +111,10 @@ SYM_FUNC_START(startup_32) ...@@ -110,10 +111,10 @@ SYM_FUNC_START(startup_32)
movl $LOAD_PHYSICAL_ADDR, %ebx movl $LOAD_PHYSICAL_ADDR, %ebx
1: 1:
movl %ebx, %ebp // Save the output address for later
/* Target address to relocate to for decompression */ /* Target address to relocate to for decompression */
movl BP_init_size(%esi), %eax addl BP_init_size(%esi), %ebx
subl $_end, %eax subl $_end, %ebx
addl %eax, %ebx
/* Set up the stack */ /* Set up the stack */
leal boot_stack_end(%ebx), %esp leal boot_stack_end(%ebx), %esp
...@@ -127,7 +128,7 @@ SYM_FUNC_START(startup_32) ...@@ -127,7 +128,7 @@ SYM_FUNC_START(startup_32)
* where decompression in place becomes safe. * where decompression in place becomes safe.
*/ */
pushl %esi pushl %esi
leal (_bss-4)(%ebp), %esi leal (_bss-4)(%edx), %esi
leal (_bss-4)(%ebx), %edi leal (_bss-4)(%ebx), %edi
movl $(_bss - startup_32), %ecx movl $(_bss - startup_32), %ecx
shrl $2, %ecx shrl $2, %ecx
...@@ -196,9 +197,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated) ...@@ -196,9 +197,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
/* push arguments for extract_kernel: */ /* push arguments for extract_kernel: */
pushl $z_output_len /* decompressed length, end of relocs */ pushl $z_output_len /* decompressed length, end of relocs */
leal _end(%ebx), %eax pushl %ebp /* output address */
subl BP_init_size(%esi), %eax
pushl %eax /* output address */
pushl $z_input_len /* input_len */ pushl $z_input_len /* input_len */
leal input_data(%ebx), %eax leal input_data(%ebx), %eax
......
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