Skip to content

Commit d1343da

Browse files
author
Ingo Molnar
committed
Merge tag 'efi-changes-for-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi into efi/core
More EFI changes for v5.8: - Rename pr_efi/pr_efi_err to efi_info/efi_err, and use them consistently - Simplify and unify initrd loading - Parse the builtin command line on x86 (if provided) - Implement printk() support, including support for wide character strings - Some fixes for issues introduced by the first batch of v5.8 changes - Fix a missing prototypes warning - Simplify GDT handling in early mixed mode thunking code - Some other minor fixes and cleanups Conflicts: drivers/firmware/efi/libstub/efistub.h Signed-off-by: Ingo Molnar <[email protected]>
2 parents a5d8e55 + 9241dfe commit d1343da

File tree

24 files changed

+1211
-313
lines changed

24 files changed

+1211
-313
lines changed

Documentation/fb/efifb.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,9 @@ auto
6363
with the highest resolution, it will choose one with the highest color
6464
depth.
6565

66+
list
67+
The EFI stub will list out all the display modes that are available. A
68+
specific mode can then be chosen using one of the above options for the
69+
next boot.
70+
6671
Edgar Hucek <[email protected]>

arch/arm/boot/compressed/efi-header.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ optional_header:
6060
.long __pecoff_code_size @ SizeOfCode
6161
.long __pecoff_data_size @ SizeOfInitializedData
6262
.long 0 @ SizeOfUninitializedData
63-
.long efi_entry - start @ AddressOfEntryPoint
63+
.long efi_pe_entry - start @ AddressOfEntryPoint
6464
.long start_offset @ BaseOfCode
6565
.long __pecoff_data_start - start @ BaseOfData
6666

arch/arm64/kernel/efi-entry.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
SYM_CODE_START(efi_enter_kernel)
1616
/*
17-
* efi_entry() will have copied the kernel image if necessary and we
17+
* efi_pe_entry() will have copied the kernel image if necessary and we
1818
* end up here with device tree address in x1 and the kernel entry
1919
* point stored in x0. Save those values in registers which are
2020
* callee preserved.

arch/arm64/kernel/efi-header.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ optional_header:
2727
.long __initdata_begin - efi_header_end // SizeOfCode
2828
.long __pecoff_data_size // SizeOfInitializedData
2929
.long 0 // SizeOfUninitializedData
30-
.long __efistub_efi_entry - _head // AddressOfEntryPoint
30+
.long __efistub_efi_pe_entry - _head // AddressOfEntryPoint
3131
.long efi_header_end - _head // BaseOfCode
3232

3333
extra_header_fields:

arch/x86/boot/compressed/efi_thunk_64.S

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ SYM_FUNC_START(__efi64_thunk)
2828
push %rbx
2929

3030
leaq 1f(%rip), %rbp
31-
leaq efi_gdt64(%rip), %rbx
32-
movl %ebx, 2(%rbx) /* Fixup the gdt base address */
3331

3432
movl %ds, %eax
3533
push %rax
@@ -48,7 +46,8 @@ SYM_FUNC_START(__efi64_thunk)
4846
movl %r8d, 0xc(%rsp)
4947
movl %r9d, 0x10(%rsp)
5048

51-
sgdt 0x14(%rsp)
49+
leaq 0x14(%rsp), %rbx
50+
sgdt (%rbx)
5251

5352
/*
5453
* Switch to gdt with 32-bit segments. This is the firmware GDT
@@ -68,8 +67,7 @@ SYM_FUNC_START(__efi64_thunk)
6867
pushq %rax
6968
lretq
7069

71-
1: lgdt 0x14(%rsp)
72-
addq $32, %rsp
70+
1: addq $32, %rsp
7371
movq %rdi, %rax
7472

7573
pop %rbx
@@ -175,14 +173,3 @@ SYM_DATA_END(efi32_boot_cs)
175173
SYM_DATA_START(efi32_boot_ds)
176174
.word 0
177175
SYM_DATA_END(efi32_boot_ds)
178-
179-
SYM_DATA_START(efi_gdt64)
180-
.word efi_gdt64_end - efi_gdt64
181-
.long 0 /* Filled out by user */
182-
.word 0
183-
.quad 0x0000000000000000 /* NULL descriptor */
184-
.quad 0x00af9a000000ffff /* __KERNEL_CS */
185-
.quad 0x00cf92000000ffff /* __KERNEL_DS */
186-
.quad 0x0080890000000000 /* TS descriptor */
187-
.quad 0x0000000000000000 /* TS continued */
188-
SYM_DATA_END_LABEL(efi_gdt64, SYM_L_LOCAL, efi_gdt64_end)

