From: Ard Biesheuvel <ardb at kernel.org>
Instead of taking vmlinux symbol values at build time and poking them
into the zboot linker script, wire up struct efi_image_info so this
information can be obtained from the code.
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
arch/arm64/boot/Makefile | 3 ---
arch/arm64/include/asm/efi.h | 11 ++++++++---
arch/arm64/kernel/image-vars.h | 4 ----
drivers/firmware/efi/libstub/arm64-stub.c | 2 ++
drivers/firmware/efi/libstub/arm64.c | 4 +---
drivers/firmware/efi/libstub/zboot.lds | 7 -------
6 files changed, 11 insertions(+), 20 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/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index b0c9120b9741..3194e133a4d5 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -151,10 +151,15 @@ efi_status_t efi_handle_corrupted_x18(efi_status_t s, const char *f);
void efi_icache_sync(unsigned long start, unsigned long end);
-// temporary resolution for efistub_get_code_size()
-#define efistub_get_code_size(image_info) ({ extern u32 code_size; code_size; })
-
struct efi_image_info {
+ s32 _text_offset;
+ s32 __inittext_end_offset;
};
+static inline u32 efistub_get_code_size(const struct efi_image_info *info)
+{
+ return info->__inittext_end_offset - info->_text_offset;
+}
+#define efistub_get_code_size efistub_get_code_size
+
#endif /* _ASM_EFI_H */
diff --git a/arch/arm64/kernel/image-vars.h b/arch/arm64/kernel/image-vars.h
index 19d602e45523..b02234f080b0 100644
--- a/arch/arm64/kernel/image-vars.h
+++ b/arch/arm64/kernel/image-vars.h
@@ -150,10 +150,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-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
index 8daed681f97d..754cb2843967 100644
--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -68,6 +68,8 @@ asm(" .section \".rodata\", \"a\", %progbits; " \
" .align 3; " \
" .globl efi_image_info; " \
"efi_image_info: " \
+ " .long _text - efi_image_info; " \
+ " .long __inittext_end - efi_image_info; " \
" .previous ");
diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
index 190cf180bb23..da6fa2f6c821 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 367907eb7d86..61714a151766 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) {
@@ -20,11 +18,6 @@ SECTIONS
__efistub_payload_size = . - 4;
__efistub__gzdata_end = .;
*(.rodata* .init.rodata* .srodata*)
-
- . = ALIGN(4);
- __efistub_code_size = .;
- LONG(zboot_code_size);
-
_etext = ALIGN(4096);
. = _etext;
}
--
2.56.0.455.g6c5a503b38-goog