Skip to content

Commit ab8de2d

Browse files
committed
Merge tag 'efi-fixes-for-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI fixes from Ard Biesheuvel: - Fix logic that is supposed to prevent placement of the kernel image below LOAD_PHYSICAL_ADDR - Use the firmware stack in the EFI stub when running in mixed mode - Clear BSS only once when using mixed mode - Check efi.get_variable() function pointer for NULL before trying to call it * tag 'efi-fixes-for-v6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: efi: fix panic in kdump kernel x86/efistub: Don't clear BSS twice in mixed mode x86/efistub: Call mixed mode boot services on the firmware's stack efi/libstub: fix efi_random_alloc() to allocate memory at alloc_min or higher address
2 parents 5e74df2 + 62b71cd commit ab8de2d

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

arch/x86/boot/compressed/efi_mixed.S

+9
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ SYM_FUNC_START(startup_64_mixed_mode)
4949
lea efi32_boot_args(%rip), %rdx
5050
mov 0(%rdx), %edi
5151
mov 4(%rdx), %esi
52+
53+
/* Switch to the firmware's stack */
54+
movl efi32_boot_sp(%rip), %esp
55+
andl $~7, %esp
56+
5257
#ifdef CONFIG_EFI_HANDOVER_PROTOCOL
5358
mov 8(%rdx), %edx // saved bootparams pointer
5459
test %edx, %edx
@@ -254,6 +259,9 @@ SYM_FUNC_START_LOCAL(efi32_entry)
254259
/* Store firmware IDT descriptor */
255260
sidtl (efi32_boot_idt - 1b)(%ebx)
256261

262+
/* Store firmware stack pointer */
263+
movl %esp, (efi32_boot_sp - 1b)(%ebx)
264+
257265
/* Store boot arguments */
258266
leal (efi32_boot_args - 1b)(%ebx), %ebx
259267
movl %ecx, 0(%ebx)
@@ -318,5 +326,6 @@ SYM_DATA_END(efi32_boot_idt)
318326

319327
SYM_DATA_LOCAL(efi32_boot_cs, .word 0)
320328
SYM_DATA_LOCAL(efi32_boot_ds, .word 0)
329+
SYM_DATA_LOCAL(efi32_boot_sp, .long 0)
321330
SYM_DATA_LOCAL(efi32_boot_args, .long 0, 0, 0)
322331
SYM_DATA(efi_is64, .byte 1)

drivers/firmware/efi/efi.c

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ static bool generic_ops_supported(void)
203203

204204
name_size = sizeof(name);
205205

206+
if (!efi.get_next_variable)
207+
return false;
206208
status = efi.get_next_variable(&name_size, &name, &guid);
207209
if (status == EFI_UNSUPPORTED)
208210
return false;

drivers/firmware/efi/libstub/randomalloc.c

+1-1
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(md->phys_addr, align) + target_slot * align;
123+
target = round_up(max(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

+2-1
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,8 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
476476
efi_status_t status;
477477
char *cmdline_ptr;
478478

479-
memset(_bss, 0, _ebss - _bss);
479+
if (efi_is_native())
480+
memset(_bss, 0, _ebss - _bss);
480481

481482
efi_system_table = sys_table_arg;
482483

0 commit comments

Comments
 (0)