Skip to contentSkip to conversation

arm64/efi changes for v3.16

GIT PULL H. Peter Anvin 1 participant 1 message Jun 5, 2014

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Hi Linus,

By agreement with the ARM64 EFI maintainers, we have agreed to make -tip the upstream for all EFI patches. That is why this patchset comes from me :)

This patchset enables EFI stub support for ARM64, like we already have on x86.

The following changes since commit e33655a386ed3b26ad36fb97a47ebb1c2ca1e928:

efivars: Add compatibility code for compat tasks (2014-04-17 13:53:53 +0100)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git arm64-efi-for-linus

for you to fetch changes up to 74bcc2499291d38b6253f9dbd6af33a195222208:

arm64: efi: only attempt efi map setup if booting via EFI (2014-05-23 15:29:43 +0100)

----------------------------------------------------------------
Ard Biesheuvel (1):
efi/arm64: ignore dtb= when UEFI SecureBoot is enabled

Leif Lindholm (2):
doc: arm: add UEFI support documentation
arm64: efi: only attempt efi map setup if booting via EFI

Mark Salter (6):
lib: add fdt_empty_tree.c
efi: add helper function to get UEFI params from FDT
arm64: Add function to create identity mappings
arm64: add EFI runtime services
arm64: efi: add EFI stub
doc: arm64: add description of EFI stub support

Roy Franz (2):
doc: efi-stub.txt updates for ARM
efi: Add shared FDT related functions for ARM/ARM64

 Documentation/arm/00-INDEX      |   2 +
 Documentation/arm/uefi.txt      |  64 ++++++
 Documentation/arm64/booting.txt |   4 +
 Documentation/efi-stub.txt      |  33 ++-
 arch/arm64/Kconfig              |  16 ++
 arch/arm64/include/asm/efi.h    |  14 ++
 arch/arm64/include/asm/mmu.h    |   2 +
 arch/arm64/kernel/Makefile      |   3 +
 arch/arm64/kernel/efi-entry.S   | 109 ++++++++++
 arch/arm64/kernel/efi-stub.c    |  81 +++++++
 arch/arm64/kernel/efi.c         | 469 ++++++++++++++++++++++++++++++++++++++++
 arch/arm64/kernel/head.S        | 112 ++++++++++
 arch/arm64/kernel/setup.c       |   5 +
 arch/arm64/mm/mmu.c             |  65 ++++--
 drivers/firmware/efi/Kconfig    |   7 +
 drivers/firmware/efi/arm-stub.c | 278 ++++++++++++++++++++++++
 drivers/firmware/efi/efi.c      |  79 +++++++
 drivers/firmware/efi/fdt.c      | 285 ++++++++++++++++++++++++
 include/linux/efi.h             |  12 +
 lib/Makefile                    |   3 +-
 lib/fdt_empty_tree.c            |   2 +
 21 files changed, 1619 insertions(+), 26 deletions(-)
 create mode 100644 Documentation/arm/uefi.txt
 create mode 100644 arch/arm64/include/asm/efi.h
 create mode 100644 arch/arm64/kernel/efi-entry.S
 create mode 100644 arch/arm64/kernel/efi-stub.c
 create mode 100644 arch/arm64/kernel/efi.c
 create mode 100644 drivers/firmware/efi/arm-stub.c
 create mode 100644 drivers/firmware/efi/fdt.c
 create mode 100644 lib/fdt_empty_tree.c
Documentation/arm/00-INDEX +2 -0
index a94090cc785d..3b08bc2b04cf 100644
@@ -46,5 +46,7 @@ swp_emulation
 	- SWP/SWPB emulation handler/logging description
 tcm.txt
 	- ARM Tightly Coupled Memory
+uefi.txt
+	- [U]EFI configuration and runtime services documentation
 vlocks.txt
 	- Voting locks, low-level mechanism relying on memory system atomic writes.
Documentation/arm/uefi.txt new file +64 -0

64 lines not on this page · raw message

Documentation/arm64/booting.txt +4 -0
index beb754e87c65..37fc4f632176 100644
@@ -85,6 +85,10 @@ The decompressed kernel image contains a 64-byte header as follows:
 Header notes:
 
 - code0/code1 are responsible for branching to stext.
+- when booting through EFI, code0/code1 are initially skipped.
+  res5 is an offset to the PE header and the PE header has the EFI
+  entry point (efi_stub_entry). When the stub has done its work, it
+  jumps to code0 to resume the normal boot process.
 
 The image must be placed at the specified offset (currently 0x80000)
 from the start of the system RAM and called there. The start of the
Documentation/efi-stub.txt +26 -7
index c628788d5b47..7747024d3bb7 100644
@@ -1,13 +1,21 @@
 			  The EFI Boot Stub
 		     ---------------------------
 
