]> git.karo-electronics.de Git - linux-beck.git/commitdiff
efi: efistub: Convert into static library
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 2 Jul 2014 12:54:43 +0000 (14:54 +0200)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 18 Jul 2014 20:22:19 +0000 (21:22 +0100)
This patch changes both x86 and arm64 efistub implementations
from #including shared .c files under drivers/firmware/efi to
building shared code as a static library.

The x86 code uses a stub built into the boot executable which
uncompresses the kernel at boot time. In this case, the library is
linked into the decompressor.

In the arm64 case, the stub is part of the kernel proper so the library
is linked into the kernel proper as well.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
13 files changed:
arch/arm64/Kconfig
arch/arm64/Makefile
arch/arm64/kernel/Makefile
arch/arm64/kernel/efi-stub.c
arch/x86/boot/compressed/Makefile
arch/x86/boot/compressed/eboot.c
drivers/firmware/efi/Kconfig
drivers/firmware/efi/Makefile
drivers/firmware/efi/libstub/Makefile [new file with mode: 0644]
drivers/firmware/efi/libstub/arm-stub.c [moved from drivers/firmware/efi/arm-stub.c with 100% similarity]
drivers/firmware/efi/libstub/efi-stub-helper.c [moved from drivers/firmware/efi/efi-stub-helper.c with 100% similarity]
drivers/firmware/efi/libstub/efistub.h [moved from drivers/firmware/efi/efistub.h with 100% similarity]
drivers/firmware/efi/libstub/fdt.c [moved from drivers/firmware/efi/fdt.c with 100% similarity]

index 2cc14cef01bd3fb489e9e8a8753574046989cdc8..3a0a4ce4c7518273dddf14cc6453ac7a5efb0dd2 100644 (file)
@@ -292,6 +292,9 @@ config CMDLINE_FORCE
          This is useful if you cannot or don't want to change the
          command-line options your boot loader passes to the kernel.
 
+config EFI_STUB
+       bool
+
 config EFI
        bool "UEFI runtime support"
        depends on OF && !CPU_BIG_ENDIAN
@@ -299,6 +302,8 @@ config EFI
        select UCS2_STRING
        select EFI_PARAMS_FROM_FDT
        select EFI_RUNTIME_WRAPPERS
+       select EFI_STUB
+       select EFI_ARMSTUB
        default y
        help
          This option provides support for runtime services provided
index 8185a913c5ed5ab2d659c119903666409bbb1793..5836717d2f6654c4ccdf1e9b1b1358b04a3f7a75 100644 (file)
@@ -48,6 +48,7 @@ core-$(CONFIG_XEN) += arch/arm64/xen/
 core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
 libs-y         := arch/arm64/lib/ $(libs-y)
 libs-y         += $(LIBGCC)
+libs-$(CONFIG_EFI_STUB) += drivers/firmware/efi/libstub/
 
 # Default target when executing plain make
 KBUILD_IMAGE   := Image.gz
index cdaedad3afe51645fc4f4b79e44ccb1728d6fdf2..afaeb734295afc8efc8111fb475f35437edb2298 100644 (file)
@@ -4,8 +4,7 @@
 
 CPPFLAGS_vmlinux.lds   := -DTEXT_OFFSET=$(TEXT_OFFSET)
 AFLAGS_head.o          := -DTEXT_OFFSET=$(TEXT_OFFSET)
-CFLAGS_efi-stub.o      := -DTEXT_OFFSET=$(TEXT_OFFSET) \
-                          -I$(src)/../../../scripts/dtc/libfdt
+CFLAGS_efi-stub.o      := -DTEXT_OFFSET=$(TEXT_OFFSET)
 
 CFLAGS_REMOVE_ftrace.o = -pg
 CFLAGS_REMOVE_insn.o = -pg
index e4999021b07d5e4685794207c16e504e47934187..1317fef8dde9688308791097b497ecb63370ec44 100644 (file)
 #include <asm/efi.h>
 #include <asm/sections.h>
 
-/* Include shared EFI stub code */
-#include "../../../drivers/firmware/efi/efi-stub-helper.c"
-#include "../../../drivers/firmware/efi/fdt.c"
-#include "../../../drivers/firmware/efi/arm-stub.c"
-
-
 efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
                                 unsigned long *image_addr,
                                 unsigned long *image_size,
index 0fcd9133790c566423b313fccef95a0768bd0d07..7a801a310e3740fd943ba3456aec57548a1301dc 100644 (file)
@@ -33,7 +33,8 @@ VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
 $(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
 
 ifeq ($(CONFIG_EFI_STUB), y)
-       VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
+       VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
+                               $(objtree)/drivers/firmware/efi/libstub/lib.a
 endif
 
 $(obj)/vmlinux: $(VMLINUX_OBJS) FORCE
index 916bbdd7dd28ab2fe334f1c4e3cd5455e89a0cbc..3b5c66c8f74906e9529809b02ec1a47a923826d6 100644 (file)
@@ -280,8 +280,6 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str)
        }
 }
 
-#include "../../../../drivers/firmware/efi/efi-stub-helper.c"
-
 static void find_bits(unsigned long mask, u8 *pos, u8 *size)
 {
        u8 first, len;
index 588dc47e7075589d99c409d51516c8289b293896..f712d47f30d8a778b9c37a3c138c1f5850e7268f 100644 (file)
@@ -57,6 +57,9 @@ config EFI_PARAMS_FROM_FDT
 config EFI_RUNTIME_WRAPPERS
        bool
 
+config EFI_ARMSTUB
+       bool
+
 endmenu
 
 config UEFI_CPER
index e1096539eedbf83c080c2950252b7d84efa64ef4..a204d1474cec130cdc2c6a93fc25566fa28cb43b 100644 (file)
@@ -7,3 +7,4 @@ obj-$(CONFIG_EFI_VARS_PSTORE)           += efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)                        += cper.o
 obj-$(CONFIG_EFI_RUNTIME_MAP)          += runtime-map.o
 obj-$(CONFIG_EFI_RUNTIME_WRAPPERS)     += runtime-wrappers.o
+obj-$(CONFIG_EFI_STUB)                 += libstub/
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
new file mode 100644 (file)
index 0000000..b14bc2b
--- /dev/null
@@ -0,0 +1,26 @@
+#
+# The stub may be linked into the kernel proper or into a separate boot binary,
+# but in either case, it executes before the kernel does (with MMU disabled) so
+# things like ftrace and stack-protector are likely to cause trouble if left
+# enabled, even if doing so doesn't break the build.
+#
+cflags-$(CONFIG_X86_32)                := -march=i386
+cflags-$(CONFIG_X86_64)                := -mcmodel=small
+cflags-$(CONFIG_X86)           += -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
+                                  -fPIC -fno-strict-aliasing -mno-red-zone \
+                                  -mno-mmx -mno-sse -DDISABLE_BRANCH_PROFILING
+
+cflags-$(CONFIG_ARM64)         := $(subst -pg,,$(KBUILD_CFLAGS))
+cflags-$(CONFIG_ARM)           := $(subst -pg,,$(KBUILD_CFLAGS)) \
+                                  -fno-builtin -fpic -mno-single-pic-base
+
+KBUILD_CFLAGS                  := $(cflags-y) \
+                                  $(call cc-option,-ffreestanding) \
+                                  $(call cc-option,-fno-stack-protector)
+
+GCOV_PROFILE                   := n
+
+lib-y                          := efi-stub-helper.o
+lib-$(CONFIG_EFI_ARMSTUB)      += arm-stub.o fdt.o
+
+CFLAGS_fdt.o                   += -I$(srctree)/scripts/dtc/libfdt/