Skip to content

Commit 0eee99d

Browse files
committed
Merge tag 'efi-fixes-for-v6.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: "These address all the outstanding EFI/x86 boot related regressions: - Revert to the old initrd memory allocation soft limit of INT_MAX, which was dropped inadvertently - Ensure that startup_32() is entered with a valid boot_params pointer when using the new EFI mixed mode protocol - Fix a compiler warning introduced by a fix from the previous pull" * tag 'efi-fixes-for-v6.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: x86/efistub: Reinstate soft limit for initrd loading efi/libstub: Cast away type warning in use of max() x86/efistub: Add missing boot_params for mixed mode compat entry
2 parents 033e808 + decd347 commit 0eee99d

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

arch/x86/boot/compressed/efi_mixed.S

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
*/
1616

1717
#include <linux/linkage.h>
18+
#include <asm/asm-offsets.h>
1819
#include <asm/msr.h>
1920
#include <asm/page_types.h>
2021
#include <asm/processor-flags.h>
2122
#include <asm/segment.h>
23+
#include <asm/setup.h>
2224

2325
.code64
2426
.text
@@ -149,6 +151,7 @@ SYM_FUNC_END(__efi64_thunk)
149151
SYM_FUNC_START(efi32_stub_entry)
150152
call 1f
151153
1: popl %ecx
154+
leal (efi32_boot_args - 1b)(%ecx), %ebx
152155

153156
/* Clear BSS */
154157
xorl %eax, %eax
@@ -163,6 +166,7 @@ SYM_FUNC_START(efi32_stub_entry)
163166
popl %ecx
164167
popl %edx
165168
popl %esi
169+
movl %esi, 8(%ebx)
166170
jmp efi32_entry
167171
SYM_FUNC_END(efi32_stub_entry)
168172
#endif
@@ -239,8 +243,6 @@ SYM_FUNC_END(efi_enter32)
239243
*
240244
* Arguments: %ecx image handle
241245
* %edx EFI system table pointer
242-
* %esi struct bootparams pointer (or NULL when not using
243-
* the EFI handover protocol)
244246
*
245247
* Since this is the point of no return for ordinary execution, no registers
246248
* are considered live except for the function parameters. [Note that the EFI
@@ -266,9 +268,18 @@ SYM_FUNC_START_LOCAL(efi32_entry)
266268
leal (efi32_boot_args - 1b)(%ebx), %ebx
267269
movl %ecx, 0(%ebx)
268270
movl %edx, 4(%ebx)
269-
movl %esi, 8(%ebx)
270271
movb $0x0, 12(%ebx) // efi_is64
271272

273+
/*
274+
* Allocate some memory for a temporary struct boot_params, which only
275+
* needs the minimal pieces that startup_32() relies on.
276+
*/
277+
subl $PARAM_SIZE, %esp
278+
movl %esp, %esi
279+
movl $PAGE_SIZE, BP_kernel_alignment(%esi)
280+
movl $_end - 1b, BP_init_size(%esi)
281+
subl $startup_32 - 1b, BP_init_size(%esi)
282+
272283
/* Disable paging */
273284
movl %cr0, %eax
274285
btrl $X86_CR0_PG_BIT, %eax
@@ -294,8 +305,7 @@ SYM_FUNC_START(efi32_pe_entry)
294305

295306
movl 8(%ebp), %ecx // image_handle
296307
movl 12(%ebp), %edx // sys_table
297-
xorl %esi, %esi
298-
jmp efi32_entry // pass %ecx, %edx, %esi
308+
jmp efi32_entry // pass %ecx, %edx
299309
// no other registers remain live
300310

301311
2: popl %edi // restore callee-save registers

drivers/firmware/efi/libstub/randomalloc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ efi_status_t efi_random_alloc(unsigned long size,
120120
continue;
121121
}
122122

123-
target = round_up(max(md->phys_addr, alloc_min), align) + target_slot * align;
123+
target = round_up(max_t(u64, md->phys_addr, alloc_min), align) + target_slot * align;
124124
pages = size / EFI_PAGE_SIZE;
125125

126126
status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,

drivers/firmware/efi/libstub/x86-stub.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
496496
hdr->vid_mode = 0xffff;
497497

498498
hdr->type_of_loader = 0x21;
499+
hdr->initrd_addr_max = INT_MAX;
499500

500501
/* Convert unicode cmdline to ascii */
501502
cmdline_ptr = efi_convert_cmdline(image, &options_size);

0 commit comments

Comments
 (0)