EFI changes for v3.17
Subsystems (5)
Linus,
Please pull the latest x86-efi-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-efi-for-linus
# HEAD: 99a5603e2a1f146ac0c6414d8a3669aa749ccff8 efi/arm64: Handle missing virtual mapping for UEFI System Table
Main changes in this cycle are:
* arm64 efi stub fixes, preservation of FP/SIMD registers across firmware calls, and conversion of the EFI stub code into a static library - Ard Biesheuvel
* Xen EFI support - Daniel Kiper
* Support for autoloading the efivars driver - Lee, Chun-Yi
* Use the PE/COFF headers in the x86 EFI boot stub to request that the stub be loaded with CONFIG_PHYSICAL_ALIGN alignment - Michael Brown
* Consolidate all the x86 EFI quirks into one file - Saurabh Tangri
* Additional error logging in x86 EFI boot stub - Ulf Winkelvos
* Support loading initrd above 4G in EFI boot stub - Yinghai Lu
* EFI reboot patches for ACPI hardware reduced platforms
out-of-topic modifications in x86-efi-for-linus:
--------------------------------------------------
arch/arm64/Kconfig # f4f75ad: efi: efistub: Convert into static
# e15dd49: efi/arm64: Preserve FP/SIMD regis
arch/arm64/Makefile # f4f75ad: efi: efistub: Convert into static
arch/arm64/include/asm/efi.h # a13b007: efi/arm64: efistub: Move shared d
# e15dd49: efi/arm64: Preserve FP/SIMD regis
arch/arm64/kernel/Makefile # f4f75ad: efi: efistub: Convert into static
arch/arm64/kernel/efi-stub.c # f4f75ad: efi: efistub: Convert into static
# bd66947: efi: efistub: Refactor stub compo
# a13b007: efi/arm64: efistub: Move shared d
# 6091c9c: efi/arm64: Avoid EFI_ERROR as a g
# f49182ec: efi/arm64: efistub: remove local
arch/arm64/kernel/efi.c # 99a5603: efi/arm64: Handle missing virtual
# e15dd49: efi/arm64: Preserve FP/SIMD regis
arch/ia64/include/asm/io.h # 4fa6248: arch/ia64: Define early_memunmap(
arch/ia64/kernel/process.c # 8562c99: efi/reboot: Add generic wrapper a
drivers/firmware/efi/Kconfig # f4f75ad: efi: efistub: Convert into static # 022ee6c: efi/x86: Move UEFI Runtime Servic
drivers/firmware/efi/Makefile # 8562c99: efi/reboot: Add generic wrapper a
# f4f75ad: efi: efistub: Convert into static # 022ee6c: efi/x86: Move UEFI Runtime Servic
drivers/firmware/efi/arm-stub.c # f4f75ad: efi: efistub: Convert into static
# bd66947: efi: efistub: Refactor stub compo
drivers/firmware/efi/efi-stub-helper.c# f4f75ad: efi: efistub: Convert into static
# bd66947: efi: efistub: Refactor stub compo
drivers/firmware/efi/efi.c # 28d5402: efi: Autoload efivars
# 9f27bc5: efi: Introduce EFI_PARAVIRT flag # abc93f8: efi: Use early_mem*() instead of
drivers/firmware/efi/efivars.c # 28d5402: efi: Autoload efivars
drivers/firmware/efi/fdt.c # f4f75ad: efi: efistub: Convert into static
# bd66947: efi: efistub: Refactor stub compo # f49182ec: efi/arm64: efistub: remove local
drivers/firmware/efi/libstub/Makefile# f4f75ad: efi: efistub: Convert into static drivers/firmware/efi/libstub/arm-stub.c# f4f75ad: efi: efistub: Convert into static drivers/firmware/efi/libstub/efi-stub-helper.c# f4f75ad: efi: efistub: Convert into static drivers/firmware/efi/libstub/efistub.h# f4f75ad: efi: efistub: Convert into static drivers/firmware/efi/libstub/fdt.c # f4f75ad: efi: efistub: Convert into static
drivers/firmware/efi/reboot.c # 44be28e: x86/reboot: Add EFI reboot quirk
# 0c5ed61: efi/reboot: Allow powering off ma # 8562c99: efi/reboot: Add generic wrapper a
drivers/firmware/efi/runtime-wrappers.c# 022ee6c: efi/x86: Move UEFI Runtime Servic
Thanks,
Ingo
------------------>
Ard Biesheuvel (9):
efi/arm64: efistub: remove local copy of linux_banner efi/x86: Move UEFI Runtime Services wrappers to generic code efi/arm64: Preserve FP/SIMD registers on UEFI runtime services calls efi/arm64: Avoid EFI_ERROR as a generic return code efi/x86: efistub: Move shared dependencies to <asm/efi.h> efi/arm64: efistub: Move shared dependencies to <asm/efi.h>
efi: efistub: Refactor stub components
efi: efistub: Convert into static library
efi/arm64: Handle missing virtual mapping for UEFI System Table
Daniel Kiper (12):
arch/ia64: Define early_memunmap()
efi: Use early_mem*() instead of early_io*() arch/x86: Do not access EFI memory map if it is not available
efi: Introduce EFI_PARAVIRT flag
arch/x86: Remove redundant set_bit(EFI_SYSTEM_TABLES) call arch/x86: Remove redundant set_bit(EFI_MEMMAP) call
xen: Define EFI related stuff
xen: Put EFI machinery in place
arch/x86: Replace plain strings with constants arch/x86: Remove efi_set_rtc_mmss()
xen: Silence compiler warnings
arch/x86/xen: Silence compiler warnings
Lee, Chun-Yi (1):
efi: Autoload efivars
Matt Fleming (5):
x86/efi: Use early_memunmap() to squelch sparse errors efi/reboot: Add generic wrapper around EfiResetSystem() efi/reboot: Allow powering off machines using EFI x86/reboot: Add EFI reboot quirk for ACPI Hardware Reduced flag
efi: Update stale locking comment for struct efivars
Michael Brown (1):
x86/efi: Request desired alignment via the PE/COFF headers
Saurabh Tangri (1):
x86/efi: Move all workarounds to a separate file quirks.c
Ulf Winkelvos (1):
x86/efi: Add better error logging to EFI boot stub
Yinghai Lu (1):
x86/efi: Support initrd loaded above 4G
arch/arm64/Kconfig | 6 +
arch/arm64/Makefile | 1 +
arch/arm64/include/asm/efi.h | 33 ++
arch/arm64/kernel/Makefile | 3 +-
arch/arm64/kernel/efi-stub.c | 50 +--
arch/arm64/kernel/efi.c | 42 +-
arch/ia64/include/asm/io.h | 1 +
arch/ia64/kernel/process.c | 2 +-
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 3 +-
arch/x86/boot/compressed/eboot.c | 48 +-
arch/x86/boot/compressed/eboot.h | 16 -
arch/x86/boot/header.S | 2 +-
arch/x86/include/asm/efi.h | 33 ++
arch/x86/kernel/reboot.c | 24 +-
arch/x86/kernel/setup.c | 4 +-
arch/x86/platform/efi/Makefile | 2 +-
arch/x86/platform/efi/efi.c | 483 ++-------------------
arch/x86/platform/efi/quirks.c | 290 +++++++++++++
arch/x86/xen/Makefile | 1 +
arch/x86/xen/efi.c | 43 ++
arch/x86/xen/enlighten.c | 2 +
arch/x86/xen/xen-ops.h | 8 +
drivers/firmware/efi/Kconfig | 6 +
drivers/firmware/efi/Makefile | 4 +-
drivers/firmware/efi/efi.c | 40 +-
drivers/firmware/efi/efivars.c | 1 +
drivers/firmware/efi/libstub/Makefile | 26 ++
drivers/firmware/efi/{ => libstub}/arm-stub.c | 32 +-
.../firmware/efi/{ => libstub}/efi-stub-helper.c | 74 ++--
drivers/firmware/efi/libstub/efistub.h | 42 ++
drivers/firmware/efi/{ => libstub}/fdt.c | 30 +-
drivers/firmware/efi/reboot.c | 56 +++
drivers/firmware/efi/runtime-wrappers.c | 161 +++++++
drivers/xen/Kconfig | 4 +
drivers/xen/Makefile | 3 +
drivers/xen/efi.c | 368 ++++++++++++++++
include/linux/efi.h | 63 ++-
include/xen/interface/platform.h | 123 ++++++
include/xen/xen-ops.h | 11 +
40 files changed, 1508 insertions(+), 634 deletions(-)
create mode 100644 arch/x86/platform/efi/quirks.c
create mode 100644 arch/x86/xen/efi.c
create mode 100644 drivers/firmware/efi/libstub/Makefile
rename drivers/firmware/efi/{ => libstub}/arm-stub.c (93%)
rename drivers/firmware/efi/{ => libstub}/efi-stub-helper.c (88%)
create mode 100644 drivers/firmware/efi/libstub/efistub.h
rename drivers/firmware/efi/{ => libstub}/fdt.c (90%)
create mode 100644 drivers/firmware/efi/reboot.c
create mode 100644 drivers/firmware/efi/runtime-wrappers.c
create mode 100644 drivers/xen/efi.carch/arm64/Kconfig +6 -0
@@ -292,12 +292,18 @@ 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 select LIBFDT 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
arch/arm64/Makefile +1 -0
@@ -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
arch/arm64/include/asm/efi.h +33 -0
@@ -2,6 +2,7 @@#define _ASM_EFI_H#include <asm/io.h> +#include <asm/neon.h> #ifdef CONFIG_EFI extern void efi_init (void );
@@ -11,4 +12,36 @@ extern void efi_idmap_init(void);#define efi_idmap_init ()#endif +#define efi_call_virt (f, ...) \ +({ \ + efi_##f##_t *__f = efi.systab->runtime->f; \ + efi_status_t __s; \ + \ + kernel_neon_begin(); \ + __s = __f(__VA_ARGS__); \ + kernel_neon_end(); \ + __s; \ +}) + +#define __efi_call_virt (f, ...) \ +({ \ + efi_##f##_t *__f = efi.systab->runtime->f; \ + \ + kernel_neon_begin(); \ + __f(__VA_ARGS__); \ + kernel_neon_end(); \ +}) + +/* arch specific definitions used by the stub code */ + +/* +* AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from +* start of kernel and may not cross a 2MiB boundary. We set alignment to +* 2MiB so we know it won't cross a 2MiB boundary. +*/ +#define EFI_FDT_ALIGN SZ_2M/* used by allocate_new_fdt_and_exit_boot() */ +#define MAX_FDT_OFFSET SZ_512M + +#define efi_call_early (f, ...) sys_table_arg->boottime->f(__VA_ARGS__) +#endif /* _ASM_EFI_H */
arch/arm64/kernel/Makefile +1 -2
@@ -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
arch/arm64/kernel/efi-stub.c +9 -41
64 lines not on this page · raw message
arch/arm64/kernel/efi.c +25 -17
59 lines not on this page · raw message
arch/ia64/include/asm/io.h +1 -0
@@ -426,6 +426,7 @@ extern void iounmap (volatile void __iomem *addr);extern void __iomem *early_ioremap (unsigned long phys_addr,unsigned long size);#define early_memremap (phys_addr, size) early_ioremap(phys_addr, size)extern void early_iounmap (volatile void __iomem *addr,unsigned long size); +#define early_memunmap (addr, size) early_iounmap(addr, size)static inline void __iomem *ioremap_cache (unsigned long phys_addr,unsigned long size) {return ioremap (phys_addr, size);
arch/ia64/kernel/process.c +1 -1
@@ -662,7 +662,7 @@ void machine_restart (char *restart_cmd) { (void )notify_die (DIE_MACHINE_RESTART , restart_cmd,NULL ,0 ,0 ,0 ); - (*efi.reset_system)(EFI_RESET_WARM ,0 ,0 ,NULL ); +efi_reboot (REBOOT_WARM ,NULL ); }void
arch/x86/Kconfig +1 -0
@@ -1522,6 +1522,7 @@ config EFI bool "EFI runtime service support" depends on ACPI select UCS2_STRING + select EFI_RUNTIME_WRAPPERS ---help--- This enables the kernel to use EFI runtime services that are available (such as the EFI variable services).
arch/x86/boot/compressed/Makefile +2 -1
@@ -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
arch/x86/boot/compressed/eboot.c +29 -19
138 lines not on this page · raw message
arch/x86/boot/compressed/eboot.h +0 -16
@@ -103,20 +103,4 @@ struct efi_uga_draw_protocol { void *blt; }; -struct efi_config { -u64 image_handle; -u64 table; -u64 allocate_pool; -u64 allocate_pages; -u64 get_memory_map; -u64 free_pool; -u64 free_pages; -u64 locate_handle; -u64 handle_protocol; -u64 exit_boot_services; -u64 text_output; -efi_status_t (*call)(unsigned long , ...); -bool is64; -} __packed; -#endif /* BOOT_COMPRESSED_EBOOT_H */
arch/x86/boot/header.S +1 -1
@@ -155,7 +155,7 @@ extra_header_fields: #else .quad 0 # ImageBase #endif - .long 0x20 # SectionAlignment + .long CONFIG_PHYSICAL_ALIGN # SectionAlignment .long 0x20 # FileAlignment .word 0 # MajorOperatingSystemVersion .word 0 # MinorOperatingSystemVersion
arch/x86/include/asm/efi.h +33 -0
@@ -104,6 +104,8 @@ extern void __init runtime_code_page_mkexec(void);extern void __init efi_runtime_mkexec (void );extern void __init efi_dump_pagetable (void );extern void __init efi_apply_memmap_quirks (void ); +extern int __init efi_reuse_config (u64 tables,int nr_tables); +extern void efi_delete_dummy_variable (void );struct efi_setup_data {u64 fw_vendor;
@@ -156,6 +158,33 @@ static inline efi_status_t efi_thunk_set_virtual_address_map( return EFI_SUCCESS; }#endif /* CONFIG_EFI_MIXED */ + + +/* arch specific definitions used by the stub code */ + +struct efi_config { +u64 image_handle; +u64 table; +u64 allocate_pool; +u64 allocate_pages; +u64 get_memory_map; +u64 free_pool; +u64 free_pages; +u64 locate_handle; +u64 handle_protocol; +u64 exit_boot_services; +u64 text_output; +efi_status_t (*call)(unsigned long , ...); +bool is64; +} __packed; + +extern struct efi_config *efi_early; + +#define efi_call_early (f, ...) \ + efi_early->call(efi_early->f, __VA_ARGS__); + +extern bool efi_reboot_required (void ); +#else /* * IF EFI is not configured, have the EFI calls return -ENOSYS.
@@ -168,6 +197,10 @@ static inline efi_status_t efi_thunk_set_virtual_address_map(#define efi_call5 (_f, _a1, _a2, _a3, _a4, _a5) (-ENOSYS)#define efi_call6 (_f, _a1, _a2, _a3, _a4, _a5, _a6) (-ENOSYS)static inline void parse_efi_setup (u64 phys_addr,u32 data_len) {} +static inline bool efi_reboot_required (void ) +{ +return false; +}#endif /* CONFIG_EFI */ #endif /* _ASM_X86_EFI_H */
arch/x86/kernel/reboot.c +17 -7
@@ -28,6 +28,7 @@#include <linux/mc146818rtc.h> #include <asm/realmode.h> #include <asm/x86_init.h> +#include <asm/efi.h> /* * Power off function, if any
@@ -401,12 +402,25 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {static int __init reboot_init (void ) { +int rv; +/* * Only do the DMI check if reboot_type hasn't been overridden * on the command line */ -if (reboot_default) -dmi_check_system (reboot_dmi_table); +if (!reboot_default) +return 0 ; + +/* +* The DMI quirks table takes precedence. If no quirks entry +* matches and the ACPI Hardware Reduced bit is set, force EFI +* reboot. +*/ + rv =dmi_check_system (reboot_dmi_table); + +if (!rv &&efi_reboot_required ()) + reboot_type =BOOT_EFI ; +return 0 ; }core_initcall (reboot_init);
@@ -528,11 +542,7 @@ static void native_machine_emergency_restart(void)break ;case BOOT_EFI : -if (efi_enabled (EFI_RUNTIME_SERVICES )) - efi.reset_system (reboot_mode ==REBOOT_WARM ? -EFI_RESET_WARM : -EFI_RESET_COLD , -EFI_SUCCESS ,0 ,NULL ); +efi_reboot (reboot_mode,NULL ); reboot_type =BOOT_BIOS ;break ;
arch/x86/kernel/setup.c +2 -2
@@ -924,10 +924,10 @@ void __init setup_arch(char **cmdline_p)#endif #ifdef CONFIG_EFI if (!strncmp ((char *)&boot_params.efi_info.efi_loader_signature, -"EL32" ,4 )) { +EFI32_LOADER_SIGNATURE ,4 )) {set_bit (EFI_BOOT , &efi.flags); }else if (!strncmp ((char *)&boot_params.efi_info.efi_loader_signature, -"EL64" ,4 )) { +EFI64_LOADER_SIGNATURE ,4 )) {set_bit (EFI_BOOT , &efi.flags);set_bit (EFI_64BIT , &efi.flags); }
arch/x86/platform/efi/Makefile +1 -1
@@ -1,4 +1,4 @@ -obj-$(CONFIG_EFI) += efi.o efi_$(BITS).o efi_stub_$(BITS).o +obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o
arch/x86/platform/efi/efi.c +46 -437
668 lines not on this page · raw message
arch/x86/platform/efi/quirks.c new file +290 -0
290 lines not on this page · raw message
arch/x86/xen/Makefile +1 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= spinlock.o obj-$(CONFIG_XEN_DEBUG_FS) += debugfs.o obj-$(CONFIG_XEN_DOM0) += apic.o vga.o obj-$(CONFIG_SWIOTLB_XEN) += pci-swiotlb-xen.o +obj-$(CONFIG_XEN_EFI) += efi.o
arch/x86/xen/efi.c new file +43 -0
43 lines not on this page · raw message
arch/x86/xen/enlighten.c +2 -0
@@ -1715,6 +1715,8 @@ asmlinkage __visible void __init xen_start_kernel(void)xen_setup_runstate_info (0 ); +xen_efi_init (); +/* Start the world */ #ifdef CONFIG_X86_32 i386_start_kernel ();
arch/x86/xen/xen-ops.h +8 -0
@@ -104,6 +104,14 @@ static inline void __init xen_init_apic(void) }#endif +#ifdef CONFIG_XEN_EFI +extern void xen_efi_init (void ); +#else +static inline void __init xen_efi_init (void ) +{ +} +#endif +/* Declare an asm function, along with symbols needed to make it inlineable */ #define DECL_ASM (ret, name, ...) \
drivers/firmware/efi/Kconfig +6 -0
@@ -54,6 +54,12 @@ config EFI_PARAMS_FROM_FDT the EFI runtime support gets system table address, memory map address, and other parameters from the device tree. +config EFI_RUNTIME_WRAPPERS + bool + +config EFI_ARMSTUB + bool + endmenu config UEFI_CPER
drivers/firmware/efi/Makefile +3 -1
@@ -1,8 +1,10 @@ # # Makefile for linux kernel # -obj-$(CONFIG_EFI) += efi.o vars.o +obj-$(CONFIG_EFI) += efi.o vars.o reboot.o obj-$(CONFIG_EFI_VARS) += efivars.o 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/
drivers/firmware/efi/efi.c +29 -11
@@ -23,6 +23,7 @@#include <linux/of.h> #include <linux/of_fdt.h> #include <linux/io.h> +#include <linux/platform_device.h> struct efi __read_mostly efi = { .mps =EFI_INVALID_TABLE_ADDR ,
@@ -104,16 +105,19 @@ static struct attribute *efi_subsys_attrs[] = {static umode_t efi_attr_is_visible (struct kobject *kobj,struct attribute *attr,int n) { -umode_t mode = attr->mode; - -if (attr == &efi_attr_fw_vendor.attr) -return (efi.fw_vendor ==EFI_INVALID_TABLE_ADDR ) ?0 : mode; -else if (attr == &efi_attr_runtime.attr) -return (efi.runtime ==EFI_INVALID_TABLE_ADDR ) ?0 : mode; -else if (attr == &efi_attr_config_table.attr) -return (efi.config_table ==EFI_INVALID_TABLE_ADDR ) ?0 : mode; +if (attr == &efi_attr_fw_vendor.attr) { +if (efi_enabled (EFI_PARAVIRT ) || + efi.fw_vendor ==EFI_INVALID_TABLE_ADDR ) +return 0 ; + }else if (attr == &efi_attr_runtime.attr) { +if (efi.runtime ==EFI_INVALID_TABLE_ADDR ) +return 0 ; + }else if (attr == &efi_attr_config_table.attr) { +if (efi.config_table ==EFI_INVALID_TABLE_ADDR ) +return 0 ; + } -return mode; +return attr->mode; }static struct attribute_group efi_subsys_attr_group = {
@@ -298,7 +302,7 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)if (table64 >>32 ) {pr_cont ("\n" );pr_err ("Table located above 4GB, disabling EFI.\n" ); -early_iounmap (config_tables, +early_memunmap (config_tables, efi.systab->nr_tables * sz);return -EINVAL ; }
@@ -314,13 +318,27 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables) tablep += sz; }pr_cont ("\n" ); -early_iounmap (config_tables, efi.systab->nr_tables * sz); +early_memunmap (config_tables, efi.systab->nr_tables * sz);set_bit (EFI_CONFIG_TABLES , &efi.flags);return 0 ; } +#ifdef CONFIG_EFI_VARS_MODULE +static int __init efi_load_efivars (void ) +{ +struct platform_device *pdev; + +if (!efi_enabled (EFI_RUNTIME_SERVICES )) +return 0 ; + + pdev =platform_device_register_simple ("efivars" ,0 ,NULL ,0 ); +return IS_ERR (pdev) ?PTR_ERR (pdev) :0 ; +} +device_initcall (efi_load_efivars); +#endif +#ifdef CONFIG_EFI_PARAMS_FROM_FDT #define UEFI_PARAM (name, prop, field) \
drivers/firmware/efi/efivars.c +1 -0
@@ -78,6 +78,7 @@ MODULE_AUTHOR("Matt Domsch <[email protected]>");MODULE_DESCRIPTION ("sysfs interface to EFI Variables" );MODULE_LICENSE ("GPL" );MODULE_VERSION (EFIVARS_VERSION ); +MODULE_ALIAS ("platform:efivars" );LIST_HEAD (efivar_sysfs_list);EXPORT_SYMBOL_GPL (efivar_sysfs_list);
drivers/firmware/efi/libstub/Makefile new file +26 -0
@@ -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/
drivers/firmware/efi/libstub/arm-stub.c renamed from drivers/firmware/efi/arm-stub.c +19 -13
@@ -12,6 +12,11 @@* */ +#include <linux/efi.h> +#include <asm/efi.h> + +#include "efistub.h" +static int __init efi_secureboot_enabled (efi_system_table_t *sys_table_arg) {static efi_guid_t const var_guid__initconst =EFI_GLOBAL_VARIABLE_GUID ;
@@ -36,8 +41,8 @@ static int __init efi_secureboot_enabled(efi_system_table_t *sys_table_arg) } } -static efi_status_t efi_open_volume (efi_system_table_t *sys_table_arg, -void *__image,void **__fh) +efi_status_t efi_open_volume (efi_system_table_t *sys_table_arg, +void *__image,void **__fh) {efi_file_io_interface_t *io;efi_loaded_image_t *image = __image;
@@ -60,14 +65,15 @@ static efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, *__fh = fh;return status; } -static efi_status_t efi_file_close (void *handle) + +efi_status_t efi_file_close (void *handle) {efi_file_handle_t *fh = handle;return fh->close (handle); } -static efi_status_t +efi_status_t efi_file_read (void *handle,unsigned long *size,void *addr) {efi_file_handle_t *fh = handle;
@@ -76,7 +82,7 @@ efi_file_read(void *handle, unsigned long *size, void *addr) } -static efi_status_t +efi_status_t efi_file_size (efi_system_table_t *sys_table_arg,void *__fh,efi_char16_t *filename_16,void **handle,u64 *file_sz) {
@@ -129,7 +135,7 @@ grow: -static void efi_char16_printk (efi_system_table_t *sys_table_arg, +void efi_char16_printk (efi_system_table_t *sys_table_arg,efi_char16_t *str) {struct efi_simple_text_output_protocol *out;
@@ -145,13 +151,13 @@ static void efi_char16_printk(efi_system_table_t *sys_table_arg,* must be reserved. On failure it is required to free all * all allocations it has made. */ -static efi_status_t handle_kernel_image (efi_system_table_t *sys_table, -unsigned long *image_addr, -unsigned long *image_size, -unsigned long *reserve_addr, -unsigned long *reserve_size, -unsigned long dram_base, -efi_loaded_image_t *image); +efi_status_t handle_kernel_image (efi_system_table_t *sys_table, +unsigned long *image_addr, +unsigned long *image_size, +unsigned long *reserve_addr, +unsigned long *reserve_size, +unsigned long dram_base, +efi_loaded_image_t *image);/* * EFI entry point for the arm/arm64 EFI stubs. This is the entrypoint * that is described in the PE/COFF header. Most of the code is the same
drivers/firmware/efi/libstub/efi-stub-helper.c renamed from drivers/firmware/efi/efi-stub-helper.c +36 -38
136 lines not on this page · raw message
drivers/firmware/efi/libstub/efistub.h new file +42 -0
42 lines not on this page · raw message
drivers/firmware/efi/libstub/fdt.c renamed from drivers/firmware/efi/fdt.c +12 -18
@@ -10,29 +10,23 @@* */ -static efi_status_t update_fdt (efi_system_table_t *sys_table,void *orig_fdt, -unsigned long orig_fdt_size, -void *fdt,int new_fdt_size,char *cmdline_ptr, -u64 initrd_addr,u64 initrd_size, -efi_memory_desc_t *memory_map, -unsigned long map_size,unsigned long desc_size, -u32 desc_ver) +#include <linux/efi.h> +#include <linux/libfdt.h> +#include <asm/efi.h> + +efi_status_t update_fdt (efi_system_table_t *sys_table,void *orig_fdt, +unsigned long orig_fdt_size, +void *fdt,int new_fdt_size,char *cmdline_ptr, +u64 initrd_addr,u64 initrd_size, +efi_memory_desc_t *memory_map, +unsigned long map_size,unsigned long desc_size, +u32 desc_ver) {int node, prev;int status;u32 fdt_val32;u64 fdt_val64; -/* -* Copy definition of linux_banner here. Since this code is -* built as part of the decompressor for ARM v7, pulling -* in version.c where linux_banner is defined for the -* kernel brings other kernel dependencies with it. -*/ -const char linux_banner[] = -"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@" -LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n" ; -/* Do some checks on provided FDT, if it exists*/ if (orig_fdt) {if (fdt_check_header (orig_fdt)) {
@@ -265,7 +259,7 @@ fail:return EFI_LOAD_ERROR ; } -static void *get_fdt (efi_system_table_t *sys_table) +void *get_fdt (efi_system_table_t *sys_table) {efi_guid_t fdt_guid =DEVICE_TREE_GUID ;efi_config_table_t *tables;
drivers/firmware/efi/reboot.c new file +56 -0
56 lines not on this page · raw message
drivers/firmware/efi/runtime-wrappers.c new file +161 -0
161 lines not on this page · raw message
drivers/xen/Kconfig +4 -0
@@ -240,4 +240,8 @@ config XEN_MCE_LOG config XEN_HAVE_PVMMU bool +config XEN_EFI + def_bool y + depends on X86_64 && EFI + endmenu
drivers/xen/Makefile +3 -0
@@ -9,6 +9,8 @@ obj-y += xenbus/ nostackp := $(call cc-option, -fno-stack-protector) CFLAGS_features.o := $(nostackp) +CFLAGS_efi.o += -fshort-wchar + dom0-$(CONFIG_PCI) += pci.o dom0-$(CONFIG_USB_SUPPORT) += dbgp.o dom0-$(CONFIG_ACPI) += acpi.o $(xen-pad-y)
@@ -33,6 +35,7 @@ obj-$(CONFIG_XEN_STUB) += xen-stub.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_MEMORY) += xen-acpi-memhotplug.o obj-$(CONFIG_XEN_ACPI_HOTPLUG_CPU) += xen-acpi-cpuhotplug.o obj-$(CONFIG_XEN_ACPI_PROCESSOR) += xen-acpi-processor.o +obj-$(CONFIG_XEN_EFI) += efi.o xen-evtchn-y := evtchn.o xen-gntdev-y := gntdev.o xen-gntalloc-y := gntalloc.o
drivers/xen/efi.c new file +368 -0
368 lines not on this page · raw message
include/linux/efi.h +55 -8
112 lines not on this page · raw message
include/xen/interface/platform.h +123 -0
146 lines not on this page · raw message
include/xen/xen-ops.h +11 -0
@@ -3,6 +3,7 @@#include <linux/percpu.h> #include <linux/notifier.h> +#include <linux/efi.h> #include <asm/xen/interface.h> DECLARE_PER_CPU(struct vcpu_info *, xen_vcpu);
@@ -35,4 +36,14 @@ int xen_unmap_domain_mfn_range(struct vm_area_struct *vma, int numpgs, struct page **pages);bool xen_running_on_version_or_later (unsigned int major,unsigned int minor); + +#ifdef CONFIG_XEN_EFI +extern efi_system_table_t *xen_efi_probe (void ); +#else +static inline efi_system_table_t __init *xen_efi_probe (void ) +{ +return NULL ; +} +#endif +#endif /* INCLUDE_XEN_OPS_H */