aboutsummaryrefslogtreecommitdiff
path: root/arch/arm64
diff options
context:
space:
mode:
authorArd Biesheuvel2023-04-18 15:49:49 +0200
committerArd Biesheuvel2023-04-26 18:01:41 +0200
commit45dd403da851124412d32e3193c21de4a51d29da (patch)
treedb4606bec41de6a73ca1a9929840f73520207266 /arch/arm64
parent538bc0f40b364f2c7b81f11aa163f723b138b40f (diff)
efi/zboot: arm64: Inject kernel code size symbol into the zboot payload
The EFI zboot code is not built as part of the kernel proper, like the ordinary EFI stub, but still needs access to symbols that are defined only internally in the kernel, and are left unexposed deliberately to avoid creating ABI inadvertently that we're stuck with later. So capture the kernel code size of the kernel image, and inject it as an ELF symbol into the object that contains the compressed payload, where it will be accessible to zboot code that needs it. Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Acked-by: Mark Rutland <mark.rutland@arm.com>
Diffstat (limited to 'arch/arm64')
-rw-r--r--arch/arm64/boot/Makefile3
-rw-r--r--arch/arm64/kernel/image-vars.h4
2 files changed, 7 insertions, 0 deletions
diff --git a/arch/arm64/boot/Makefile b/arch/arm64/boot/Makefile
index ae645fda90bc..1761f5972443 100644
--- a/arch/arm64/boot/Makefile
+++ b/arch/arm64/boot/Makefile
@@ -44,4 +44,7 @@ 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$(shell \
+ $(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 8309197c0ebd..35f3c7959513 100644
--- a/arch/arm64/kernel/image-vars.h
+++ b/arch/arm64/kernel/image-vars.h
@@ -108,4 +108,8 @@ KVM_NVHE_ALIAS(kvm_protected_mode_initialized);
#endif /* CONFIG_KVM */
+#ifdef CONFIG_EFI_ZBOOT
+_kernel_codesize = ABSOLUTE(__inittext_end - _text);
+#endif
+
#endif /* __ARM64_KERNEL_IMAGE_VARS_H */