arch/x86/include/asm/efi.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <asm/nospec-branch.h>
1010
#include <asm/mmu_context.h>
1111
#include <linux/build_bug.h>
12+
#include <linux/kernel.h>
1213

1314
extern unsigned long efi_fw_vendor, efi_config_table;
1415

@@ -225,13 +226,15 @@ efi_status_t efi_set_virtual_address_map(unsigned long memory_map_size,
225226

226227
/* arch specific definitions used by the stub code */
227228

228-
extern const bool efi_is64;
229+
#ifdef CONFIG_EFI_MIXED
230+
231+
#define ARCH_HAS_EFISTUB_WRAPPERS
229232

230233
static inline bool efi_is_64bit(void)
231234
{
232-
if (IS_ENABLED(CONFIG_EFI_MIXED))
233-
return efi_is64;
234-
return IS_ENABLED(CONFIG_X86_64);
235+
extern const bool efi_is64;
236+
237+
return efi_is64;
235238
}
236239

237240
static inline bool efi_is_native(void)
@@ -291,6 +294,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
291294
#define __efi64_argmap_allocate_pool(type, size, buffer) \
292295
((type), (size), efi64_zero_upper(buffer))
293296

297+
#define __efi64_argmap_create_event(type, tpl, f, c, event) \
298+
((type), (tpl), (f), (c), efi64_zero_upper(event))
299+
300+
#define __efi64_argmap_set_timer(event, type, time) \
301+
((event), (type), lower_32_bits(time), upper_32_bits(time))
302+
303+
#define __efi64_argmap_wait_for_event(num, event, index) \
304+
((num), (event), efi64_zero_upper(index))
305+
294306
#define __efi64_argmap_handle_protocol(handle, protocol, interface) \
295307
((handle), (protocol), efi64_zero_upper(interface))
296308

@@ -356,6 +368,15 @@ static inline u32 efi64_convert_status(efi_status_t status)
356368
runtime), \
357369
func, __VA_ARGS__))
358370

371+
#else /* CONFIG_EFI_MIXED */
372+
373+
static inline bool efi_is_64bit(void)
374+
{
375+
return IS_ENABLED(CONFIG_X86_64);
376+
}
377+
378+
#endif /* CONFIG_EFI_MIXED */
379+
359380
extern bool efi_reboot_required(void);
360381
extern bool efi_is_table_address(unsigned long phys_addr);
361382

