aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2014-07-02 08:54:43 -0400
committerMatt Fleming <matt.fleming@intel.com>2014-07-18 16:22:19 -0400
commitf4f75ad5741fe0331bbe1f5c42b906cda299f26b (patch)
tree0f06f0b7ecc94bc930a952dd79763adc94b34fda
parentbd669475d14e3279a7f96ed917a82df5da6ad52d (diff)
efi: efistub: Convert into static library
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>
-rw-r--r--arch/arm64/Kconfig5
-rw-r--r--arch/arm64/Makefile1
-rw-r--r--arch/arm64/kernel/Makefile3
-rw-r--r--arch/arm64/kernel/efi-stub.c6
-rw-r--r--arch/x86/boot/compressed/Makefile3
-rw-r--r--arch/x86/boot/compressed/eboot.c2
-rw-r--r--drivers/firmware/efi/Kconfig3
-rw-r--r--drivers/firmware/efi/Makefile1
-rw-r--r--drivers/firmware/efi/libstub/Makefile26
-rw-r--r--drivers/firmware/efi/libstub/arm-stub.c (renamed from drivers/firmware/efi/arm-stub.c)0
-rw-r--r--drivers/firmware/efi/libstub/efi-stub-helper.c (renamed from drivers/firmware/efi/efi-stub-helper.c)0
-rw-r--r--drivers/firmware/efi/libstub/efistub.h (renamed from drivers/firmware/efi/efistub.h)0
-rw-r--r--drivers/firmware/efi/libstub/fdt.c (renamed from drivers/firmware/efi/fdt.c)0
13 files changed, 39 insertions, 11 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 2cc14cef01bd..3a0a4ce4c751 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -292,6 +292,9 @@ config CMDLINE_FORCE
292 This is useful if you cannot or don't want to change the 292 This is useful if you cannot or don't want to change the
293 command-line options your boot loader passes to the kernel. 293 command-line options your boot loader passes to the kernel.
294 294
295config EFI_STUB
296 bool
297
295config EFI 298config EFI
296 bool "UEFI runtime support" 299 bool "UEFI runtime support"
297 depends on OF && !CPU_BIG_ENDIAN 300 depends on OF && !CPU_BIG_ENDIAN
@@ -299,6 +302,8 @@ config EFI
299 select UCS2_STRING 302 select UCS2_STRING
300 select EFI_PARAMS_FROM_FDT 303 select EFI_PARAMS_FROM_FDT
301 select EFI_RUNTIME_WRAPPERS 304 select EFI_RUNTIME_WRAPPERS
305 select EFI_STUB
306 select EFI_ARMSTUB
302 default y 307 default y
303 help 308 help
304 This option provides support for runtime services provided 309 This option provides support for runtime services provided
diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile
index 8185a913c5ed..5836717d2f66 100644
--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -48,6 +48,7 @@ core-$(CONFIG_XEN) += arch/arm64/xen/
48core-$(CONFIG_CRYPTO) += arch/arm64/crypto/ 48core-$(CONFIG_CRYPTO) += arch/arm64/crypto/
49libs-y := arch/arm64/lib/ $(libs-y) 49libs-y := arch/arm64/lib/ $(libs-y)
50libs-y += $(LIBGCC) 50libs-y += $(LIBGCC)
51libs-$(CONFIG_EFI_STUB) += drivers/firmware/efi/libstub/
51 52
52# Default target when executing plain make 53# Default target when executing plain make
53KBUILD_IMAGE := Image.gz 54KBUILD_IMAGE := Image.gz
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index cdaedad3afe5..afaeb734295a 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -4,8 +4,7 @@
4 4
5CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET) 5CPPFLAGS_vmlinux.lds := -DTEXT_OFFSET=$(TEXT_OFFSET)
6AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 6AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
7CFLAGS_efi-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) \ 7CFLAGS_efi-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
8 -I$(src)/../../../scripts/dtc/libfdt
9 8
10CFLAGS_REMOVE_ftrace.o = -pg 9CFLAGS_REMOVE_ftrace.o = -pg
11CFLAGS_REMOVE_insn.o = -pg 10CFLAGS_REMOVE_insn.o = -pg
diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c
index e4999021b07d..1317fef8dde9 100644
--- a/arch/arm64/kernel/efi-stub.c
+++ b/arch/arm64/kernel/efi-stub.c
@@ -13,12 +13,6 @@
13#include <asm/efi.h> 13#include <asm/efi.h>
14#include <asm/sections.h> 14#include <asm/sections.h>
15 15
16/* Include shared EFI stub code */
17#include "../../../drivers/firmware/efi/efi-stub-helper.c"
18#include "../../../drivers/firmware/efi/fdt.c"
19#include "../../../drivers/firmware/efi/arm-stub.c"
20
21
22efi_status_t handle_kernel_image(efi_system_table_t *sys_table, 16efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
23 unsigned long *image_addr, 17 unsigned long *image_addr,
24 unsigned long *image_size, 18 unsigned long *image_size,
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index 0fcd9133790c..7a801a310e37 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -33,7 +33,8 @@ VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
33$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone 33$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
34 34
35ifeq ($(CONFIG_EFI_STUB), y) 35ifeq ($(CONFIG_EFI_STUB), y)
36 VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o 36 VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \
37 $(objtree)/drivers/firmware/efi/libstub/lib.a
37endif 38endif
38 39
39$(obj)/vmlinux: $(VMLINUX_OBJS) FORCE 40$(obj)/vmlinux: $(VMLINUX_OBJS) FORCE
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 916bbdd7dd28..3b5c66c8f749 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -280,8 +280,6 @@ void efi_char16_printk(efi_system_table_t *table, efi_char16_t *str)
280 } 280 }
281} 281}
282 282
283#include "../../../../drivers/firmware/efi/efi-stub-helper.c"
284
285static void find_bits(unsigned long mask, u8 *pos, u8 *size) 283static void find_bits(unsigned long mask, u8 *pos, u8 *size)
286{ 284{
287 u8 first, len; 285 u8 first, len;
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index 588dc47e7075..f712d47f30d8 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -57,6 +57,9 @@ config EFI_PARAMS_FROM_FDT
57config EFI_RUNTIME_WRAPPERS 57config EFI_RUNTIME_WRAPPERS
58 bool 58 bool
59 59
60config EFI_ARMSTUB
61 bool
62
60endmenu 63endmenu
61 64
62config UEFI_CPER 65config UEFI_CPER
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile
index e1096539eedb..a204d1474cec 100644
--- a/drivers/firmware/efi/Makefile
+++ b/drivers/firmware/efi/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_EFI_VARS_PSTORE) += efi-pstore.o
7obj-$(CONFIG_UEFI_CPER) += cper.o 7obj-$(CONFIG_UEFI_CPER) += cper.o
8obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o 8obj-$(CONFIG_EFI_RUNTIME_MAP) += runtime-map.o
9obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o 9obj-$(CONFIG_EFI_RUNTIME_WRAPPERS) += runtime-wrappers.o
10obj-$(CONFIG_EFI_STUB) += libstub/
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
new file mode 100644
index 000000000000..b14bc2b9fb4d
--- /dev/null
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -0,0 +1,26 @@
1#
2# The stub may be linked into the kernel proper or into a separate boot binary,
3# but in either case, it executes before the kernel does (with MMU disabled) so
4# things like ftrace and stack-protector are likely to cause trouble if left
5# enabled, even if doing so doesn't break the build.
6#
7cflags-$(CONFIG_X86_32) := -march=i386
8cflags-$(CONFIG_X86_64) := -mcmodel=small
9cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
10 -fPIC -fno-strict-aliasing -mno-red-zone \
11 -mno-mmx -mno-sse -DDISABLE_BRANCH_PROFILING
12
13cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS))
14cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \
15 -fno-builtin -fpic -mno-single-pic-base
16
17KBUILD_CFLAGS := $(cflags-y) \
18 $(call cc-option,-ffreestanding) \
19 $(call cc-option,-fno-stack-protector)
20
21GCOV_PROFILE := n
22
23lib-y := efi-stub-helper.o
24lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o
25
26CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
diff --git a/drivers/firmware/efi/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 480339b6b110..480339b6b110 100644
--- a/drivers/firmware/efi/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
diff --git a/drivers/firmware/efi/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 32d5cca30f49..32d5cca30f49 100644
--- a/drivers/firmware/efi/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
diff --git a/drivers/firmware/efi/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 304ab295ca1a..304ab295ca1a 100644
--- a/drivers/firmware/efi/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
diff --git a/drivers/firmware/efi/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 86d2934840e2..86d2934840e2 100644
--- a/drivers/firmware/efi/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c