arm64: efi: Move efi-entry.S into the libstub source directory
authorArd Biesheuvel <ardb@kernel.org>
Mon, 17 Oct 2022 15:14:41 +0000 (17:14 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Wed, 9 Nov 2022 11:42:01 +0000 (12:42 +0100)
We will be sharing efi-entry.S with the zboot decompressor build, which
does not link against vmlinux directly. So move it into the libstub
source directory so we can include in the libstub static library.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/Makefile
arch/arm64/kernel/efi-entry.S [deleted file]
drivers/firmware/efi/libstub/Makefile
drivers/firmware/efi/libstub/arm64-entry.S [new file with mode: 0644]

index 2f361a8..2a3b0e4 100644 (file)
@@ -36,12 +36,6 @@ obj-y                        := debug-monitors.o entry.o irq.o fpsimd.o              \
                           syscall.o proton-pack.o idreg-override.o idle.o      \
                           patching.o
 
-targets                        += efi-entry.o
-
-OBJCOPYFLAGS := --prefix-symbols=__efistub_
-$(obj)/%.stub.o: $(obj)/%.o FORCE
-       $(call if_changed,objcopy)
-
 obj-$(CONFIG_COMPAT)                   += sys32.o signal32.o                   \
                                           sys_compat.o
 obj-$(CONFIG_COMPAT)                   += sigreturn32.o
@@ -57,8 +51,7 @@ obj-$(CONFIG_CPU_PM)                  += sleep.o suspend.o
 obj-$(CONFIG_CPU_IDLE)                 += cpuidle.o
 obj-$(CONFIG_JUMP_LABEL)               += jump_label.o
 obj-$(CONFIG_KGDB)                     += kgdb.o
-obj-$(CONFIG_EFI)                      += efi.o efi-entry.stub.o               \
-                                          efi-rt-wrapper.o
+obj-$(CONFIG_EFI)                      += efi.o efi-rt-wrapper.o
 obj-$(CONFIG_PCI)                      += pci.o
 obj-$(CONFIG_ARMV8_DEPRECATED)         += armv8_deprecated.o
 obj-$(CONFIG_ACPI)                     += acpi.o
diff --git a/arch/arm64/kernel/efi-entry.S b/arch/arm64/kernel/efi-entry.S
deleted file mode 100644 (file)
index 8bce133..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * EFI entry point.
- *
- * Copyright (C) 2013, 2014 Red Hat, Inc.
- * Author: Mark Salter <msalter@redhat.com>
- */
-#include <linux/linkage.h>
-#include <linux/init.h>
-
-#include <asm/assembler.h>
-
-       __INIT
-
-SYM_CODE_START(efi_enter_kernel)
-       /*
-        * efi_pe_entry() will have copied the kernel image if necessary and we
-        * end up here with device tree address in x1 and the kernel entry
-        * point stored in x0. Save those values in registers which are
-        * callee preserved.
-        */
-       ldr     w2, =primary_entry_offset
-       add     x19, x0, x2             // relocated Image entrypoint
-
-       mov     x0, x1                  // DTB address
-       mov     x1, xzr
-       mov     x2, xzr
-       mov     x3, xzr
-
-       /*
-        * Clean the remainder of this routine to the PoC
-        * so that we can safely disable the MMU and caches.
-        */
-       adr     x4, 1f
-       dc      civac, x4
-       dsb     sy
-
-       /* Turn off Dcache and MMU */
-       mrs     x4, CurrentEL
-       cmp     x4, #CurrentEL_EL2
-       mrs     x4, sctlr_el1
-       b.ne    0f
-       mrs     x4, sctlr_el2
-0:     bic     x4, x4, #SCTLR_ELx_M
-       bic     x4, x4, #SCTLR_ELx_C
-       b.eq    1f
-       b       2f
-
-       .balign 32
-1:     pre_disable_mmu_workaround
-       msr     sctlr_el2, x4
-       isb
-       br      x19             // jump to kernel entrypoint
-
-2:     pre_disable_mmu_workaround
-       msr     sctlr_el1, x4
-       isb
-       br      x19             // jump to kernel entrypoint
-
-       .org    1b + 32
-SYM_CODE_END(efi_enter_kernel)
index 26b0a42..01a0be4 100644 (file)
@@ -83,7 +83,7 @@ $(obj)/lib-%.o: $(srctree)/lib/%.c FORCE
 lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o
 
 lib-$(CONFIG_ARM)              += arm32-stub.o
-lib-$(CONFIG_ARM64)            += arm64-stub.o
+lib-$(CONFIG_ARM64)            += arm64-stub.o arm64-entry.o
 lib-$(CONFIG_X86)              += x86-stub.o
 lib-$(CONFIG_RISCV)            += riscv-stub.o
 lib-$(CONFIG_LOONGARCH)                += loongarch-stub.o
@@ -137,7 +137,7 @@ STUBCOPY_RELOC-$(CONFIG_ARM)        := R_ARM_ABS
 #
 STUBCOPY_FLAGS-$(CONFIG_ARM64) += --prefix-alloc-sections=.init \
                                   --prefix-symbols=__efistub_
-STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
+STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS64
 
 # For RISC-V, we don't need anything special other than arm64. Keep all the
 # symbols in .init section and make sure that no absolute symbols references
diff --git a/drivers/firmware/efi/libstub/arm64-entry.S b/drivers/firmware/efi/libstub/arm64-entry.S
new file mode 100644 (file)
index 0000000..87082b2
--- /dev/null
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * EFI entry point.
+ *
+ * Copyright (C) 2013, 2014 Red Hat, Inc.
+ * Author: Mark Salter <msalter@redhat.com>
+ */
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+
+SYM_CODE_START(efi_enter_kernel)
+       /*
+        * efi_pe_entry() will have copied the kernel image if necessary and we
+        * end up here with device tree address in x1 and the kernel entry
+        * point stored in x0. Save those values in registers which are
+        * callee preserved.
+        */
+       ldr     w2, =primary_entry_offset
+       add     x19, x0, x2             // relocated Image entrypoint
+
+       mov     x0, x1                  // DTB address
+       mov     x1, xzr
+       mov     x2, xzr
+       mov     x3, xzr
+
+       /*
+        * Clean the remainder of this routine to the PoC
+        * so that we can safely disable the MMU and caches.
+        */
+       adr     x4, 1f
+       dc      civac, x4
+       dsb     sy
+
+       /* Turn off Dcache and MMU */
+       mrs     x4, CurrentEL
+       cmp     x4, #CurrentEL_EL2
+       mrs     x4, sctlr_el1
+       b.ne    0f
+       mrs     x4, sctlr_el2
+0:     bic     x4, x4, #SCTLR_ELx_M
+       bic     x4, x4, #SCTLR_ELx_C
+       b.eq    1f
+       b       2f
+
+       .balign 32
+1:     pre_disable_mmu_workaround
+       msr     sctlr_el2, x4
+       isb
+       br      x19             // jump to kernel entrypoint
+
+2:     pre_disable_mmu_workaround
+       msr     sctlr_el1, x4
+       isb
+       br      x19             // jump to kernel entrypoint
+
+       .org    1b + 32
+SYM_CODE_END(efi_enter_kernel)