arch/x86/xen/efi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static efi_system_table_t efi_systab_xen __initdata = {
2929
.fw_vendor = EFI_INVALID_TABLE_ADDR, /* Initialized later. */
3030
.fw_revision = 0, /* Initialized later. */
3131
.con_in_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
32-
.con_in = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
32+
.con_in = NULL, /* Not used under Xen. */
3333
.con_out_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
3434
.con_out = NULL, /* Not used under Xen. */
3535
.stderr_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */

drivers/firmware/efi/efivars.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,10 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
522522
ret = kobject_init_and_add(&new_var->kobj, &efivar_ktype,
523523
NULL, "%s", short_name);
524524
kfree(short_name);
525-
if (ret)
525+
if (ret) {
526+
kobject_put(&new_var->kobj);
526527
return ret;
528+
}
527529

528530
kobject_uevent(&new_var->kobj, KOBJ_ADD);
529531
if (efivar_entry_add(new_var, &efivar_sysfs_list)) {

drivers/firmware/efi/libstub/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
cflags-$(CONFIG_X86_32) := -march=i386
99
cflags-$(CONFIG_X86_64) := -mcmodel=small
10-
cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \
10+
cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \
1111
-fPIC -fno-strict-aliasing -mno-red-zone \
1212
-mno-mmx -mno-sse -fshort-wchar \
1313
-Wno-pointer-sign \
@@ -25,11 +25,12 @@ cflags-$(CONFIG_ARM) := $(subst $(CC_FLAGS_FTRACE),,$(KBUILD_CFLAGS)) \
2525

2626
cflags-$(CONFIG_EFI_GENERIC_STUB) += -I$(srctree)/scripts/dtc/libfdt
2727

28-
KBUILD_CFLAGS := $(cflags-y) -DDISABLE_BRANCH_PROFILING \
28+
KBUILD_CFLAGS := $(cflags-y) -Os -DDISABLE_BRANCH_PROFILING \
2929
-include $(srctree)/drivers/firmware/efi/libstub/hidden.h \
3030
-D__NO_FORTIFY \
3131
$(call cc-option,-ffreestanding) \
3232
$(call cc-option,-fno-stack-protector) \
33+
$(call cc-option,-fno-addrsig) \
3334
-D__DISABLE_EXPORTS
3435

3536
GCOV_PROFILE := n
@@ -43,7 +44,7 @@ KCOV_INSTRUMENT := n
4344
lib-y := efi-stub-helper.o gop.o secureboot.o tpm.o \
4445
file.o mem.o random.o randomalloc.o pci.o \
4546
skip_spaces.o lib-cmdline.o lib-ctype.o \
46-
alignedmem.o relocate.o
47+
alignedmem.o relocate.o vsprintf.o
4748

4849
# include the stub's generic dependencies from lib/ when building for ARM/arm64
4950
efi-deps-y := fdt_rw.c fdt_ro.c fdt_wip.c fdt.c fdt_empty_tree.c fdt_sw.c

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ efi_status_t check_platform_features(void)
1818
/* LPAE kernels need compatible hardware */
1919
block = cpuid_feature_extract(CPUID_EXT_MMFR0, 0);
2020
if (block < 5) {
21-
pr_efi_err("This LPAE kernel is not supported by your CPU\n");
21+
efi_err("This LPAE kernel is not supported by your CPU\n");
2222
return EFI_UNSUPPORTED;
2323
}
2424
return EFI_SUCCESS;
@@ -120,7 +120,7 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base,
120120
*/
121121
status = efi_get_memory_map(&map);
122122
if (status != EFI_SUCCESS) {
123-
pr_efi_err("reserve_kernel_base(): Unable to retrieve memory map.\n");
123+
efi_err("reserve_kernel_base(): Unable to retrieve memory map.\n");
124124
return status;
125125
}
126126

@@ -162,7 +162,7 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base,
162162
(end - start) / EFI_PAGE_SIZE,
163163
&start);
164164
if (status != EFI_SUCCESS) {
165-
pr_efi_err("reserve_kernel_base(): alloc failed.\n");
165+
efi_err("reserve_kernel_base(): alloc failed.\n");
166166
goto out;
167167
}
168168
break;
@@ -219,7 +219,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
219219

220220
status = reserve_kernel_base(kernel_base, reserve_addr, reserve_size);
221221
if (status != EFI_SUCCESS) {
222-
pr_efi_err("Unable to allocate memory for uncompressed kernel.\n");
222+
efi_err("Unable to allocate memory for uncompressed kernel.\n");
223223
return status;
224224
}
225225

@@ -232,7 +232,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
232232
status = efi_relocate_kernel(image_addr, *image_size, *image_size,
233233
kernel_base + MAX_UNCOMP_KERNEL_SIZE, 0, 0);
234234
if (status != EFI_SUCCESS) {
235-
pr_efi_err("Failed to relocate kernel.\n");
235+
efi_err("Failed to relocate kernel.\n");
236236
efi_free(*reserve_size, *reserve_addr);
237237
*reserve_size = 0;
238238
return status;
@@ -244,7 +244,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
244244
* address at which the zImage is loaded.
245245
*/
246246
if (*image_addr + *image_size > dram_base + ZIMAGE_OFFSET_LIMIT) {
247-
pr_efi_err("Failed to relocate kernel, no low memory available.\n");
247+
efi_err("Failed to relocate kernel, no low memory available.\n");
248248
efi_free(*reserve_size, *reserve_addr);
249249
*reserve_size = 0;
250250
efi_free(*image_size, *image_addr);

0 commit comments

Comments
 (0)