Skip to content

Commit 8ef44be

Browse files
nivedita76Ingo Molnar
authored andcommitted
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: Arvind Sankar <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lore.kernel.org/r/[email protected]
1 parent f3fa0ef commit 8ef44be

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

arch/x86/boot/compressed/head_32.S

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ SYM_FUNC_START(startup_32)
7575
*/
7676
leal (BP_scratch+4)(%esi), %esp
7777
call 1f
78-
1: popl %ebp
79-
subl $1b, %ebp
78+
1: popl %edx
79+
subl $1b, %edx
8080

8181
/* Load new GDT */
82-
leal gdt(%ebp), %eax
82+
leal gdt(%edx), %eax
8383
movl %eax, 2(%eax)
8484
lgdt (%eax)
8585

@@ -92,13 +92,14 @@ SYM_FUNC_START(startup_32)
9292
movl %eax, %ss
9393

9494
/*
95-
* %ebp contains the address we are loaded at by the boot loader and %ebx
95+
* %edx contains the address we are loaded at by the boot loader and %ebx
9696
* contains the address where we should move the kernel image temporarily
97-
* for safe in-place decompression.
97+
* for safe in-place decompression. %ebp contains the address that the kernel
98+
* will be decompressed to.
9899
*/
99100

100101
#ifdef CONFIG_RELOCATABLE
101-
movl %ebp, %ebx
102+
movl %edx, %ebx
102103
movl BP_kernel_alignment(%esi), %eax
103104
decl %eax
104105
addl %eax, %ebx
@@ -110,10 +111,10 @@ SYM_FUNC_START(startup_32)
110111
movl $LOAD_PHYSICAL_ADDR, %ebx
111112
1:
112113

114+
movl %ebx, %ebp // Save the output address for later
113115
/* Target address to relocate to for decompression */
114-
movl BP_init_size(%esi), %eax
115-
subl $_end, %eax
116-
addl %eax, %ebx
116+
addl BP_init_size(%esi), %ebx
117+
subl $_end, %ebx
117118

118119
/* Set up the stack */
119120
leal boot_stack_end(%ebx), %esp
@@ -127,7 +128,7 @@ SYM_FUNC_START(startup_32)
127128
* where decompression in place becomes safe.
128129
*/
129130
pushl %esi
130-
leal (_bss-4)(%ebp), %esi
131+
leal (_bss-4)(%edx), %esi
131132
leal (_bss-4)(%ebx), %edi
132133
movl $(_bss - startup_32), %ecx
133134
shrl $2, %ecx
@@ -196,9 +197,7 @@ SYM_FUNC_START_LOCAL_NOALIGN(.Lrelocated)
196197
/* push arguments for extract_kernel: */
197198
pushl $z_output_len /* decompressed length, end of relocs */
198199

199-
leal _end(%ebx), %eax
200-
subl BP_init_size(%esi), %eax
201-
pushl %eax /* output address */
200+
pushl %ebp /* output address */
202201

203202
pushl $z_input_len /* input_len */
204203
leal input_data(%ebx), %eax

0 commit comments

Comments
 (0)