-On the x86 platform, a bzImage can masquerade as a PE/COFF image,
-thereby convincing EFI firmware loaders to load it as an EFI
-executable. The code that modifies the bzImage header, along with the
-EFI-specific entry point that the firmware loader jumps to are
-collectively known as the "EFI boot stub", and live in
+On the x86 and ARM platforms, a kernel zImage/bzImage can masquerade
+as a PE/COFF image, thereby convincing EFI firmware loaders to load
+it as an EFI executable. The code that modifies the bzImage header,
+along with the EFI-specific entry point that the firmware loader
+jumps to are collectively known as the "EFI boot stub", and live in
 arch/x86/boot/header.S and arch/x86/boot/compressed/eboot.c,
-respectively.
+respectively. For ARM the EFI stub is implemented in
+arch/arm/boot/compressed/efi-header.S and
+arch/arm/boot/compressed/efi-stub.c. EFI stub code that is shared
+between architectures is in drivers/firmware/efi/efi-stub-helper.c.
+
+For arm64, there is no compressed kernel support, so the Image itself
+masquerades as a PE/COFF image and the EFI stub is linked into the
+kernel. The arm64 EFI stub lives in arch/arm64/kernel/efi-entry.S
+and arch/arm64/kernel/efi-stub.c.
 
 By using the EFI boot stub it's possible to boot a Linux kernel
 without the use of a conventional EFI boot loader, such as grub or
@@ -23,7 +31,10 @@ The bzImage located in arch/x86/boot/bzImage must be copied to the EFI
 System Partition (ESP) and renamed with the extension ".efi". Without
 the extension the EFI firmware loader will refuse to execute it. It's
 not possible to execute bzImage.efi from the usual Linux file systems
-because EFI firmware doesn't have support for them.
+because EFI firmware doesn't have support for them. For ARM the
+arch/arm/boot/zImage should be copied to the system partition, and it
+may not need to be renamed. Similarly for arm64, arch/arm64/boot/Image
+should be copied but not necessarily renamed.
 
 
 **** Passing kernel parameters from the EFI shell
@@ -63,3 +74,11 @@ Notice how bzImage.efi can be specified with a relative path. That's
 because the image we're executing is interpreted by the EFI shell,
 which understands relative paths, whereas the rest of the command line
 is passed to bzImage.efi.
+
+
+**** The "dtb=" option
+
+For the ARM and arm64 architectures, we also need to be able to provide a
+device tree to the kernel. This is done with the "dtb=" command line option,
+and is processed in the same manner as the "initrd=" option that is
+described above.
arch/arm64/Kconfig +16 -0
index e6e4d3749a6e..6c71f122638d 100644
@@ -280,6 +280,20 @@ 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
+	bool "UEFI runtime support"
+	depends on OF && !CPU_BIG_ENDIAN
+	select LIBFDT
+	select UCS2_STRING
+	select EFI_PARAMS_FROM_FDT
+	default y
+	help
+	  This option provides support for runtime services provided
+	  by UEFI firmware (such as non-volatile variables, realtime
+          clock, and platform reset). A UEFI stub is also provided to
+	  allow the kernel to be booted as an EFI application. This
+	  is only useful on systems that have UEFI firmware.
+
 endmenu
 
 menu "Userspace binary formats"
@@ -333,6 +347,8 @@ source "net/Kconfig"
 
 source "drivers/Kconfig"
 
+source "drivers/firmware/Kconfig"
+
 source "fs/Kconfig"
 
 source "arch/arm64/kvm/Kconfig"
arch/arm64/include/asm/efi.h new file +14 -0
new file mode 100644
index 000000000000..5a46c4e7f539
@@ -0,0 +1,14 @@
+#ifndef _ASM_EFI_H
+#define _ASM_EFI_H
+
+#include <asm/io.h>
+
+#ifdef CONFIG_EFI
+extern void efi_init(void);
+extern void efi_idmap_init(void);
+#else
+#define efi_init()
+#define efi_idmap_init()
+#endif
+
+#endif /* _ASM_EFI_H */
arch/arm64/include/asm/mmu.h +2 -0
index f600d400c07d..29ed1d865e13 100644
@@ -28,5 +28,7 @@ extern void paging_init(void);
 extern void setup_mm_for_reboot(void);
 extern void __iomem *early_io_map(phys_addr_t phys, unsigned long virt);
 extern void init_mem_pgprot(void);
+/* create an identity mapping for memory (or io if map_io is true) */
+extern void create_id_mapping(phys_addr_t addr, phys_addr_t size, int map_io);
 
 #endif
arch/arm64/kernel/Makefile +3 -0
index 7d811d9522bc..db63a0a25810 100644
@@ -4,6 +4,8 @@
 
 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
 
 # Object file lists.
 arm64-obj-y		:= cputable.o debug-monitors.o entry.o irq.o fpsimd.o	\
