* [PATCH v3 01/15] efi/zboot: arm64: Add missing barrier after cache maintenance
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 02/15] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv,
stable
From: Ard Biesheuvel <ardb@kernel.org>
Prevent the I-cache from fetching stale data by issuing a barrier after
the data cache maintenance completes but before performing the I-cache
maintenance.
Cc: <stable@vger.kernel.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/libstub/arm64.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
index e57cd3de0a00..d35c6dd76601 100644
--- a/drivers/firmware/efi/libstub/arm64.c
+++ b/drivers/firmware/efi/libstub/arm64.c
@@ -109,6 +109,7 @@ void efi_cache_sync_image(unsigned long image_base,
} while (size >= lsize);
}
+ dsb(ish);
asm("ic ialluis");
dsb(ish);
isb();
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 02/15] riscv: Use _stext not _text to denote the start of kernel code
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 01/15] efi/zboot: arm64: Add missing barrier after cache maintenance Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 03/15] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
On RISC-V, _text and _stext currently refer to the same location, i.e.,
the start of the .text output section, which follows the image header
(.head.text) emitted by HEAD_TEXT_SECTION. _start is the symbol that
refers to the actual start of the image.
On other architectures such as arm64, _text refers to the start of the
image, and _stext to the start of the kernel code, and generic code
(such as the EFI stub) may start relying on this distinction.
So switch the only user of _text in arch/riscv, i.e., the "Kernel code"
resource that is exposed via /proc/iomem (and from which the "Kernel
image" resource inherits its start address), over to _stext. This is a
no-op given that both symbols currently resolve to the same address, but
it permits _text to be moved to the start of the image, making it an
alias of _start.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/kernel/setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index d79f99b86033..e6112d424fde 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -91,7 +91,7 @@ static int __init add_kernel_resources(void)
* child nodes.
*/
- code_res.start = __pa_symbol(_text);
+ code_res.start = __pa_symbol(_stext);
code_res.end = __pa_symbol(_etext) - 1;
code_res.flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 03/15] riscv: Make _text point to the start of the kernel image
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 01/15] efi/zboot: arm64: Add missing barrier after cache maintenance Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 02/15] riscv: Use _stext not _text to denote the start of kernel code Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 04/15] efi/riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
On RISC-V, _text currently refers to the start of the .text output
section, which is placed after the image header (.head.text), and is
therefore equal to _stext. On other architectures such as arm64, _text
refers to the start of the image, and is used as such by generic code,
e.g., to describe the kernel mapping in /proc/kcore and in the ELF
headers of the vmcore, and by the EFI stub.
Now that arch/riscv no longer uses _text to refer to the start of the
kernel code, move it to the start of the image so that it is equal to
_start, and the distinction between _text and _stext is the same as on
other architectures.
This also means that the image header is no longer omitted from the
/proc/kcore and vmcore kernel text mappings. Other users of _text, such
as kallsyms and ftrace, only use it as a reference point to calculate
relative offsets, and are not affected by this change.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/kernel/vmlinux.lds.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 1f4f8496941a..9849a3e4d102 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -28,11 +28,11 @@ SECTIONS
/* Beginning of code and text segment */
. = LOAD_OFFSET;
_start = .;
+ _text = .;
HEAD_TEXT_SECTION
. = ALIGN(PAGE_SIZE);
.text : {
- _text = .;
_stext = .;
TEXT_TEXT
SCHED_TEXT
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 04/15] efi/riscv: Rename __init_text_end to __inittext_end like other archs
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (2 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 03/15] riscv: Make _text point to the start of the kernel image Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 05/15] efi/libstub: Avoid _end section marker in library code Ard Biesheuvel
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Align RISC-V with arm64, LoongArch and x86, and drop the underscore
between 'init' and 'text' in the section markers. This allows the value
to be captured by generic EFI stub code that can be shared between all
those architectures.
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/include/asm/sections.h | 2 +-
arch/riscv/kernel/image-vars.h | 2 +-
arch/riscv/kernel/vmlinux.lds.S | 4 ++--
drivers/firmware/efi/libstub/riscv-stub.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/riscv/include/asm/sections.h b/arch/riscv/include/asm/sections.h
index a393d5035c54..4a882a28f414 100644
--- a/arch/riscv/include/asm/sections.h
+++ b/arch/riscv/include/asm/sections.h
@@ -11,7 +11,7 @@
extern char _start[];
extern char _start_kernel[];
extern char __init_data_begin[], __init_data_end[];
-extern char __init_text_begin[], __init_text_end[];
+extern char __inittext_begin[], __inittext_end[];
extern char __alt_start[], __alt_end[];
extern char __exittext_begin[], __exittext_end[];
diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h
index 7b44b94f1283..bf703eba3fa5 100644
--- a/arch/riscv/kernel/image-vars.h
+++ b/arch/riscv/kernel/image-vars.h
@@ -27,7 +27,7 @@ __efistub__start = _start;
__efistub__start_kernel = _start_kernel;
__efistub__end = _end;
__efistub__edata = _edata;
-__efistub___init_text_end = __init_text_end;
+__efistub___inittext_end = __inittext_end;
#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
__efistub_sysfb_primary_display = sysfb_primary_display;
#endif
diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S
index 9849a3e4d102..ba939c7365b2 100644
--- a/arch/riscv/kernel/vmlinux.lds.S
+++ b/arch/riscv/kernel/vmlinux.lds.S
@@ -46,7 +46,7 @@ SECTIONS
. = ALIGN(SECTION_ALIGN);
__init_begin = .;
- __init_text_begin = .;
+ __inittext_begin = .;
.init.text : AT(ADDR(.init.text) - LOAD_OFFSET) ALIGN(SECTION_ALIGN) { \
_sinittext = .; \
INIT_TEXT \
@@ -72,7 +72,7 @@ SECTIONS
}
__exittext_end = .;
- __init_text_end = .;
+ __inittext_end = .;
. = ALIGN(SECTION_ALIGN);
#ifdef CONFIG_EFI
. = ALIGN(PECOFF_SECTION_ALIGNMENT);
diff --git a/drivers/firmware/efi/libstub/riscv-stub.c b/drivers/firmware/efi/libstub/riscv-stub.c
index 725b634c5179..5cbc50a814e1 100644
--- a/drivers/firmware/efi/libstub/riscv-stub.c
+++ b/drivers/firmware/efi/libstub/riscv-stub.c
@@ -34,7 +34,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
efi_status_t status;
kernel_size = _edata - _start;
- kernel_codesize = __init_text_end - _start;
+ kernel_codesize = __inittext_end - _start;
kernel_memsize = kernel_size + (_end - _edata);
*image_addr = (unsigned long)_start;
*reserve_size = kernel_memsize;
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 05/15] efi/libstub: Avoid _end section marker in library code
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (3 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 04/15] efi/riscv: Rename __init_text_end to __inittext_end like other archs Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 06/15] efi/libstub: Capture loaded image information in struct efi_image_info Ard Biesheuvel
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
The _end marker could point to the end of the kernel image being loaded,
or to the _end of the zboot decompressor image, and so it should only be
used in code that is obviously only intended for the former case.
So instead, use kernel_memsize and the image address to obtain the same
quantity.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/libstub/kaslr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/firmware/efi/libstub/kaslr.c b/drivers/firmware/efi/libstub/kaslr.c
index 8f8dc335b3b3..b34e4599f0f6 100644
--- a/drivers/firmware/efi/libstub/kaslr.c
+++ b/drivers/firmware/efi/libstub/kaslr.c
@@ -125,7 +125,7 @@ efi_status_t efi_kaslr_relocate_kernel(unsigned long *image_addr,
if (!check_image_region(*image_addr, kernel_memsize)) {
efi_err("FIRMWARE BUG: Image BSS overlaps adjacent EFI memory region\n");
} else if (IS_ALIGNED(*image_addr, min_kimg_align) &&
- (unsigned long)_end < EFI_ALLOC_LIMIT) {
+ (*image_addr + kernel_memsize) < EFI_ALLOC_LIMIT) {
/*
* Just execute from wherever we were loaded by the
* UEFI PE/COFF loader if the placement is suitable.
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 06/15] efi/libstub: Capture loaded image information in struct efi_image_info
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (4 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 05/15] efi/libstub: Avoid _end section marker in library code Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 07/15] efi/libstub: Pass kernel entrypoint down to efi_enter_kernel() Ard Biesheuvel
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Define a struct efi_image_info that carries properties of the loaded
kernel image, and pass a pointer to it to efi_stub_common() so that EFI
stub code can access these properties in a consistent manner for both
the uncompressed kernel and the EFI zboot image.
Note that zboot can only access this information after decompressing the
image, whereas code that is part of the EFI stub that gets integrated
into Linux could just grab the efi_image_info pointer as needed.
However, in order to avoid future surprises, pass the efi_image_info
pointer down via the calls into the shared stub code, replacing the
image base address field, whose value can be derived from image_info as
well as long as it is taken from the copy of the image that will
ultimately be used to boot the kernel.
ARM implements neither, but -like x86- incorporates the EFI stub into
its own decompressor and cannot incorporate struct efi_image_info as
defined here, as it refers to global symbols in vmlinux. It does not
really have a need for this either, so just define an empty struct for
it.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
| 2 +
arch/loongarch/kernel/head.S | 1 +
arch/riscv/kernel/head.S | 1 +
drivers/firmware/efi/libstub/Makefile | 1 +
drivers/firmware/efi/libstub/Makefile.zboot | 11 +++-
drivers/firmware/efi/libstub/arm32-stub.c | 5 +-
drivers/firmware/efi/libstub/arm64-stub.c | 17 ++++--
drivers/firmware/efi/libstub/efi-stub-entry.c | 22 +++-----
drivers/firmware/efi/libstub/efi-stub.c | 10 ++--
drivers/firmware/efi/libstub/efistub.h | 57 ++++++++++++++++++--
drivers/firmware/efi/libstub/image_info.S | 19 +++++++
drivers/firmware/efi/libstub/loongarch-stub.c | 4 +-
drivers/firmware/efi/libstub/riscv-stub.c | 4 +-
drivers/firmware/efi/libstub/zboot.c | 22 ++++++--
drivers/firmware/efi/libstub/zboot.lds | 2 +
15 files changed, 145 insertions(+), 33 deletions(-)
--git a/arch/arm64/kernel/efi-header.S b/arch/arm64/kernel/efi-header.S
index 329e8df9215f..54ca61d03403 100644
--- a/arch/arm64/kernel/efi-header.S
+++ b/arch/arm64/kernel/efi-header.S
@@ -7,6 +7,8 @@
#include <linux/pe.h>
#include <linux/sizes.h>
+SYM_FUNC_ALIAS(efi_primary_entry, primary_entry)
+
.macro efi_signature_nop
#ifdef CONFIG_EFI
.L_head:
diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.S
index 601ddd78b233..69c31b0b65c5 100644
--- a/arch/loongarch/kernel/head.S
+++ b/arch/loongarch/kernel/head.S
@@ -35,6 +35,7 @@ pe_header:
SYM_DATA(kernel_asize, .long _kernel_asize);
SYM_DATA(kernel_fsize, .long _kernel_fsize);
+SYM_FUNC_ALIAS(efi_primary_entry, kernel_entry)
#endif
__REF
diff --git a/arch/riscv/kernel/head.S b/arch/riscv/kernel/head.S
index 1631fd6bc786..6c81f32be70b 100644
--- a/arch/riscv/kernel/head.S
+++ b/arch/riscv/kernel/head.S
@@ -28,6 +28,7 @@ SYM_CODE_START(_start)
* that expects this header format!!
*/
#ifdef CONFIG_EFI
+SYM_FUNC_ALIAS(efi_primary_entry, _start_kernel)
/*
* This instruction decodes to "MZ" ASCII required by UEFI.
*/
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index bbab12b8eb4b..9dc6a707fd79 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -107,6 +107,7 @@ lib-$(CONFIG_UNACCEPTED_MEMORY) += unaccepted_memory.o bitmap.o find.o
targets := $(lib-y)
lib-y := $(patsubst %.o,%.stub.o,$(lib-y))
+lib-$(CONFIG_EFI_GENERIC_STUB) += image_info.o
# Even when -mbranch-protection=none is set, Clang will generate a
# .note.gnu.property for code-less object files (like lib/ctype.c),
diff --git a/drivers/firmware/efi/libstub/Makefile.zboot b/drivers/firmware/efi/libstub/Makefile.zboot
index 52baacf3e9d9..e2769bbec963 100644
--- a/drivers/firmware/efi/libstub/Makefile.zboot
+++ b/drivers/firmware/efi/libstub/Makefile.zboot
@@ -26,9 +26,18 @@ zboot-size-len-$(CONFIG_KERNEL_ZSTD) := 4
$(obj)/vmlinuz: $(obj)/vmlinux.bin FORCE
+$(call if_changed,$(zboot-method-y))
+# subtract the two symbol values to obtain the offset of struct efi_image_info
+get_image_info_offset = $(shell $(NM) -n $(objtree)/vmlinux |\
+ grep -E ' _text$$| __efistub_efistub_image_info$$' |\
+ awk 'NR == 1 { a = toupper($$1) } \
+ NR == 2 { print "obase=16; ibase=16; " toupper($$1) "-" a }' |\
+ bc)
+
# avoid eager evaluation to prevent references to non-existent build artifacts
OBJCOPYFLAGS_vmlinuz.o = -I binary -O $(EFI_ZBOOT_BFD_TARGET) $(EFI_ZBOOT_OBJCOPY_FLAGS) \
- --rename-section .data=.gzdata,load,alloc,readonly,contents
+ --rename-section .data=.gzdata,load,alloc,readonly,contents \
+ --add-symbol efistub_image_info_offset=0x$(get_image_info_offset)
+
$(obj)/vmlinuz.o: $(obj)/vmlinuz FORCE
$(call if_changed,objcopy)
diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
index 1073dd947516..f7151a4915ba 100644
--- a/drivers/firmware/efi/libstub/arm32-stub.c
+++ b/drivers/firmware/efi/libstub/arm32-stub.c
@@ -76,12 +76,15 @@ void efi_handle_post_ebs_state(void)
&efi_entry_state->sctlr_after_ebs);
}
+struct efi_image_info efistub_image_info = {};
+
efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_size,
unsigned long *reserve_addr,
unsigned long *reserve_size,
efi_loaded_image_t *image,
- efi_handle_t image_handle)
+ efi_handle_t image_handle,
+ const struct efi_image_info **image_info)
{
const int slack = TEXT_OFFSET - 5 * PAGE_SIZE;
int alloc_size = MAX_UNCOMP_KERNEL_SIZE + EFI_PHYS_ALIGN;
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
index 2c3869356147..c93ab8b6e9d3 100644
--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -19,9 +19,11 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *reserve_addr,
unsigned long *reserve_size,
efi_loaded_image_t *image,
- efi_handle_t image_handle)
+ efi_handle_t image_handle,
+ const struct efi_image_info **image_info)
{
unsigned long kernel_size, kernel_codesize, kernel_memsize;
+ efi_status_t status;
if (image->image_base != _text) {
efi_err("FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value\n");
@@ -38,9 +40,16 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
*reserve_size = kernel_memsize;
*image_addr = (unsigned long)_text;
- return efi_kaslr_relocate_kernel(image_addr, reserve_addr, reserve_size,
- kernel_size, kernel_codesize, kernel_memsize,
- efi_kaslr_get_phys_seed(image_handle));
+ status = efi_kaslr_relocate_kernel(image_addr, reserve_addr,
+ reserve_size, kernel_size,
+ kernel_codesize, kernel_memsize,
+ efi_kaslr_get_phys_seed(image_handle));
+
+ if (status != EFI_SUCCESS)
+ return status;
+
+ *(unsigned long *)image_info += *image_addr - (unsigned long)_text;
+ return EFI_SUCCESS;
}
asmlinkage void primary_entry(void);
diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c
index efa3ab8ad1c6..36ea6aa2cfcc 100644
--- a/drivers/firmware/efi/libstub/efi-stub-entry.c
+++ b/drivers/firmware/efi/libstub/efi-stub-entry.c
@@ -7,22 +7,17 @@
#include "efistub.h"
-static unsigned long kernel_image_offset;
+extern const struct efi_image_info efistub_image_info;
-static void *kernel_image_addr(void *addr)
-{
- return addr + kernel_image_offset;
-}
-
-struct sysfb_display_info *alloc_primary_display(void)
+struct sysfb_display_info *
+alloc_primary_display(const struct efi_image_info *image_info)
{
if (IS_ENABLED(CONFIG_ARM))
return __alloc_primary_display();
- if (IS_ENABLED(CONFIG_X86) ||
- IS_ENABLED(CONFIG_EFI_EARLYCON) ||
+ if (IS_ENABLED(CONFIG_EFI_EARLYCON) ||
IS_ENABLED(CONFIG_SYSFB))
- return kernel_image_addr(&sysfb_primary_display);
+ return efistub_sysfb_display_info(image_info);
return NULL;
}
@@ -36,6 +31,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
efi_system_table_t *systab)
{
static efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID;
+ const struct efi_image_info *image_info = &efistub_image_info;
efi_loaded_image_t *image;
efi_status_t status;
unsigned long image_addr;
@@ -72,15 +68,13 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
status = handle_kernel_image(&image_addr, &image_size,
&reserve_addr,
&reserve_size,
- image, handle);
+ image, handle, &image_info);
if (status != EFI_SUCCESS) {
efi_err("Failed to relocate kernel\n");
return status;
}
- kernel_image_offset = image_addr - (unsigned long)image->image_base;
-
- status = efi_stub_common(handle, image, image_addr, cmdline_ptr);
+ status = efi_stub_common(handle, image, image_info, cmdline_ptr);
efi_free(image_size, image_addr);
efi_free(reserve_size, reserve_addr);
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 6db10590f89b..bf9a9f53a95c 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -51,14 +51,15 @@ static bool flat_va_mapping = (EFI_RT_VIRTUAL_OFFSET != 0);
void __weak free_primary_display(struct sysfb_display_info *dpy)
{ }
-static struct sysfb_display_info *setup_primary_display(void)
+static struct sysfb_display_info *
+setup_primary_display(const struct efi_image_info *image_info)
{
struct sysfb_display_info *dpy;
struct screen_info *screen = NULL;
struct edid_info *edid = NULL;
efi_status_t status;
- dpy = alloc_primary_display();
+ dpy = alloc_primary_display(image_info);
if (!dpy)
return NULL;
screen = &dpy->screen;
@@ -160,9 +161,10 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
efi_status_t efi_stub_common(efi_handle_t handle,
efi_loaded_image_t *image,
- unsigned long image_addr,
+ const struct efi_image_info *image_info,
char *cmdline_ptr)
{
+ unsigned long image_addr = efistub_kernel_base(image_info);
struct sysfb_display_info *dpy;
efi_status_t status;
@@ -170,7 +172,7 @@ efi_status_t efi_stub_common(efi_handle_t handle,
if (status != EFI_SUCCESS)
return status;
- dpy = setup_primary_display();
+ dpy = setup_primary_display(image_info);
efi_retrieve_eventlog();
efi_bli_set_variables(image);
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index f5eec8c12894..bb8e360fee7b 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1135,6 +1135,16 @@ efi_status_t efi_load_initrd(efi_loaded_image_t *image,
unsigned long soft_limit,
unsigned long hard_limit,
const struct linux_efi_initrd **out);
+
+struct efi_image_info {
+ s32 _text_offset;
+ s32 __inittext_end_offset;
+ s32 _edata_offset;
+ s32 _end_offset;
+ s32 entry_offset;
+ s32 sysfb_primary_display_offset;
+};
+
/*
* This function handles the architcture specific differences between arm and
* arm64 regarding where the kernel image must be loaded and any memory that
@@ -1146,12 +1156,51 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *reserve_addr,
unsigned long *reserve_size,
efi_loaded_image_t *image,
- efi_handle_t image_handle);
+ efi_handle_t image_handle,
+ const struct efi_image_info **image_info);
+
+static inline
+unsigned long efistub_kernel_base(const struct efi_image_info *image_info)
+{
+ return (unsigned long)offset_to_ptr(&image_info->_text_offset);
+}
+
+static inline
+unsigned long efistub_kernel_size(const struct efi_image_info *image_info)
+{
+ return image_info->_edata_offset - image_info->_text_offset;
+}
+
+static inline
+unsigned long efistub_kernel_memsize(const struct efi_image_info *image_info)
+{
+ return image_info->_end_offset - image_info->_text_offset;
+}
+
+static inline
+unsigned long efistub_kernel_codesize(const struct efi_image_info *image_info)
+{
+ return image_info->__inittext_end_offset - image_info->_text_offset;
+}
+
+static inline
+void *efistub_kernel_entry(const struct efi_image_info *image_info)
+{
+ return offset_to_ptr(&image_info->entry_offset);
+}
+
+static inline
+void *efistub_sysfb_display_info(const struct efi_image_info *image_info)
+{
+ auto offset = &image_info->sysfb_primary_display_offset;
+
+ return *offset ? offset_to_ptr(offset) : NULL;
+}
/* shared entrypoint between the normal stub and the zboot stub */
efi_status_t efi_stub_common(efi_handle_t handle,
efi_loaded_image_t *image,
- unsigned long image_addr,
+ const struct efi_image_info *image_info,
char *cmdline_ptr);
efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr);
@@ -1173,7 +1222,9 @@ efi_enable_reset_attack_mitigation(void) { }
void efi_retrieve_eventlog(void);
-struct sysfb_display_info *alloc_primary_display(void);
+struct sysfb_display_info *
+alloc_primary_display(const struct efi_image_info *image_info);
+
struct sysfb_display_info *__alloc_primary_display(void);
void free_primary_display(struct sysfb_display_info *dpy);
diff --git a/drivers/firmware/efi/libstub/image_info.S b/drivers/firmware/efi/libstub/image_info.S
new file mode 100644
index 000000000000..587a3eaff1c3
--- /dev/null
+++ b/drivers/firmware/efi/libstub/image_info.S
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <linux/init.h>
+
+ __INITRODATA
+
+ .p2align 3
+ .globl __efistub_efistub_image_info
+__efistub_efistub_image_info:
+0: .long _text - .
+ .long __inittext_end - 0b
+ .long _edata - 0b
+ .long _end - 0b
+ .long efi_primary_entry - .
+#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
+ .long sysfb_primary_display - .
+#else
+ .long 0
+#endif
diff --git a/drivers/firmware/efi/libstub/loongarch-stub.c b/drivers/firmware/efi/libstub/loongarch-stub.c
index c87ac7025107..d57e3d3557a5 100644
--- a/drivers/firmware/efi/libstub/loongarch-stub.c
+++ b/drivers/firmware/efi/libstub/loongarch-stub.c
@@ -99,7 +99,8 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *reserve_addr,
unsigned long *reserve_size,
efi_loaded_image_t *image,
- efi_handle_t image_handle)
+ efi_handle_t image_handle,
+ const struct efi_image_info **image_info)
{
efi_status_t status;
unsigned long kernel_addr = 0;
@@ -112,6 +113,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
*image_addr = kernel_addr;
*image_size = kernel_asize;
+ *(unsigned long *)image_info += *image_addr - (unsigned long)image->image_base;
return status;
}
diff --git a/drivers/firmware/efi/libstub/riscv-stub.c b/drivers/firmware/efi/libstub/riscv-stub.c
index 5cbc50a814e1..0ddbe7cc8628 100644
--- a/drivers/firmware/efi/libstub/riscv-stub.c
+++ b/drivers/firmware/efi/libstub/riscv-stub.c
@@ -28,7 +28,8 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *reserve_addr,
unsigned long *reserve_size,
efi_loaded_image_t *image,
- efi_handle_t image_handle)
+ efi_handle_t image_handle,
+ const struct efi_image_info **image_info)
{
unsigned long kernel_size, kernel_codesize, kernel_memsize;
efi_status_t status;
@@ -46,6 +47,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
if (status != EFI_SUCCESS)
efi_err("Failed to relocate kernel\n");
+ *(unsigned long *)image_info += *image_addr - (unsigned long)_start;
return status;
}
diff --git a/drivers/firmware/efi/libstub/zboot.c b/drivers/firmware/efi/libstub/zboot.c
index 4a5ffe164873..4cff756902ad 100644
--- a/drivers/firmware/efi/libstub/zboot.c
+++ b/drivers/firmware/efi/libstub/zboot.c
@@ -26,9 +26,18 @@ void __weak efi_cache_sync_image(unsigned long image_base,
// executable code loaded into memory to be safe for execution.
}
-struct sysfb_display_info *alloc_primary_display(void)
+struct sysfb_display_info *
+alloc_primary_display(const struct efi_image_info *image_info)
{
- return __alloc_primary_display();
+ return efistub_sysfb_display_info(image_info);
+}
+
+static
+const struct efi_image_info *zboot_get_image_info(unsigned long image_base)
+{
+ extern const u32 efistub_image_info_offset;
+
+ return (void *)image_base + efistub_image_info_offset;
}
asmlinkage efi_status_t __efiapi
@@ -93,9 +102,14 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab)
}
// Decompress the payload into the newly allocated buffer
- status = efi_zboot_decompress((void *)image_base, alloc_size) ?:
- efi_stub_common(handle, image, image_base, cmdline_ptr);
+ status = efi_zboot_decompress((void *)image_base, alloc_size);
+ if (status != EFI_SUCCESS)
+ goto error;
+
+ auto image_info = zboot_get_image_info(image_base);
+ status = efi_stub_common(handle, image, image_info, cmdline_ptr);
+error:
efi_free(alloc_size, image_base);
return status;
}
diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
index 367907eb7d86..e1365907f805 100644
--- a/drivers/firmware/efi/libstub/zboot.lds
+++ b/drivers/firmware/efi/libstub/zboot.lds
@@ -24,6 +24,8 @@ SECTIONS
. = ALIGN(4);
__efistub_code_size = .;
LONG(zboot_code_size);
+ __efistub_efistub_image_info_offset = .;
+ LONG(efistub_image_info_offset);
_etext = ALIGN(4096);
. = _etext;
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 07/15] efi/libstub: Pass kernel entrypoint down to efi_enter_kernel()
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (5 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 06/15] efi/libstub: Capture loaded image information in struct efi_image_info Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 08/15] efi/libstub: arm64: Use struct efi_image_info to access image properties Ard Biesheuvel
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Update the EFI stub code shared by arm64 and RISC-V so that the kernel
entry point is taken from struct efi_image_info rather than from opaque
arithmetic performed on linker symbols.
Notably, this results in EFI zboot to enter via the actual kernel
entrypoint rather than byte 0x0 of the loaded image on these
architectures. Beyond that, it is mostly a cleanup that will allow
special linker exports for global symbols to be dropped in subsequent
patches.
ARM is a special case here, as it combines the EFI stub with its legacy
decompressor, and so the generic image_info carrying direct references
to vmlinux symbols cannot be used there. Instead, it provides an empty
struct efi_image_info, which is passed directly to its implementation of
efi_enter_kernel(). So on ARM, populate this efi_image_info with the
base address that the callee expects.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm/boot/compressed/head.S | 2 +-
drivers/firmware/efi/libstub/arm32-stub.c | 2 +-
drivers/firmware/efi/libstub/arm64.c | 16 ++--------------
drivers/firmware/efi/libstub/efi-stub.c | 2 +-
drivers/firmware/efi/libstub/efistub.h | 9 +++++----
drivers/firmware/efi/libstub/fdt.c | 5 +++--
drivers/firmware/efi/libstub/loongarch.c | 3 ++-
drivers/firmware/efi/libstub/riscv.c | 16 +++-------------
8 files changed, 18 insertions(+), 37 deletions(-)
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 9f406e9c0ea6..a7f58dfe41bc 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -1450,7 +1450,7 @@ __enter_kernel_from_hyp:
b __enter_kernel
ENTRY(efi_enter_kernel)
- mov r4, r0 @ preserve image base
+ ldr r4, [r0] @ preserve image base
mov r8, r1 @ preserve DT pointer
adr_l r0, call_cache_fn
diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
index f7151a4915ba..b73a0b4fcd10 100644
--- a/drivers/firmware/efi/libstub/arm32-stub.c
+++ b/drivers/firmware/efi/libstub/arm32-stub.c
@@ -127,7 +127,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
efi_bs_call(free_pages, *reserve_addr + MAX_UNCOMP_KERNEL_SIZE,
(alloc_size - MAX_UNCOMP_KERNEL_SIZE) / EFI_PAGE_SIZE);
- *image_addr = kernel_base + TEXT_OFFSET;
+ *image_addr = efistub_image_info._text_offset = kernel_base + TEXT_OFFSET;
*image_size = 0;
efi_debug("image addr == 0x%lx, reserve_addr == 0x%lx\n",
diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
index d35c6dd76601..e892302f4189 100644
--- a/drivers/firmware/efi/libstub/arm64.c
+++ b/drivers/firmware/efi/libstub/arm64.c
@@ -117,24 +117,12 @@ void efi_cache_sync_image(unsigned long image_base,
efi_remap_image(image_base, alloc_size, code_size);
}
-unsigned long __weak primary_entry_offset(void)
-{
- /*
- * By default, we can invoke the kernel via the branch instruction in
- * the image header, so offset #0. This will be overridden by the EFI
- * stub build that is linked into the core kernel, as in that case, the
- * image header may not have been loaded into memory, or may be mapped
- * with non-executable permissions.
- */
- return 0;
-}
-
-void __noreturn efi_enter_kernel(unsigned long entrypoint,
+void __noreturn efi_enter_kernel(const struct efi_image_info *image_info,
unsigned long fdt_addr,
unsigned long fdt_size)
{
void (* __noreturn enter_kernel)(u64, u64, u64, u64);
- enter_kernel = (void *)entrypoint + primary_entry_offset();
+ enter_kernel = efistub_kernel_entry(image_info);
enter_kernel(fdt_addr, 0, 0, 0);
}
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index bf9a9f53a95c..55bf7ed50c81 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -191,7 +191,7 @@ efi_status_t efi_stub_common(efi_handle_t handle,
install_memreserve_table();
- status = efi_boot_kernel(handle, image, image_addr, cmdline_ptr);
+ status = efi_boot_kernel(handle, image, image_info, cmdline_ptr);
free_primary_display(dpy);
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index bb8e360fee7b..b985ababbe66 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1054,9 +1054,6 @@ typedef efi_status_t (*efi_exit_boot_map_processing)(
efi_status_t efi_exit_boot_services(void *handle, void *priv,
efi_exit_boot_map_processing priv_func);
-efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
- unsigned long kernel_addr, char *cmdline_ptr);
-
void *get_fdt(unsigned long *fdt_size);
efi_status_t efi_alloc_virtmap(efi_memory_desc_t **virtmap,
@@ -1189,6 +1186,10 @@ void *efistub_kernel_entry(const struct efi_image_info *image_info)
return offset_to_ptr(&image_info->entry_offset);
}
+efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
+ const struct efi_image_info *image_info,
+ char *cmdline_ptr);
+
static inline
void *efistub_sysfb_display_info(const struct efi_image_info *image_info)
{
@@ -1205,7 +1206,7 @@ efi_status_t efi_stub_common(efi_handle_t handle,
efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr);
-asmlinkage void __noreturn efi_enter_kernel(unsigned long entrypoint,
+asmlinkage void __noreturn efi_enter_kernel(const struct efi_image_info *image_info,
unsigned long fdt_addr,
unsigned long fdt_size);
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index f01450b49975..09e9e5bc831e 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -344,7 +344,8 @@ efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
}
efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
- unsigned long kernel_addr, char *cmdline_ptr)
+ const struct efi_image_info *image_info,
+ char *cmdline_ptr)
{
unsigned long fdt_addr;
efi_status_t status;
@@ -359,7 +360,7 @@ efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
if (IS_ENABLED(CONFIG_ARM))
efi_handle_post_ebs_state();
- efi_enter_kernel(kernel_addr, fdt_addr, fdt_totalsize((void *)fdt_addr));
+ efi_enter_kernel(image_info, fdt_addr, fdt_totalsize((void *)fdt_addr));
/* not reached */
}
diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/efi/libstub/loongarch.c
index 2b0c87dc9908..7f21e79384d3 100644
--- a/drivers/firmware/efi/libstub/loongarch.c
+++ b/drivers/firmware/efi/libstub/loongarch.c
@@ -66,8 +66,9 @@ unsigned long __weak kernel_entry_address(unsigned long kernel_addr,
}
efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
- unsigned long kernel_addr, char *cmdline_ptr)
+ const struct efi_image_info *image_info, char *cmdline_ptr)
{
+ unsigned long kernel_addr = efistub_kernel_base(image_info);
kernel_entry_t real_kernel_entry;
struct exit_boot_struct priv;
unsigned long desc_size;
diff --git a/drivers/firmware/efi/libstub/riscv.c b/drivers/firmware/efi/libstub/riscv.c
index 49db47c05bfe..7be2774dea90 100644
--- a/drivers/firmware/efi/libstub/riscv.c
+++ b/drivers/firmware/efi/libstub/riscv.c
@@ -72,20 +72,10 @@ efi_status_t check_platform_features(void)
return EFI_SUCCESS;
}
-unsigned long __weak stext_offset(void)
+void __noreturn efi_enter_kernel(const struct efi_image_info *image_info,
+ unsigned long fdt, unsigned long fdt_size)
{
- /*
- * This fallback definition is used by the EFI zboot stub, which loads
- * the entire image so it can branch via the image header at offset #0.
- */
- return 0;
-}
-
-void __noreturn efi_enter_kernel(unsigned long entrypoint, unsigned long fdt,
- unsigned long fdt_size)
-{
- unsigned long kernel_entry = entrypoint + stext_offset();
- jump_kernel_func jump_kernel = (jump_kernel_func)kernel_entry;
+ jump_kernel_func jump_kernel = efistub_kernel_entry(image_info);
/*
* Jump to real kernel here with following constraints.
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 08/15] efi/libstub: arm64: Use struct efi_image_info to access image properties
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (6 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 07/15] efi/libstub: Pass kernel entrypoint down to efi_enter_kernel() Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 09/15] efi/libstub: loongarch: " Ard Biesheuvel
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Instead of exposing individual symbols to the EFI stub explicitly via
the linker script, use the generic struct efi_image_info, which accesses
the original symbols via PC-relative references from the stub itself.
This improves code reuse across architectures, and makes it easier to
add new references in a generic manner.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/kernel/image-vars.h | 10 ------
drivers/firmware/efi/libstub/arm64-stub.c | 33 ++++++--------------
2 files changed, 9 insertions(+), 34 deletions(-)
diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h
index 19d602e45523..329d5e214b36 100644
--- a/arch/arm64/kernel/image-vars.h
+++ b/arch/arm64/kernel/image-vars.h
@@ -20,8 +20,6 @@
PROVIDE(pisym = sym); \
ASSERT((sym - KIMAGE_VADDR) < (__bss_start - KIMAGE_VADDR), #msg)
-PROVIDE(__efistub_primary_entry = primary_entry);
-
/*
* The EFI stub has its own symbol namespace prefixed by __efistub_, to
* isolate it from the kernel proper. The following symbols are legally
@@ -32,14 +30,6 @@ PROVIDE(__efistub_primary_entry = primary_entry);
* position independent manner
*/
PROVIDE(__efistub_caches_clean_inval_pou = __pi_caches_clean_inval_pou);
-
-PROVIDE(__efistub__text = _text);
-PROVIDE(__efistub__end = _end);
-PROVIDE(__efistub___inittext_end = __inittext_end);
-PROVIDE(__efistub__edata = _edata);
-#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
-PROVIDE(__efistub_sysfb_primary_display = sysfb_primary_display);
-#endif
PROVIDE(__efistub__ctype = _ctype);
PROVIDE(__pi___memcpy = __pi_memcpy);
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
index c93ab8b6e9d3..8ff8f8651504 100644
--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -10,7 +10,6 @@
#include <linux/efi.h>
#include <asm/efi.h>
#include <asm/memory.h>
-#include <asm/sections.h>
#include "efistub.h"
@@ -22,23 +21,23 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
efi_handle_t image_handle,
const struct efi_image_info **image_info)
{
- unsigned long kernel_size, kernel_codesize, kernel_memsize;
+ unsigned long kernel_base = efistub_kernel_base(*image_info);
+ unsigned long kernel_size = efistub_kernel_size(*image_info);
+ unsigned long kernel_codesize = efistub_kernel_codesize(*image_info);
+ unsigned long kernel_memsize = efistub_kernel_memsize(*image_info);
efi_status_t status;
- if (image->image_base != _text) {
+ if (image->image_base != (void *)kernel_base) {
efi_err("FIRMWARE BUG: efi_loaded_image_t::image_base has bogus value\n");
- image->image_base = _text;
+ image->image_base = (void *)kernel_base;
}
- if (!IS_ALIGNED((u64)_text, SEGMENT_ALIGN))
+ if (!IS_ALIGNED(kernel_base, SEGMENT_ALIGN))
efi_err("FIRMWARE BUG: kernel image not aligned on %dk boundary\n",
SEGMENT_ALIGN >> 10);
- kernel_size = _edata - _text;
- kernel_codesize = __inittext_end - _text;
- kernel_memsize = kernel_size + (_end - _edata);
*reserve_size = kernel_memsize;
- *image_addr = (unsigned long)_text;
+ *image_addr = kernel_base;
status = efi_kaslr_relocate_kernel(image_addr, reserve_addr,
reserve_size, kernel_size,
@@ -48,24 +47,10 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
if (status != EFI_SUCCESS)
return status;
- *(unsigned long *)image_info += *image_addr - (unsigned long)_text;
+ *(unsigned long *)image_info += *image_addr - kernel_base;
return EFI_SUCCESS;
}
-asmlinkage void primary_entry(void);
-
-unsigned long primary_entry_offset(void)
-{
- /*
- * When built as part of the kernel, the EFI stub cannot branch to the
- * kernel proper via the image header, as the PE/COFF header is
- * strictly not part of the in-memory presentation of the image, only
- * of the file representation. So instead, we need to jump to the
- * actual entrypoint in the .text region of the image.
- */
- return (char *)primary_entry - _text;
-}
-
void efi_icache_sync(unsigned long start, unsigned long end)
{
caches_clean_inval_pou(start, end);
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 09/15] efi/libstub: loongarch: Use struct efi_image_info to access image properties
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (7 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 08/15] efi/libstub: arm64: Use struct efi_image_info to access image properties Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 10/15] efi/libstub: riscv: " Ard Biesheuvel
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Instead of exposing individual symbols to the EFI stub explicitly via
the linker script, use the generic struct efi_image_info, which accesses
the original symbols via PC-relative references from the stub itself.
This improves code reuse across architectures, and makes it easier to
add new references in a generic manner.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/loongarch/kernel/image-vars.h | 4 ----
drivers/firmware/efi/libstub/loongarch-stub.c | 8 --------
drivers/firmware/efi/libstub/loongarch.c | 9 +--------
3 files changed, 1 insertion(+), 20 deletions(-)
diff --git a/arch/loongarch/kernel/image-vars.h b/arch/loongarch/kernel/image-vars.h
index e557ebd46c2b..b01022ce6bb8 100644
--- a/arch/loongarch/kernel/image-vars.h
+++ b/arch/loongarch/kernel/image-vars.h
@@ -8,12 +8,8 @@
#ifdef CONFIG_EFI_STUB
__efistub_strcmp = strcmp;
-__efistub_kernel_entry = kernel_entry;
__efistub_kernel_asize = kernel_asize;
__efistub_kernel_fsize = kernel_fsize;
-#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
-__efistub_sysfb_primary_display = sysfb_primary_display;
-#endif
#endif
diff --git a/drivers/firmware/efi/libstub/loongarch-stub.c b/drivers/firmware/efi/libstub/loongarch-stub.c
index d57e3d3557a5..6126b05e99fb 100644
--- a/drivers/firmware/efi/libstub/loongarch-stub.c
+++ b/drivers/firmware/efi/libstub/loongarch-stub.c
@@ -116,11 +116,3 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
*(unsigned long *)image_info += *image_addr - (unsigned long)image->image_base;
return status;
}
-
-unsigned long kernel_entry_address(unsigned long kernel_addr,
- efi_loaded_image_t *image)
-{
- unsigned long base = (unsigned long)image->image_base;
-
- return (unsigned long)&kernel_entry - base + kernel_addr;
-}
diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/efi/libstub/loongarch.c
index 7f21e79384d3..dd4bdf4b08cc 100644
--- a/drivers/firmware/efi/libstub/loongarch.c
+++ b/drivers/firmware/efi/libstub/loongarch.c
@@ -59,16 +59,9 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map, void *priv)
return EFI_SUCCESS;
}
-unsigned long __weak kernel_entry_address(unsigned long kernel_addr,
- efi_loaded_image_t *image)
-{
- return *(unsigned long *)(kernel_addr + 8) - PHYSADDR(VMLINUX_LOAD_ADDRESS) + kernel_addr;
-}
-
efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
const struct efi_image_info *image_info, char *cmdline_ptr)
{
- unsigned long kernel_addr = efistub_kernel_base(image_info);
kernel_entry_t real_kernel_entry;
struct exit_boot_struct priv;
unsigned long desc_size;
@@ -99,7 +92,7 @@ efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
csr_write(CSR_DMW2_INIT, LOONGARCH_CSR_DMWIN2);
csr_write(CSR_DMW3_INIT, LOONGARCH_CSR_DMWIN3);
- real_kernel_entry = (void *)kernel_entry_address(kernel_addr, image);
+ real_kernel_entry = efistub_kernel_entry(image_info);
real_kernel_entry(true, (unsigned long)cmdline_ptr,
(unsigned long)efi_system_table);
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 10/15] efi/libstub: riscv: Use struct efi_image_info to access image properties
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (8 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 09/15] efi/libstub: loongarch: " Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 11/15] efi/libstub: Make efi_remap_image() return efi_status_t Ard Biesheuvel
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Instead of exposing individual symbols to the EFI stub explicitly via
the linker script, use the generic struct efi_image_info, which accesses
the original symbols via PC-relative references from the stub itself.
This improves code reuse across architectures, and makes it easier to
add new references in a generic manner.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/riscv/kernel/image-vars.h | 8 -------
drivers/firmware/efi/libstub/riscv-stub.c | 25 +++++---------------
2 files changed, 6 insertions(+), 27 deletions(-)
diff --git a/arch/riscv/kernel/image-vars.h b/arch/riscv/kernel/image-vars.h
index bf703eba3fa5..c18b24792a29 100644
--- a/arch/riscv/kernel/image-vars.h
+++ b/arch/riscv/kernel/image-vars.h
@@ -23,14 +23,6 @@
* linked at. The routines below are all implemented in assembler in a
* position independent manner
*/
-__efistub__start = _start;
-__efistub__start_kernel = _start_kernel;
-__efistub__end = _end;
-__efistub__edata = _edata;
-__efistub___inittext_end = __inittext_end;
-#if defined(CONFIG_EFI_EARLYCON) || defined(CONFIG_SYSFB)
-__efistub_sysfb_primary_display = sysfb_primary_display;
-#endif
/*
* These double-word integer shifts are used by the library code, and
diff --git a/drivers/firmware/efi/libstub/riscv-stub.c b/drivers/firmware/efi/libstub/riscv-stub.c
index 0ddbe7cc8628..58581ccb4cc0 100644
--- a/drivers/firmware/efi/libstub/riscv-stub.c
+++ b/drivers/firmware/efi/libstub/riscv-stub.c
@@ -6,23 +6,10 @@
#include <linux/efi.h>
#include <asm/efi.h>
-#include <asm/sections.h>
#include <linux/unaligned.h>
#include "efistub.h"
-unsigned long stext_offset(void)
-{
- /*
- * When built as part of the kernel, the EFI stub cannot branch to the
- * kernel proper via the image header, as the PE/COFF header is
- * strictly not part of the in-memory presentation of the image, only
- * of the file representation. So instead, we need to jump to the
- * actual entrypoint in the .text region of the image.
- */
- return _start_kernel - _start;
-}
-
efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_size,
unsigned long *reserve_addr,
@@ -31,13 +18,13 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
efi_handle_t image_handle,
const struct efi_image_info **image_info)
{
- unsigned long kernel_size, kernel_codesize, kernel_memsize;
+ unsigned long kernel_base = efistub_kernel_base(*image_info);
+ unsigned long kernel_size = efistub_kernel_size(*image_info);
+ unsigned long kernel_codesize = efistub_kernel_codesize(*image_info);
+ unsigned long kernel_memsize = efistub_kernel_memsize(*image_info);
efi_status_t status;
- kernel_size = _edata - _start;
- kernel_codesize = __inittext_end - _start;
- kernel_memsize = kernel_size + (_end - _edata);
- *image_addr = (unsigned long)_start;
+ *image_addr = kernel_base;
*reserve_size = kernel_memsize;
status = efi_kaslr_relocate_kernel(image_addr,
@@ -47,7 +34,7 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
if (status != EFI_SUCCESS)
efi_err("Failed to relocate kernel\n");
- *(unsigned long *)image_info += *image_addr - (unsigned long)_start;
+ *(unsigned long *)image_info += *image_addr - kernel_base;
return status;
}
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 11/15] efi/libstub: Make efi_remap_image() return efi_status_t
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (9 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 10/15] efi/libstub: riscv: " Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 12/15] efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image() Ard Biesheuvel
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
efi_remap_image() uses the EFI Memory Attributes Protocol to remap code
and data regions with the appropriate permissions. This could fail for a
variety of regions, all of which are currently ignored.
So relay the failure status code if any occur when invoking the
protocol. Locating the protocol itself is allowed to fail, as remapping
the image is likely unnecessary in the first place if the protocol does
not exist.
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/libstub/efi-stub-helper.c | 15 ++++++++++-----
drivers/firmware/efi/libstub/efistub.h | 4 ++--
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 8e43eb3f418b..e50deec99686 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -697,9 +697,11 @@ efi_status_t efi_wait_for_key(unsigned long usec, efi_input_key_t *key)
* region of the loaded image read-only/executable, and the remainder
* read-write/non-executable. The code region is assumed to start at the base
* of the image, and will therefore cover the PE/COFF header as well.
+ *
+ * Return: EFI_SUCCESS on success, other EFI status codes on failure.
*/
-void efi_remap_image(unsigned long image_base, unsigned alloc_size,
- unsigned long code_size)
+efi_status_t efi_remap_image(unsigned long image_base, unsigned alloc_size,
+ unsigned long code_size)
{
static efi_guid_t guid = EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID;
efi_memory_attribute_protocol_t *memattr;
@@ -710,10 +712,12 @@ void efi_remap_image(unsigned long image_base, unsigned alloc_size,
* If the firmware implements the EFI_MEMORY_ATTRIBUTE_PROTOCOL, let's
* invoke it to remap the text/rodata region of the decompressed image
* as read-only and the data/bss region as non-executable.
+ * Don't bother if the protocol does not exist: it means all memory is
+ * read-write-exec anyway.
*/
status = efi_bs_call(locate_protocol, &guid, NULL, (void **)&memattr);
if (status != EFI_SUCCESS)
- return;
+ return EFI_SUCCESS;
// Get the current attributes for the entire region
status = memattr->get_memory_attributes(memattr, image_base,
@@ -721,7 +725,7 @@ void efi_remap_image(unsigned long image_base, unsigned alloc_size,
if (status != EFI_SUCCESS) {
efi_warn("Failed to retrieve memory attributes for image region: 0x%lx\n",
status);
- return;
+ return status;
}
// Mark the code region as read-only
@@ -729,7 +733,7 @@ void efi_remap_image(unsigned long image_base, unsigned alloc_size,
EFI_MEMORY_RO);
if (status != EFI_SUCCESS) {
efi_warn("Failed to remap code region read-only\n");
- return;
+ return status;
}
// If the entire region was already mapped as non-exec, clear the
@@ -749,4 +753,5 @@ void efi_remap_image(unsigned long image_base, unsigned alloc_size,
if (status != EFI_SUCCESS)
efi_warn("Failed to remap data region non-executable\n");
}
+ return status;
}
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index b985ababbe66..634e52aa6dcc 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1293,8 +1293,8 @@ struct efi_smbios_type4_record {
const u8 *__efi_get_smbios_string(const struct efi_smbios_record *record,
const u8 *offset);
-void efi_remap_image(unsigned long image_base, unsigned alloc_size,
- unsigned long code_size);
+efi_status_t efi_remap_image(unsigned long image_base, unsigned alloc_size,
+ unsigned long code_size);
efi_status_t efi_kaslr_relocate_kernel(unsigned long *image_addr,
unsigned long *reserve_addr,
unsigned long *reserve_size,
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 12/15] efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image()
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (10 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 11/15] efi/libstub: Make efi_remap_image() return efi_status_t Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 13/15] efi/libstub: arm64: Drop zboot code_size hack Ard Biesheuvel
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Refactor efi_cache_sync_image() so that it is not in charge of calling
efi_remap_image(), which is really the wrong way around.
Instead, call efi_remap_image() from the primary zboot procedure, where
it is more straight-forward to obtain the code size from the loaded
image.
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/libstub/arm64.c | 2 --
drivers/firmware/efi/libstub/zboot-decompress-gzip.c | 2 --
drivers/firmware/efi/libstub/zboot-decompress-zstd.c | 2 --
drivers/firmware/efi/libstub/zboot.c | 14 +++++++++++++-
4 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
index e892302f4189..f8bb890b9631 100644
--- a/drivers/firmware/efi/libstub/arm64.c
+++ b/drivers/firmware/efi/libstub/arm64.c
@@ -113,8 +113,6 @@ void efi_cache_sync_image(unsigned long image_base,
asm("ic ialluis");
dsb(ish);
isb();
-
- efi_remap_image(image_base, alloc_size, code_size);
}
void __noreturn efi_enter_kernel(const struct efi_image_info *image_info,
diff --git a/drivers/firmware/efi/libstub/zboot-decompress-gzip.c b/drivers/firmware/efi/libstub/zboot-decompress-gzip.c
index e97a7e9d3c98..79cf8c48b033 100644
--- a/drivers/firmware/efi/libstub/zboot-decompress-gzip.c
+++ b/drivers/firmware/efi/libstub/zboot-decompress-gzip.c
@@ -62,7 +62,5 @@ efi_status_t efi_zboot_decompress(u8 *out, unsigned long outlen)
return EFI_LOAD_ERROR;
}
- efi_cache_sync_image((unsigned long)out, outlen);
-
return EFI_SUCCESS;
}
diff --git a/drivers/firmware/efi/libstub/zboot-decompress-zstd.c b/drivers/firmware/efi/libstub/zboot-decompress-zstd.c
index bde9d94dd2e3..dd7f11238154 100644
--- a/drivers/firmware/efi/libstub/zboot-decompress-zstd.c
+++ b/drivers/firmware/efi/libstub/zboot-decompress-zstd.c
@@ -43,7 +43,5 @@ efi_status_t efi_zboot_decompress(u8 *out, unsigned long outlen)
return EFI_LOAD_ERROR;
}
- efi_cache_sync_image((unsigned long)out, outlen);
-
return EFI_SUCCESS;
}
diff --git a/drivers/firmware/efi/libstub/zboot.c b/drivers/firmware/efi/libstub/zboot.c
index 4cff756902ad..9c7de225b39e 100644
--- a/drivers/firmware/efi/libstub/zboot.c
+++ b/drivers/firmware/efi/libstub/zboot.c
@@ -40,6 +40,17 @@ const struct efi_image_info *zboot_get_image_info(unsigned long image_base)
return (void *)image_base + efistub_image_info_offset;
}
+static efi_status_t efi_zboot_remap_image(const struct efi_image_info *image_info,
+ unsigned long image_base,
+ unsigned long image_size)
+{
+ unsigned long code_size = efistub_kernel_codesize(image_info);
+
+ efi_cache_sync_image(image_base, code_size);
+
+ return efi_remap_image(image_base, image_size, code_size);
+}
+
asmlinkage efi_status_t __efiapi
efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab)
{
@@ -107,7 +118,8 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab)
goto error;
auto image_info = zboot_get_image_info(image_base);
- status = efi_stub_common(handle, image, image_info, cmdline_ptr);
+ status = efi_zboot_remap_image(image_info, image_base, alloc_size) ?:
+ efi_stub_common(handle, image, image_info, cmdline_ptr);
error:
efi_free(alloc_size, image_base);
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 13/15] efi/libstub: arm64: Drop zboot code_size hack
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (11 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 12/15] efi/zboot: Disentangle efi_remap_image() from efi_cache_sync_image() Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 14/15] efi: Make config table based primary display handover ARM-only again Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 15/15] Revert "efi: earlycon: Reprobe after parsing config tables" Ard Biesheuvel
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
Now that the code size can be obtained via the generic image_info
struct, there is no longer a need to inject it explicitly during the
build.
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/boot/Makefile | 3 ---
arch/arm64/kernel/image-vars.h | 4 ----
drivers/firmware/efi/libstub/arm64.c | 4 +---
drivers/firmware/efi/libstub/zboot.lds | 4 ----
4 files changed, 1 insertion(+), 14 deletions(-)
diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
index d42d07667822..509b59518818 100644
--- a/arch/arm64/boot/Makefile
+++ b/arch/arm64/boot/Makefile
@@ -51,7 +51,4 @@ EFI_ZBOOT_BFD_TARGET := elf64-littleaarch64
EFI_ZBOOT_MACH_TYPE := ARM64
EFI_ZBOOT_FORWARD_CFI := $(CONFIG_ARM64_BTI_KERNEL)
-EFI_ZBOOT_OBJCOPY_FLAGS = --add-symbol zboot_code_size=0x$$( \
- $(NM) vmlinux|grep _kernel_codesize|cut -d' ' -f1)
-
include $(srctree)/drivers/firmware/efi/libstub/Makefile.zboot
diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h
index 329d5e214b36..ca634cedcf63 100644
--- a/arch/arm64/kernel/image-vars.h
+++ b/arch/arm64/kernel/image-vars.h
@@ -140,10 +140,6 @@ KVM_NVHE_ALIAS(kvm_protected_mode_initialized);
#endif /* CONFIG_KVM */
-#ifdef CONFIG_EFI_ZBOOT
-_kernel_codesize = ABSOLUTE(__inittext_end - _text);
-#endif
-
/*
* LLD will occasionally error out with a '__init_end does not converge' error
* if INIT_IDMAP_DIR_SIZE is defined in terms of _end, as this results in a
diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
index f8bb890b9631..8a051412814d 100644
--- a/drivers/firmware/efi/libstub/arm64.c
+++ b/drivers/firmware/efi/libstub/arm64.c
@@ -88,8 +88,6 @@ efi_status_t check_platform_features(void)
#define DCTYPE "cvau"
#endif
-u32 __weak code_size;
-
void efi_cache_sync_image(unsigned long image_base,
unsigned long alloc_size)
{
@@ -100,7 +98,7 @@ void efi_cache_sync_image(unsigned long image_base,
/* only perform the cache maintenance if needed for I/D coherency */
if (!(ctr & BIT(CTR_EL0_IDC_SHIFT))) {
unsigned long base = image_base;
- unsigned long size = code_size;
+ unsigned long size = alloc_size;
do {
asm("dc " DCTYPE ", %0" :: "r"(base));
diff --git a/drivers/firmware/efi/libstub/zboot.lds b/drivers/firmware/efi/libstub/zboot.lds
index e1365907f805..e0f0bf005854 100644
--- a/drivers/firmware/efi/libstub/zboot.lds
+++ b/drivers/firmware/efi/libstub/zboot.lds
@@ -2,8 +2,6 @@
ENTRY(__efistub_efi_zboot_header);
-PROVIDE(zboot_code_size = ABSOLUTE(0));
-
SECTIONS
{
.head : ALIGN(4096) {
@@ -22,8 +20,6 @@ SECTIONS
*(.rodata* .init.rodata* .srodata*)
. = ALIGN(4);
- __efistub_code_size = .;
- LONG(zboot_code_size);
__efistub_efistub_image_info_offset = .;
LONG(efistub_image_info_offset);
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 14/15] efi: Make config table based primary display handover ARM-only again
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (12 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 13/15] efi/libstub: arm64: Drop zboot code_size hack Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
2026-11-16 14:26 ` [PATCH v3 15/15] Revert "efi: earlycon: Reprobe after parsing config tables" Ard Biesheuvel
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
This reverts the effect of commit 732ea9db9d8a ("efi: libstub: Move
screen_info handling to common code"), taking into account the changes
that were made to the code since.
That commit moved all architectures to the ARM approach of passing the
primary display information (formerly struct screen_info) from the EFI
stub to the core kernel via an EFI configuration table, so that the zboot
decompressor, which is not linked into the core kernel image, could pass
this information as well.
Now that the EFI stub and the zboot decompressor both have access to the
location of sysfb_primary_display inside the loaded kernel image via
struct efi_image_info, they can populate it directly, and the
configuration table is only needed on ARM, whose decompressor has no
such information.
So make the configuration table based handover ARM-only again:
- move the config table based alloc/free routines into the ARM stub,
and provide __weak defaults in the generic stub that return a pointer
to the kernel image's copy of sysfb_primary_display;
- drop the primary display table from the common config table list,
and move the code that copies it into sysfb_primary_display into the
ARM arch code;
- on the other architectures, revert to simply reserving the
framebuffer memory if the stub populated sysfb_primary_display.
This makes the EFI framebuffer earlycon available right away when booting
via zboot, rather than only after the EFI config tables have been parsed.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm/kernel/efi.c | 27 ++++++++++
arch/loongarch/kernel/efi.c | 20 ++-----
drivers/firmware/efi/efi-init.c | 24 ++-------
drivers/firmware/efi/efi.c | 5 --
drivers/firmware/efi/libstub/Makefile | 2 +-
drivers/firmware/efi/libstub/arm32-stub.c | 41 ++++++++++++++
drivers/firmware/efi/libstub/efi-stub-entry.c | 13 -----
drivers/firmware/efi/libstub/efi-stub.c | 14 +++++
drivers/firmware/efi/libstub/efistub.h | 1 -
drivers/firmware/efi/libstub/primary_display.c | 56 --------------------
drivers/firmware/efi/libstub/zboot.c | 6 ---
11 files changed, 90 insertions(+), 119 deletions(-)
diff --git a/arch/arm/kernel/efi.c b/arch/arm/kernel/efi.c
index c14275257a8a..84d516b84848 100644
--- a/arch/arm/kernel/efi.c
+++ b/arch/arm/kernel/efi.c
@@ -7,6 +7,7 @@
#include <linux/memblock.h>
#include <linux/screen_info.h>
#include <linux/sizes.h>
+#include <linux/sysfb.h>
#include <asm/efi.h>
#include <asm/mach/map.h>
@@ -91,13 +92,36 @@ int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md)
return 0;
}
+static unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR;
static unsigned long __initdata cpu_state_table = EFI_INVALID_TABLE_ADDR;
const efi_config_table_type_t efi_arch_tables[] __initconst = {
+ {LINUX_EFI_PRIMARY_DISPLAY_TABLE_GUID, &primary_display_table},
{LINUX_EFI_ARM_CPU_STATE_TABLE_GUID, &cpu_state_table},
{}
};
+static void __init load_primary_display_table(void)
+{
+ struct sysfb_display_info *dpy;
+
+ if (primary_display_table == EFI_INVALID_TABLE_ADDR)
+ return;
+
+ dpy = early_memremap(primary_display_table, sizeof(*dpy));
+ if (!dpy) {
+ pr_err("Could not map primary_display config table\n");
+ return;
+ }
+ sysfb_primary_display = *dpy;
+ memset(dpy, 0, sizeof(*dpy));
+ early_memunmap(dpy, sizeof(*dpy));
+
+ if (memblock_is_map_memory(sysfb_primary_display.screen.lfb_base))
+ memblock_mark_nomap(sysfb_primary_display.screen.lfb_base,
+ sysfb_primary_display.screen.lfb_size);
+}
+
static void __init load_cpu_state_table(void)
{
if (cpu_state_table != EFI_INVALID_TABLE_ADDR) {
@@ -136,6 +160,9 @@ void __init arm_efi_init(void)
{
efi_init();
+ if (IS_ENABLED(CONFIG_SYSFB) || IS_ENABLED(CONFIG_FIRMWARE_EDID))
+ load_primary_display_table();
+
/* ARM does not permit early mappings to persist across paging_init() */
efi_memmap_unmap();
diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
index 69dd83f8082f..c914aabcd282 100644
--- a/arch/loongarch/kernel/efi.c
+++ b/arch/loongarch/kernel/efi.c
@@ -72,8 +72,6 @@ bool efi_poweroff_required(void)
(acpi_gbl_reduced_hardware || acpi_no_s5);
}
-unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR;
-
#if defined(CONFIG_SYSFB) || defined(CONFIG_EFI_EARLYCON)
struct sysfb_display_info sysfb_primary_display __section(".data");
EXPORT_SYMBOL_GPL(sysfb_primary_display);
@@ -81,22 +79,10 @@ EXPORT_SYMBOL_GPL(sysfb_primary_display);
static void __init init_primary_display(void)
{
- struct sysfb_display_info *dpy;
-
- if (primary_display_table == EFI_INVALID_TABLE_ADDR)
- return;
-
- dpy = early_memremap(primary_display_table, sizeof(*dpy));
- if (!dpy) {
- pr_err("Could not map primary_display config table\n");
- return;
- }
- sysfb_primary_display = *dpy;
- memset(dpy, 0, sizeof(*dpy));
- early_memunmap(dpy, sizeof(*dpy));
+ struct screen_info *si = &sysfb_primary_display.screen;
- memblock_reserve(__screen_info_lfb_base(&sysfb_primary_display.screen),
- sysfb_primary_display.screen.lfb_size);
+ if (si->orig_video_isVGA == VIDEO_TYPE_EFI)
+ memblock_reserve(__screen_info_lfb_base(si), si->lfb_size);
}
void __init efi_init(void)
diff --git a/drivers/firmware/efi/efi-init.c b/drivers/firmware/efi/efi-init.c
index 9f09b0d2daa0..25a5497ebb2e 100644
--- a/drivers/firmware/efi/efi-init.c
+++ b/drivers/firmware/efi/efi-init.c
@@ -23,8 +23,6 @@
#include <asm/efi.h>
-unsigned long __initdata primary_display_table = EFI_INVALID_TABLE_ADDR;
-
static int __init is_memory(efi_memory_desc_t *md)
{
if (md->attribute & (EFI_MEMORY_WB|EFI_MEMORY_WT|EFI_MEMORY_WC))
@@ -67,25 +65,11 @@ EXPORT_SYMBOL_GPL(sysfb_primary_display);
static void __init init_primary_display(void)
{
- struct sysfb_display_info *dpy;
-
- if (primary_display_table != EFI_INVALID_TABLE_ADDR) {
- dpy = early_memremap(primary_display_table, sizeof(*dpy));
- if (!dpy) {
- pr_err("Could not map primary_display config table\n");
- return;
- }
- sysfb_primary_display = *dpy;
- memset(dpy, 0, sizeof(*dpy));
- early_memunmap(dpy, sizeof(*dpy));
+ struct screen_info *si = &sysfb_primary_display.screen;
- if (memblock_is_map_memory(sysfb_primary_display.screen.lfb_base))
- memblock_mark_nomap(sysfb_primary_display.screen.lfb_base,
- sysfb_primary_display.screen.lfb_size);
-
- if (IS_ENABLED(CONFIG_EFI_EARLYCON))
- efi_earlycon_reprobe();
- }
+ if (si->orig_video_isVGA == VIDEO_TYPE_EFI &&
+ memblock_is_map_memory(si->lfb_base))
+ memblock_mark_nomap(si->lfb_base, si->lfb_size);
}
static int __init uefi_init(u64 efi_system_table)
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 9bc22de0d67e..90c421211ddc 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -57,8 +57,6 @@ unsigned long __ro_after_init efi_rng_seed = EFI_INVALID_TABLE_ADDR;
static unsigned long __initdata rt_prop = EFI_INVALID_TABLE_ADDR;
static unsigned long __initdata initrd = EFI_INVALID_TABLE_ADDR;
-extern unsigned long primary_display_table;
-
struct mm_struct efi_mm = {
.mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS, efi_mm.mmap_lock),
.mm_users = ATOMIC_INIT(2),
@@ -674,9 +672,6 @@ static const efi_config_table_type_t common_tables[] __initconst = {
#endif
#ifdef CONFIG_UNACCEPTED_MEMORY
{LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID, &efi.unaccepted, "Unaccepted" },
-#endif
-#ifdef CONFIG_EFI_GENERIC_STUB
- {LINUX_EFI_PRIMARY_DISPLAY_TABLE_GUID, &primary_display_table },
#endif
{},
};
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index 9dc6a707fd79..0c5fbc21d2a2 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -81,7 +81,7 @@ $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
$(call if_changed_rule,cc_o_c)
lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o \
- primary_display.o efi-stub-entry.o
+ efi-stub-entry.o
lib-$(CONFIG_ARM) += arm32-stub.o
lib-$(CONFIG_ARM64) += kaslr.o arm64.o arm64-stub.o smbios.o
diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
index b73a0b4fcd10..5e6c0de168f4 100644
--- a/drivers/firmware/efi/libstub/arm32-stub.c
+++ b/drivers/firmware/efi/libstub/arm32-stub.c
@@ -3,6 +3,7 @@
* Copyright (C) 2013 Linaro Ltd; <roy.franz@linaro.org>
*/
#include <linux/efi.h>
+#include <linux/sysfb.h>
#include <asm/efi.h>
#include "efistub.h"
@@ -76,6 +77,46 @@ void efi_handle_post_ebs_state(void)
&efi_entry_state->sctlr_after_ebs);
}
+static efi_guid_t primary_display_guid = LINUX_EFI_PRIMARY_DISPLAY_TABLE_GUID;
+
+struct sysfb_display_info *
+alloc_primary_display(const struct efi_image_info *image_info)
+{
+ struct sysfb_display_info *dpy;
+ efi_status_t status;
+
+ /*
+ * Unlike on other architectures, where we can directly fill out the
+ * sysfb_primary_display structure in the loaded kernel image, we need
+ * to allocate a buffer to hold its contents while we hand over to the
+ * kernel proper from the decompressor.
+ */
+ status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
+ sizeof(*dpy), (void **)&dpy);
+
+ if (status != EFI_SUCCESS)
+ return NULL;
+
+ memset(dpy, 0, sizeof(*dpy));
+
+ status = efi_bs_call(install_configuration_table,
+ &primary_display_guid, dpy);
+ if (status == EFI_SUCCESS)
+ return dpy;
+
+ efi_bs_call(free_pool, dpy);
+ return NULL;
+}
+
+void free_primary_display(struct sysfb_display_info *dpy)
+{
+ if (!dpy)
+ return;
+
+ efi_bs_call(install_configuration_table, &primary_display_guid, NULL);
+ efi_bs_call(free_pool, dpy);
+}
+
struct efi_image_info efistub_image_info = {};
efi_status_t handle_kernel_image(unsigned long *image_addr,
diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c
index 36ea6aa2cfcc..fb1a4a175717 100644
--- a/drivers/firmware/efi/libstub/efi-stub-entry.c
+++ b/drivers/firmware/efi/libstub/efi-stub-entry.c
@@ -9,19 +9,6 @@
extern const struct efi_image_info efistub_image_info;
-struct sysfb_display_info *
-alloc_primary_display(const struct efi_image_info *image_info)
-{
- if (IS_ENABLED(CONFIG_ARM))
- return __alloc_primary_display();
-
- if (IS_ENABLED(CONFIG_EFI_EARLYCON) ||
- IS_ENABLED(CONFIG_SYSFB))
- return efistub_sysfb_display_info(image_info);
-
- return NULL;
-}
-
/*
* EFI entry point for the generic EFI stub used by ARM, arm64, RISC-V and
* LoongArch. This is the entrypoint that is described in the PE/COFF header
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index 55bf7ed50c81..a824b2ba3026 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -48,6 +48,20 @@
static u64 virtmap_base = EFI_RT_VIRTUAL_BASE;
static bool flat_va_mapping = (EFI_RT_VIRTUAL_OFFSET != 0);
+/*
+ * By default, populate the core kernel's copy of sysfb_primary_display
+ * directly. This works for both the EFI stub that is incorporated into the
+ * core kernel and for the zboot decompressor, as both have access to the
+ * location of the variable inside the loaded kernel image via image_info.
+ *
+ * ARM overrides these, as it uses a configuration table instead.
+ */
+struct sysfb_display_info * __weak
+alloc_primary_display(const struct efi_image_info *image_info)
+{
+ return efistub_sysfb_display_info(image_info);
+}
+
void __weak free_primary_display(struct sysfb_display_info *dpy)
{ }
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 634e52aa6dcc..082ce2961dda 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -1226,7 +1226,6 @@ void efi_retrieve_eventlog(void);
struct sysfb_display_info *
alloc_primary_display(const struct efi_image_info *image_info);
-struct sysfb_display_info *__alloc_primary_display(void);
void free_primary_display(struct sysfb_display_info *dpy);
void efi_cache_sync_image(unsigned long image_base,
diff --git a/drivers/firmware/efi/libstub/primary_display.c b/drivers/firmware/efi/libstub/primary_display.c
deleted file mode 100644
index cdaebab26514..000000000000
--- a/drivers/firmware/efi/libstub/primary_display.c
+++ /dev/null
@@ -1,56 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#include <linux/efi.h>
-#include <linux/sysfb.h>
-
-#include <asm/efi.h>
-
-#include "efistub.h"
-
-/*
- * There are two ways of populating the core kernel's sysfb_primary_display
- * via the stub:
- *
- * - using a configuration table, which relies on the EFI init code to
- * locate the table and copy the contents; or
- *
- * - by linking directly to the core kernel's copy of the global symbol.
- *
- * The latter is preferred because it makes the EFIFB earlycon available very
- * early, but it only works if the EFI stub is part of the core kernel image
- * itself. The zboot decompressor can only use the configuration table
- * approach.
- */
-
-static efi_guid_t primary_display_guid = LINUX_EFI_PRIMARY_DISPLAY_TABLE_GUID;
-
-struct sysfb_display_info *__alloc_primary_display(void)
-{
- struct sysfb_display_info *dpy;
- efi_status_t status;
-
- status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY,
- sizeof(*dpy), (void **)&dpy);
-
- if (status != EFI_SUCCESS)
- return NULL;
-
- memset(dpy, 0, sizeof(*dpy));
-
- status = efi_bs_call(install_configuration_table,
- &primary_display_guid, dpy);
- if (status == EFI_SUCCESS)
- return dpy;
-
- efi_bs_call(free_pool, dpy);
- return NULL;
-}
-
-void free_primary_display(struct sysfb_display_info *dpy)
-{
- if (!dpy)
- return;
-
- efi_bs_call(install_configuration_table, &primary_display_guid, NULL);
- efi_bs_call(free_pool, dpy);
-}
diff --git a/drivers/firmware/efi/libstub/zboot.c b/drivers/firmware/efi/libstub/zboot.c
index 9c7de225b39e..4089a29068ca 100644
--- a/drivers/firmware/efi/libstub/zboot.c
+++ b/drivers/firmware/efi/libstub/zboot.c
@@ -26,12 +26,6 @@ void __weak efi_cache_sync_image(unsigned long image_base,
// executable code loaded into memory to be safe for execution.
}
-struct sysfb_display_info *
-alloc_primary_display(const struct efi_image_info *image_info)
-{
- return efistub_sysfb_display_info(image_info);
-}
-
static
const struct efi_image_info *zboot_get_image_info(unsigned long image_base)
{
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread* [PATCH v3 15/15] Revert "efi: earlycon: Reprobe after parsing config tables"
2026-11-16 14:26 [PATCH v3 00/15] efi: Expose loaded image properties via info struct Ard Biesheuvel
` (13 preceding siblings ...)
2026-11-16 14:26 ` [PATCH v3 14/15] efi: Make config table based primary display handover ARM-only again Ard Biesheuvel
@ 2026-11-16 14:26 ` Ard Biesheuvel
14 siblings, 0 replies; 16+ messages in thread
From: Ard Biesheuvel @ 2026-11-16 14:26 UTC (permalink / raw)
To: linux-efi
Cc: linux-arm-kernel, Ard Biesheuvel, Jason Gunthorpe, Paul Walmsley,
Palmer Dabbelt, Albert Ou, Huacai Chen, loongarch, linux-riscv
From: Ard Biesheuvel <ardb@kernel.org>
This reverts commit 8b3a149db461d3286d1e211112de3b44ccaeaf71.
That commit added logic to probe the EFI framebuffer earlycon again after
the EFI configuration tables have been parsed, as the primary display
information may not have been available yet when the earlycon= early
parameter was processed.
Now that only ARM uses a configuration table to pass the primary display
information to the core kernel, and the EFI framebuffer earlycon is not
supported on ARM, the reprobe logic no longer has any callers. So revert
it.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
drivers/firmware/efi/earlycon.c | 16 +++-------------
include/linux/efi.h | 1 -
2 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
index 3d060d59968c..997f69ce46cb 100644
--- a/drivers/firmware/efi/earlycon.c
+++ b/drivers/firmware/efi/earlycon.c
@@ -216,14 +216,6 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
}
}
-static bool __initdata fb_probed;
-
-void __init efi_earlycon_reprobe(void)
-{
- if (fb_probed)
- setup_earlycon("efifb");
-}
-
static int __init efi_earlycon_setup(struct earlycon_device *device,
const char *opt)
{
@@ -231,17 +223,15 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
u16 xres, yres;
u32 i;
- fb_wb = opt && !strcmp(opt, "ram");
-
- if (si->orig_video_isVGA != VIDEO_TYPE_EFI) {
- fb_probed = true;
+ if (si->orig_video_isVGA != VIDEO_TYPE_EFI)
return -ENODEV;
- }
fb_base = si->lfb_base;
if (si->capabilities & VIDEO_CAPABILITY_64BIT_BASE)
fb_base |= (u64)si->ext_lfb_base << 32;
+ fb_wb = opt && !strcmp(opt, "ram");
+
xres = si->lfb_width;
yres = si->lfb_height;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index cc1df1577d5f..4a809c6ae724 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -719,7 +719,6 @@ efi_guid_to_str(const efi_guid_t *guid, char *out)
}
extern void efi_init (void);
-extern void efi_earlycon_reprobe(void);
#ifdef CONFIG_EFI
extern void efi_enter_virtual_mode (void); /* switch EFI to virtual mode, if possible */
#else
--
2.56.0.611.g1030f0b940-goog
^ permalink raw reply related [flat|nested] 16+ messages in thread