EFI changes for v4.12
Subsystems (6)
Linus,
Please pull the latest efi-core-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git efi-core-for-linus
# HEAD: 197decefdb79d6f1350ba0316ce26ba737372d0c efi/libstub/arm: Don't use TASK_SIZE when randomizing the RT space
The main changes in this cycle were:
- Move BGRT handling to drivers/acpi so it can be shared between x86 and ARM
- Bring the EFI stub's initrd and FDT allocation logic in line with the latest changes to the arm64 boot protocol
- Improvements and fixes to the EFI stub's command line parsing routines
- Randomize the virtual mapping of the UEFI runtime services on ARM/arm64
- ... and other misc enhancements, cleanups and fixes.
Thanks,
Ingo
------------------>
Ard Biesheuvel (8):
efi/arm-stub: Correct FDT and initrd allocation rules for arm64 efi/arm-stub: Round up FDT allocation to mapping size efi/arm32-stub: Allow boot-time allocations in the vmlinux region efi/libstub: Fix harmless command line parsing bug efi/libstub: Unify command line param parsing efi/libstub/arm/arm64: Disable debug prints on 'quiet' cmdline arg ef/libstub/arm/arm64: Randomize the base of the UEFI rt services region efi/libstub/arm: Don't use TASK_SIZE when randomizing the RT space
Baoquan He (1):
x86/efi: Clean up a minor mistake in comment
Bhupesh Sharma (2):
x86/efi/bgrt: Move efi-bgrt handling out of arch/x86 efi/bgrt: Enable ACPI BGRT handling on arm64
Evgeny Kalugin (1):
efi/pstore: Return error code (if any) from efi_pstore_write()
arch/arm/include/asm/efi.h | 14 +-
arch/arm64/include/asm/efi.h | 24 +++-
arch/arm64/kernel/acpi.c | 3 +
arch/x86/kernel/acpi/boot.c | 6 -
arch/x86/platform/efi/Makefile | 1 -
arch/x86/platform/efi/efi_64.c | 2 +-
drivers/acpi/Kconfig | 2 +-
drivers/acpi/bgrt.c | 6 +
drivers/firmware/efi/Makefile | 1 +
.../platform => drivers/firmware}/efi/efi-bgrt.c | 0
drivers/firmware/efi/efi-pstore.c | 6 +-
drivers/firmware/efi/libstub/arm-stub.c | 87 +++++++-----
drivers/firmware/efi/libstub/arm32-stub.c | 150 ++++++++++++++++++---
drivers/firmware/efi/libstub/arm64-stub.c | 4 +-
drivers/firmware/efi/libstub/efi-stub-helper.c | 32 +++--
drivers/firmware/efi/libstub/efistub.h | 9 ++
drivers/firmware/efi/libstub/fdt.c | 57 ++++----
drivers/firmware/efi/libstub/secureboot.c | 2 +
include/linux/efi-bgrt.h | 5 +
include/linux/efi.h | 5 +-
20 files changed, 299 insertions(+), 117 deletions(-)
rename {arch/x86/platform => drivers/firmware}/efi/efi-bgrt.c (100%)arch/arm/include/asm/efi.h +13 -1
@@ -85,6 +85,18 @@ static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)*/ #define ZIMAGE_OFFSET_LIMIT SZ_128M#define MIN_ZIMAGE_OFFSET MAX_UNCOMP_KERNEL_SIZE -#define MAX_FDT_OFFSET ZIMAGE_OFFSET_LIMIT + +/* on ARM, the FDT should be located in the first 128 MB of RAM */ +static inline unsigned long efi_get_max_fdt_addr (unsigned long dram_base) +{ +return dram_base +ZIMAGE_OFFSET_LIMIT ; +} + +/* on ARM, the initrd should be loaded in a lowmem region */ +static inline unsigned long efi_get_max_initrd_addr (unsigned long dram_base, +unsigned long image_addr) +{ +return dram_base +SZ_512M ; +}#endif /* _ASM_ARM_EFI_H */
arch/arm64/include/asm/efi.h +23 -1
@@ -1,6 +1,7 @@#ifndef _ASM_EFI_H#define _ASM_EFI_H +#include <asm/boot.h> #include <asm/cpufeature.h> #include <asm/io.h> #include <asm/mmu_context.h>
@@ -46,7 +47,28 @@ int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md);* 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 + +/* on arm64, the FDT may be located anywhere in system RAM */ +static inline unsigned long efi_get_max_fdt_addr (unsigned long dram_base) +{ +return ULONG_MAX ; +} + +/* +* On arm64, we have to ensure that the initrd ends up in the linear region, +* which is a 1 GB aligned region of size '1UL << (VA_BITS - 1)' that is +* guaranteed to cover the kernel Image. +* +* Since the EFI stub is part of the kernel Image, we can relax the +* usual requirements in Documentation/arm64/booting.txt, which still +* apply to other bootloaders, and are required for some kernel +* configurations. +*/ +static inline unsigned long efi_get_max_initrd_addr (unsigned long dram_base, +unsigned long image_addr) +{ +return (image_addr & ~(SZ_1G -1UL )) + (1UL << (VA_BITS -1 )); +}#define efi_call_early (f, ...) sys_table_arg->boottime->f(__VA_ARGS__)#define __efi_call_early (f, ...) f(__VA_ARGS__)
arch/arm64/kernel/acpi.c +3 -0
@@ -18,6 +18,7 @@#include <linux/acpi.h> #include <linux/bootmem.h> #include <linux/cpumask.h> +#include <linux/efi-bgrt.h> #include <linux/init.h> #include <linux/irq.h> #include <linux/irqdomain.h>
@@ -233,6 +234,8 @@ void __init acpi_boot_table_init(void)early_init_dt_scan_chosen_stdout (); }else {parse_spcr (earlycon_init_is_deferred); +if (IS_ENABLED (CONFIG_ACPI_BGRT )) +acpi_table_parse (ACPI_SIG_BGRT , acpi_parse_bgrt); } }
arch/x86/kernel/acpi/boot.c +0 -6
@@ -1564,12 +1564,6 @@ int __init early_acpi_boot_init(void)return 0 ; } -static int __init acpi_parse_bgrt (struct acpi_table_header *table) -{ -efi_bgrt_init (table); -return 0 ; -} -int __init acpi_boot_init (void ) {/* those are executed after early-quirks are executed */
arch/x86/platform/efi/Makefile +0 -1
@@ -1,6 +1,5 @@ OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y 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_64.c +1 -1
@@ -47,7 +47,7 @@#include <asm/pgalloc.h> /* -* We allocate runtime services regions bottom-up, starting from -4G, i.e. +* We allocate runtime services regions top-down, starting from -4G, i.e. * 0xffff_ffff_0000_0000 and limit EFI VA mapping space to 64G. */ static u64 efi_va =EFI_VA_START ;
drivers/acpi/Kconfig +1 -1
@@ -440,7 +440,7 @@ config ACPI_CUSTOM_METHOD config ACPI_BGRT bool "Boottime Graphics Resource Table support" - depends on EFI && X86 + depends on EFI && (X86 || ARM64) help This driver adds support for exposing the ACPI Boottime Graphics Resource Table, which allows the operating system to obtain
drivers/acpi/bgrt.c +6 -0
@@ -81,6 +81,12 @@ static struct attribute_group bgrt_attribute_group = { .bin_attrs = bgrt_bin_attributes, }; +int __init acpi_parse_bgrt (struct acpi_table_header *table) +{ +efi_bgrt_init (table); +return 0 ; +} +static int __init bgrt_init (void ) {int ret;
drivers/firmware/efi/Makefile +1 -0
@@ -9,6 +9,7 @@ # KASAN_SANITIZE_runtime-wrappers.o := n +obj-$(CONFIG_ACPI_BGRT) += efi-bgrt.o obj-$(CONFIG_EFI) += efi.o vars.o reboot.o memattr.o obj-$(CONFIG_EFI) += capsule.o memmap.o obj-$(CONFIG_EFI_VARS) += efivars.o
drivers/firmware/efi/efi-bgrt.c renamed from arch/x86/platform/efi/efi-bgrt.c +0 -0
drivers/firmware/efi/efi-pstore.c +3 -3
@@ -274,9 +274,9 @@ static int efi_pstore_write(enum pstore_type_id type,for (i =0 ; i <DUMP_NAME_LEN ; i++) efi_name[i] = name[i]; -efivar_entry_set_safe (efi_name, vendor,PSTORE_EFI_ATTRIBUTES , - !pstore_cannot_block_path (reason), - size, psi->buf); + ret =efivar_entry_set_safe (efi_name, vendor,PSTORE_EFI_ATTRIBUTES , + !pstore_cannot_block_path (reason), + size, psi->buf);if (reason ==KMSG_DUMP_OOPS )efivar_run_worker ();
drivers/firmware/efi/libstub/arm-stub.c +54 -33
138 lines not on this page · raw message
drivers/firmware/efi/libstub/arm32-stub.c +130 -20
179 lines not on this page · raw message
drivers/firmware/efi/libstub/arm64-stub.c +1 -3
@@ -16,8 +16,6 @@#include "efistub.h" -extern bool __nokaslr; -efi_status_t check_platform_features (efi_system_table_t *sys_table_arg) {u64 tg;
@@ -52,7 +50,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg,u64 phys_seed =0 ;if (IS_ENABLED (CONFIG_RANDOMIZE_BASE )) { -if (!__nokaslr) { +if (!nokaslr ()) { status =efi_get_random_bytes (sys_table_arg,sizeof (phys_seed), (u8 *)&phys_seed);
drivers/firmware/efi/libstub/efi-stub-helper.c +22 -10
@@ -32,6 +32,18 @@static unsigned long __chunk_size =EFI_READ_CHUNK_SIZE ; +static int __section(.data) __nokaslr; +static int __section(.data) __quiet; + +int __pure nokaslr(void) +{ + return __nokaslr; +} +int __pure is_quiet(void) +{ +return __quiet; +} +#define EFI_MMAP_NR_SLACK_SLOTS 8struct file_info {
@@ -409,17 +421,17 @@ static efi_status_t efi_file_close(void *handle)* environments, first in the early boot environment of the EFI boot * stub, and subsequently during the kernel boot. */ -efi_status_t efi_parse_options (char *cmdline) +efi_status_t efi_parse_options (char const *cmdline) {char *str; -/* -* Currently, the only efi= option we look for is 'nochunk', which -* is intended to work around known issues on certain x86 UEFI -* versions. So ignore for now on other architectures. -*/ -if (!IS_ENABLED (CONFIG_X86 )) -return EFI_SUCCESS ; + str =strstr (cmdline,"nokaslr" ); +if (str == cmdline || (str && str > cmdline && *(str -1 ) ==' ' )) + __nokaslr =1 ; + + str =strstr (cmdline,"quiet" ); +if (str == cmdline || (str && str > cmdline && *(str -1 ) ==' ' )) + __quiet =1 ;/* * If no EFI parameters were specified on the cmdline we've got
@@ -436,14 +448,14 @@ efi_status_t efi_parse_options(char *cmdline)* Remember, because efi= is also used by the kernel we need to * skip over arguments we don't understand. */ -while (*str) { +while (*str && *str !=' ' ) {if (!strncmp (str,"nochunk" ,7 )) { str +=strlen ("nochunk" ); __chunk_size =-1UL ; }/* Group words together, delimited by "," */ -while (*str && *str !=',' ) +while (*str && *str !=' ' && *str !=',' ) str++;if (*str ==',' )
drivers/firmware/efi/libstub/efistub.h +9 -0
@@ -24,6 +24,15 @@#define EFI_ALLOC_ALIGN EFI_PAGE_SIZE#endif +extern int __pure nokaslr (void ); +extern int __pure is_quiet (void ); + +#define pr_efi (sys_table, msg) do { \ + if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \ +} while (0) + +#define pr_efi_err (sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) +void efi_char16_printk (efi_system_table_t *,efi_char16_t *); efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image,
drivers/firmware/efi/libstub/fdt.c +24 -33
85 lines not on this page · raw message
drivers/firmware/efi/libstub/secureboot.c +2 -0
@@ -12,6 +12,8 @@#include <linux/efi.h> #include <asm/efi.h> +#include "efistub.h" +/* BIOS variables */ static const efi_guid_t efi_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;static const efi_char16_t const efi_SecureBoot_name[] = {
include/linux/efi-bgrt.h +5 -0
@@ -6,6 +6,7 @@#ifdef CONFIG_ACPI_BGRT void efi_bgrt_init (struct acpi_table_header *table); +int __init acpi_parse_bgrt (struct acpi_table_header *table);/* The BGRT data itself; only valid if bgrt_image != NULL. */ extern size_t bgrt_image_size;
@@ -14,6 +15,10 @@ extern struct acpi_table_bgrt bgrt_tab;#else /* !CONFIG_ACPI_BGRT */ static inline void efi_bgrt_init (struct acpi_table_header *table) {} +static inline int __init acpi_parse_bgrt (struct acpi_table_header *table) +{ +return 0 ; +}#endif /* !CONFIG_ACPI_BGRT */
include/linux/efi.h +1 -4
@@ -1435,9 +1435,6 @@ static inline int efi_runtime_map_copy(void *buf, size_t bufsz)/* prototypes shared between arch specific and generic stub code */ -#define pr_efi (sys_table, msg) efi_printk(sys_table, "EFI stub: "msg) -#define pr_efi_err (sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) -void efi_printk (efi_system_table_t *sys_table_arg,char *str); void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
@@ -1471,7 +1468,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,unsigned long *load_addr, unsigned long *load_size); -efi_status_t efi_parse_options (char *cmdline); +efi_status_t efi_parse_options (char const *cmdline); efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, struct screen_info *si, efi_guid_t *proto,