@@ -22,6 +24,7 @@ arm64-obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND)	+= sleep.o suspend.o
 arm64-obj-$(CONFIG_JUMP_LABEL)		+= jump_label.o
 arm64-obj-$(CONFIG_KGDB)		+= kgdb.o
+arm64-obj-$(CONFIG_EFI)			+= efi.o efi-stub.o efi-entry.o
 
 obj-y					+= $(arm64-obj-y) vdso/
 obj-m					+= $(arm64-obj-m)
arch/arm64/kernel/efi-entry.S new file +109 -0

109 lines not on this page · raw message

arch/arm64/kernel/efi-stub.c new file +81 -0

81 lines not on this page · raw message

arch/arm64/kernel/efi.c new file +469 -0

469 lines not on this page · raw message

arch/arm64/kernel/head.S +112 -0

127 lines not on this page · raw message

arch/arm64/kernel/setup.c +5 -0
index 720853f70b6b..0a14aaffc834 100644
@@ -41,6 +41,7 @@
 #include <linux/memblock.h>
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
+#include <linux/efi.h>
 
 #include <asm/fixmap.h>
 #include <asm/cputype.h>
@@ -55,6 +56,7 @@
 #include <asm/traps.h>
 #include <asm/memblock.h>
 #include <asm/psci.h>
+#include <asm/efi.h>
 
 unsigned int processor_id;
 EXPORT_SYMBOL(processor_id);
@@ -366,11 +368,14 @@ void __init setup_arch(char **cmdline_p)
 
 	parse_early_param();
 
+	efi_init();
 	arm64_memblock_init();
 
 	paging_init();
 	request_standard_resources();
 
+	efi_idmap_init();
+
 	unflatten_device_tree();
 
 	psci_init();
arch/arm64/mm/mmu.c +47 -18

128 lines not on this page · raw message

drivers/firmware/efi/Kconfig +7 -0
index 1e75f48b61f8..d420ae2d3413 100644
@@ -47,6 +47,13 @@ config EFI_RUNTIME_MAP
 
 	  See also Documentation/ABI/testing/sysfs-firmware-efi-runtime-map.
 
+config EFI_PARAMS_FROM_FDT
+	bool
+	help
+	  Select this config option from the architecture Kconfig if
+	  the EFI runtime support gets system table address, memory
+          map address, and other parameters from the device tree.
+
 endmenu
 
 config UEFI_CPER
drivers/firmware/efi/arm-stub.c new file +278 -0

278 lines not on this page · raw message

drivers/firmware/efi/efi.c +79 -0

88 lines not on this page · raw message

drivers/firmware/efi/fdt.c new file +285 -0

285 lines not on this page · raw message

include/linux/efi.h +12 -0
index 6a4d8e27d1d7..41bbf8ba4ba8 100644
@@ -575,6 +575,9 @@ typedef efi_status_t efi_query_variable_store_t(u32 attributes, unsigned long si
 #define EFI_FILE_SYSTEM_GUID \
     EFI_GUID(  0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b )
 
+#define DEVICE_TREE_GUID \
+    EFI_GUID(  0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 )
+
 typedef struct {
 	efi_guid_t guid;
 	u64 table;
@@ -664,6 +667,14 @@ struct efi_memory_map {
 	unsigned long desc_size;
 };
 
+struct efi_fdt_params {
+	u64 system_table;
+	u64 mmap;
+	u32 mmap_size;
+	u32 desc_size;
+	u32 desc_ver;
+};
+
 typedef struct {
 	u32 revision;
 	u32 parent_handle;
@@ -861,6 +872,7 @@ extern void efi_initialize_iomem_resources(struct resource *code_resource,
 extern void efi_get_time(struct timespec *now);
 extern int efi_set_rtc_mmss(const struct timespec *now);
 extern void efi_reserve_boot_services(void);
+extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose);
 extern struct efi_memory_map memmap;
 
 /* Iterate through an efi_memory_map */
lib/Makefile +2 -1
index 0cd7b68e1382..74a32dc49a93 100644
@@ -148,7 +148,8 @@ obj-$(CONFIG_GENERIC_NET_UTILS) += net_utils.o
 
 obj-$(CONFIG_STMP_DEVICE) += stmp_device.o
 
-libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o
+libfdt_files = fdt.o fdt_ro.o fdt_wip.o fdt_rw.o fdt_sw.o fdt_strerror.o \
+	       fdt_empty_tree.o
 $(foreach file, $(libfdt_files), \
 	$(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
 lib-$(CONFIG_LIBFDT) += $(libfdt_files)
lib/fdt_empty_tree.c new file +2 -0
new file mode 100644
index 000000000000..5d30c58150ad
@@ -0,0 +1,2 @@
+#include <linux/libfdt_env.h>
+#include "../scripts/dtc/libfdt/fdt_empty_tree.c"