x86/efi for v3.18-rc2
Subsystems (6)
Hi Linus,
This patchset falls under the "maintainers that grovel" clause in the v3.18-rc1 announcement. We had intended to push it late in the merge window since we got it into the -tip tree relatively late.
Many of these are relatively simple things, but there are a couple of key bits, especially Ard's and Matt's patches as listed below.
-hpa
The following changes since commit fe82dcec644244676d55a1384c958d5f67979adb:
Linux 3.17-rc7 (2014-09-28 14:29:07 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-efi-for-linus
for you to fetch changes up to 75b128573b275d5a5a7210b98c4b8cb3b39c12e7:
Merge branch 'next' into efi-next-merge (2014-10-03 22:15:56 +0100)
----------------------------------------------------------------
Andre Müller (1):
x86/efi: Adding efi_printks on memory allocationa and pci.reads
Ard Biesheuvel (2):
efi: Implement mandatory locking for UEFI Runtime Services
efi: rtc-efi: Export platform:rtc-efi as module alias
Dave Young (6):
efi: Move noefi early param code out of x86 arch code
lib: Add a generic cmdline parse function parse_option_str
efi: Add kernel param efi=noruntime
arm64/efi: uefi_init error handling fix
arm64/efi: Do not enter virtual mode if booting with efi=noruntime or noefi x86/efi: Clear EFI_RUNTIME_SERVICES if failing to enter virtual mode
Josh Triplett (1):
efi-bgrt: Add error handling; inform the user when ignoring the BGRT
Laszlo Ersek (5):
efi: Add macro for EFI_MEMORY_UCE memory attribute
efi: Introduce efi_md_typeattr_format()
x86: efi: Format EFI memory type & attrs with efi_md_typeattr_format()
ia64: efi: Format EFI memory type & attrs with efi_md_typeattr_format()
arm64: efi: Format EFI memory type & attrs with efi_md_typeattr_format()
Mark Rustad (1):
efi: Resolve some shadow warnings
Mathias Krause (4):
x86/efi: Remove unused efi_call* macros
x86/efi: Unexport add_efi_memmap variable
x86/efi: Update comment regarding required phys mapped EFI services x86/efi: Mark initialization code as such
Matt Fleming (5):
efi: Add efi= parameter parsing to the EFI boot stub
efi: Provide a non-blocking SetVariable() operation
efi: Delete the in_nmi() conditional runtime locking
rtc: Disable EFI rtc for x86
Merge branch 'next' into efi-next-merge
Documentation/kernel-parameters.txt | 8 +- arch/arm64/kernel/efi.c | 44 +++---- arch/ia64/kernel/efi.c | 6 +- arch/x86/boot/compressed/eboot.c | 32 +++-- arch/x86/include/asm/efi.h | 31 ++--- arch/x86/platform/efi/efi-bgrt.c | 36 +++++- arch/x86/platform/efi/efi.c | 52 ++++---- arch/x86/platform/efi/efi_32.c | 12 +- arch/x86/platform/efi/efi_64.c | 6 +- arch/x86/platform/efi/efi_stub_32.S | 4 +- drivers/firmware/efi/efi.c | 79 ++++++++++++ drivers/firmware/efi/libstub/arm-stub.c | 4 + drivers/firmware/efi/libstub/efi-stub-helper.c | 62 +++++++++- drivers/firmware/efi/runtime-wrappers.c | 164 +++++++++++++++++++++++-- drivers/firmware/efi/vars.c | 61 +++++++-- drivers/rtc/Kconfig | 2 +- drivers/rtc/rtc-efi.c | 1 + include/linux/efi.h | 17 +++ include/linux/kernel.h | 1 + lib/cmdline.c | 29 +++++ 20 files changed, 528 insertions(+), 123 deletions(-)
Documentation/kernel-parameters.txt +6 -2
@@ -992,10 +992,14 @@ bytes respectively. Such letter suffixes can also be entirely omitted. Format: {"off" | "on" | "skip[mbr]"} efi= [EFI] - Format: { "old_map" } + Format: { "old_map", "nochunk", "noruntime" } old_map [X86-64]: switch to the old ioremap-based EFI runtime services mapping. 32-bit still uses this one by default. + nochunk: disable reading files in "chunks" in the EFI + boot stub, as chunking can cause problems with some + firmware implementations. + noruntime : disable EFI runtime services support efi_no_storage_paranoia [EFI; X86] Using this parameter you can use more than 50% of
@@ -2166,7 +2170,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. nodsp [SH] Disable hardware DSP at boot time. - noefi [X86] Disable EFI runtime services support. + noefi Disable EFI runtime services support. noexec [IA-64]
arch/arm64/kernel/efi.c +18 -26
81 lines not on this page · raw message
arch/ia64/kernel/efi.c +4 -2
@@ -568,6 +568,7 @@ efi_init (void) {const char *unit;unsigned long size; +char buf[64 ]; md = p; size = md->num_pages <<EFI_PAGE_SHIFT ;
@@ -586,9 +587,10 @@ efi_init (void) unit ="KB" ; } -printk ("mem%02d: type=%2u, attr=0x%016lx, " +printk ("mem%02d: %s " "range=[0x%016lx-0x%016lx) (%4lu%s)\n" , - i, md->type, md->attribute, md->phys_addr, + i,efi_md_typeattr_format (buf,sizeof (buf), md), + md->phys_addr, md->phys_addr +efi_md_size (md), size, unit); } }
arch/x86/boot/compressed/eboot.c +25 -7
@@ -330,8 +330,10 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom) size = pci->romsize +sizeof (*rom); status =efi_call_early (allocate_pool,EFI_LOADER_DATA , size, &rom); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to alloc mem for rom\n" );return status; + }memset (rom,0 ,sizeof (*rom));
@@ -344,14 +346,18 @@ __setup_efi_pci32(efi_pci_io_protocol_32 *pci, struct pci_setup_rom **__rom) status = efi_early->call (pci->pci.read, pci, EfiPciIoWidthUint16,PCI_VENDOR_ID ,1 , &(rom->vendor)); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to read rom->vendor\n" ); goto free_struct; + } status = efi_early->call (pci->pci.read, pci, EfiPciIoWidthUint16,PCI_DEVICE_ID ,1 , &(rom->devid)); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to read rom->devid\n" ); goto free_struct; + } status = efi_early->call (pci->get_location, pci, &(rom->segment), &(rom->bus), &(rom->device), &(rom->function));
@@ -432,8 +438,10 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom) size = pci->romsize +sizeof (*rom); status =efi_call_early (allocate_pool,EFI_LOADER_DATA , size, &rom); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to alloc mem for rom\n" );return status; + } rom->data.type =SETUP_PCI ; rom->data.len = size -sizeof (struct setup_data );
@@ -444,14 +452,18 @@ __setup_efi_pci64(efi_pci_io_protocol_64 *pci, struct pci_setup_rom **__rom) status = efi_early->call (pci->pci.read, pci, EfiPciIoWidthUint16,PCI_VENDOR_ID ,1 , &(rom->vendor)); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to read rom->vendor\n" ); goto free_struct; + } status = efi_early->call (pci->pci.read, pci, EfiPciIoWidthUint16,PCI_DEVICE_ID ,1 , &(rom->devid)); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to read rom->devid\n" ); goto free_struct; + } status = efi_early->call (pci->get_location, pci, &(rom->segment), &(rom->bus), &(rom->device), &(rom->function));
@@ -538,8 +550,10 @@ static void setup_efi_pci(struct boot_params *params)EFI_LOADER_DATA , size, (void **)&pci_handle); -if (status !=EFI_SUCCESS ) +if (status !=EFI_SUCCESS ) { +efi_printk (sys_table,"Failed to alloc mem for pci_handle\n" );return ; + } status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, &pci_proto,
@@ -1105,6 +1119,10 @@ struct boot_params *make_boot_params(struct efi_config *c)memset (sdt,0 ,sizeof (*sdt)); + status =efi_parse_options (cmdline_ptr); +if (status !=EFI_SUCCESS ) + goto fail2; + status = handle_cmdline_files(sys_table, image, (char *)(unsigned long)hdr->cmd_line_ptr, "initrd=", hdr->initrd_addr_max,
arch/x86/include/asm/efi.h +10 -21
@@ -81,24 +81,23 @@ extern u64 asmlinkage efi_call(void *fp, ...);*/ #define __efi_call_virt(f, args...) efi_call_virt(f, args) -extern void __iomem *efi_ioremap (unsigned long addr,unsigned long size, -u32 type,u64 attribute); +extern void __iomem *__init efi_ioremap (unsigned long addr,unsigned long size, +u32 type,u64 attribute);#endif /* CONFIG_X86_32 */ -extern int add_efi_memmap;extern struct efi_scratch efi_scratch; -extern void efi_set_executable (efi_memory_desc_t *md,bool executable); -extern int efi_memblock_x86_reserve_range (void ); -extern void efi_call_phys_prelog (void ); -extern void efi_call_phys_epilog (void ); -extern void efi_unmap_memmap (void ); -extern void efi_memory_uc (u64 addr,unsigned long size); +extern void __init efi_set_executable (efi_memory_desc_t *md,bool executable); +extern int __init efi_memblock_x86_reserve_range (void ); +extern void __init efi_call_phys_prolog (void ); +extern void __init efi_call_phys_epilog (void ); +extern void __init efi_unmap_memmap (void ); +extern void __init efi_memory_uc (u64 addr,unsigned long size);extern void __init efi_map_region (efi_memory_desc_t *md);extern void __init efi_map_region_fixed (efi_memory_desc_t *md);extern void efi_sync_low_kernel_mappings (void ); -extern int efi_setup_page_tables (unsigned long pa_memmap,unsigned num_pages); -extern void efi_cleanup_page_tables (unsigned long pa_memmap,unsigned num_pages); +extern int __init efi_setup_page_tables (unsigned long pa_memmap,unsigned num_pages); +extern void __init efi_cleanup_page_tables (unsigned long pa_memmap,unsigned num_pages);extern void __init old_map_region (efi_memory_desc_t *md);extern void __init runtime_code_page_mkexec (void );extern void __init efi_runtime_mkexec (void );
@@ -162,16 +161,6 @@ static inline efi_status_t efi_thunk_set_virtual_address_map(extern bool efi_reboot_required (void );#else -/* -* IF EFI is not configured, have the EFI calls return -ENOSYS. -*/ -#define efi_call0 (_f) (-ENOSYS) -#define efi_call1 (_f, _a1) (-ENOSYS) -#define efi_call2 (_f, _a1, _a2) (-ENOSYS) -#define efi_call3 (_f, _a1, _a2, _a3) (-ENOSYS) -#define efi_call4 (_f, _a1, _a2, _a3, _a4) (-ENOSYS) -#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 ) {
arch/x86/platform/efi/efi-bgrt.c +30 -6
@@ -40,20 +40,40 @@ void __init efi_bgrt_init(void)if (ACPI_FAILURE (status))return ; -if (bgrt_tab->header.length <sizeof (*bgrt_tab)) +if (bgrt_tab->header.length <sizeof (*bgrt_tab)) { +pr_err ("Ignoring BGRT: invalid length %u (expected %zu)\n" , + bgrt_tab->header.length,sizeof (*bgrt_tab));return ; -if (bgrt_tab->version !=1 || bgrt_tab->status !=1 ) + } +if (bgrt_tab->version !=1 ) { +pr_err ("Ignoring BGRT: invalid version %u (expected 1)\n" , + bgrt_tab->version); +return ; + } +if (bgrt_tab->status !=1 ) { +pr_err ("Ignoring BGRT: invalid status %u (expected 1)\n" , + bgrt_tab->status); +return ; + } +if (bgrt_tab->image_type !=0 ) { +pr_err ("Ignoring BGRT: invalid image type %u (expected 0)\n" , + bgrt_tab->image_type);return ; -if (bgrt_tab->image_type !=0 || !bgrt_tab->image_address) + } +if (!bgrt_tab->image_address) { +pr_err ("Ignoring BGRT: null image address\n" );return ; + } image =efi_lookup_mapped_addr (bgrt_tab->image_address);if (!image) { image =early_memremap (bgrt_tab->image_address,sizeof (bmp_header)); ioremapped = true; -if (!image) +if (!image) { +pr_err ("Ignoring BGRT: failed to map image header memory\n" );return ; + } }memcpy_fromio (&bmp_header, image,sizeof (bmp_header));
@@ -61,14 +81,18 @@ void __init efi_bgrt_init(void)early_iounmap (image,sizeof (bmp_header)); bgrt_image_size = bmp_header.size; - bgrt_image =kmalloc (bgrt_image_size,GFP_KERNEL ); -if (!bgrt_image) + bgrt_image =kmalloc (bgrt_image_size,GFP_KERNEL | __GFP_NOWARN); +if (!bgrt_image) { +pr_err ("Ignoring BGRT: failed to allocate memory for image (wanted %zu bytes)\n" , + bgrt_image_size);return ; + }if (ioremapped) { image =early_memremap (bgrt_tab->image_address, bmp_header.size);if (!image) { +pr_err ("Ignoring BGRT: failed to map image memory\n" );kfree (bgrt_image); bgrt_image =NULL ;return ;
arch/x86/platform/efi/efi.c +23 -29
122 lines not on this page · raw message
arch/x86/platform/efi/efi_32.c +7 -5
@@ -33,7 +33,7 @@/* * To make EFI call EFI runtime service in physical addressing mode we need -* prelog/epilog before/after the invocation to disable interrupt, to +* prolog/epilog before/after the invocation to disable interrupt, to * claim EFI runtime service handler exclusively and to duplicate a memory in * low memory space say 0 - 3G. */
@@ -41,11 +41,13 @@ static unsigned long efi_rt_eflags;void efi_sync_low_kernel_mappings (void ) {}void __init efi_dump_pagetable (void ) {} -int efi_setup_page_tables (unsigned long pa_memmap,unsigned num_pages) +int __init efi_setup_page_tables (unsigned long pa_memmap,unsigned num_pages) {return 0 ; } -void efi_cleanup_page_tables (unsigned long pa_memmap,unsigned num_pages) {} +void __init efi_cleanup_page_tables (unsigned long pa_memmap,unsigned num_pages) +{ +}void __init efi_map_region (efi_memory_desc_t *md) {
@@ -55,7 +57,7 @@ void __init efi_map_region(efi_memory_desc_t *md)void __init efi_map_region_fixed (efi_memory_desc_t *md) {}void __init parse_efi_setup (u64 phys_addr,u32 data_len) {} -void efi_call_phys_prelog (void ) +void __init efi_call_phys_prolog (void ) {struct desc_ptr gdt_descr;
@@ -69,7 +71,7 @@ void efi_call_phys_prelog(void)load_gdt (&gdt_descr); } -void efi_call_phys_epilog (void ) +void __init efi_call_phys_epilog (void ) {struct desc_ptr gdt_descr;
arch/x86/platform/efi/efi_64.c +3 -3
@@ -79,7 +79,7 @@ static void __init early_code_mapping_set_exec(int executable) } } -void __init efi_call_phys_prelog (void ) +void __init efi_call_phys_prolog (void ) {unsigned long vaddress;int pgd;
@@ -139,7 +139,7 @@ void efi_sync_low_kernel_mappings(void) sizeof(pgd_t) * num_pgds); } -int efi_setup_page_tables (unsigned long pa_memmap,unsigned num_pages) +int __init efi_setup_page_tables (unsigned long pa_memmap,unsigned num_pages) {unsigned long text;struct page *page;
@@ -192,7 +192,7 @@ int efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages)return 0 ; } -void efi_cleanup_page_tables (unsigned long pa_memmap,unsigned num_pages) +void __init efi_cleanup_page_tables (unsigned long pa_memmap,unsigned num_pages) {pgd_t *pgd = (pgd_t *)__va (real_mode_header->trampoline_pgd);
arch/x86/platform/efi/efi_stub_32.S +2 -2
@@ -27,13 +27,13 @@ ENTRY(efi_call_phys) * set to 0x0010, DS and SS have been set to 0x0018. In EFI, I found * the values of these registers are the same. And, the corresponding * GDT entries are identical. So I will do nothing about segment reg - * and GDT, but change GDT base register in prelog and epilog. + * and GDT, but change GDT base register in prolog and epilog. */ /* * 1. Now I am running with EIP = <physical address> + PAGE_OFFSET. * But to make it smoothly switch from virtual mode to flat mode. - * The mapping of lower virtual memory has been created in prelog and + * The mapping of lower virtual memory has been created in prolog and * epilog. */ movl $1f, %edx
drivers/firmware/efi/efi.c +79 -0
88 lines not on this page · raw message
drivers/firmware/efi/libstub/arm-stub.c +4 -0
@@ -226,6 +226,10 @@ unsigned long __init efi_entry(void *handle, efi_system_table_t *sys_table, goto fail_free_image; } + status =efi_parse_options (cmdline_ptr); +if (status !=EFI_SUCCESS ) +pr_efi_err (sys_table,"Failed to parse EFI cmdline options\n" ); +/* * Unauthenticated device tree data is a security hazard, so * ignore 'dtb=' unless UEFI Secure Boot is disabled.
drivers/firmware/efi/libstub/efi-stub-helper.c +60 -2
82 lines not on this page · raw message
drivers/firmware/efi/runtime-wrappers.c +154 -10
265 lines not on this page · raw message
drivers/firmware/efi/vars.c +54 -7
93 lines not on this page · raw message
drivers/rtc/Kconfig +1 -1
@@ -806,7 +806,7 @@ config RTC_DRV_DA9063 config RTC_DRV_EFI tristate "EFI RTC" - depends on EFI + depends on EFI && !X86 help If you say yes here you will get support for the EFI Real Time Clock.
drivers/rtc/rtc-efi.c +1 -0
@@ -236,3 +236,4 @@ MODULE_ALIAS("platform:rtc-efi");MODULE_AUTHOR ("dann frazier <[email protected]>" );MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("EFI RTC driver" ); +MODULE_ALIAS ("platform:rtc-efi" );
include/linux/efi.h +17 -0
@@ -92,6 +92,7 @@ typedef struct {#define EFI_MEMORY_WC ((u64)0x0000000000000002ULL)/* write-coalescing */ #define EFI_MEMORY_WT ((u64)0x0000000000000004ULL)/* write-through */ #define EFI_MEMORY_WB ((u64)0x0000000000000008ULL)/* write-back */ +#define EFI_MEMORY_UCE ((u64)0x0000000000000010ULL)/* uncached, exported */ #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL)/* write-protect */ #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL)/* read-protect */ #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL)/* execute-protect */
@@ -502,6 +503,10 @@ typedef efi_status_t efi_get_next_variable_t (unsigned long *name_size, efi_chartypedef efi_status_t efi_set_variable_t (efi_char16_t *name,efi_guid_t *vendor,u32 attr,unsigned long data_size,void *data); +typedef efi_status_t +efi_set_variable_nonblocking_t (efi_char16_t *name,efi_guid_t *vendor, +u32 attr,unsigned long data_size,void *data); +typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count);typedef void efi_reset_system_t (int reset_type,efi_status_t status,unsigned long data_size,efi_char16_t *data);
@@ -821,6 +826,7 @@ extern struct efi {efi_get_variable_t *get_variable;efi_get_next_variable_t *get_next_variable;efi_set_variable_t *set_variable; +efi_set_variable_nonblocking_t *set_variable_nonblocking;efi_query_variable_info_t *query_variable_info;efi_update_capsule_t *update_capsule;efi_query_capsule_caps_t *query_capsule_caps;
@@ -886,6 +892,13 @@ extern bool efi_poweroff_required(void); (md) <= (efi_memory_desc_t *)((m)->map_end - (m)->desc_size); \ (md) = (void *)(md) + (m)->desc_size) +/* +* Format an EFI memory descriptor's type and attributes to a user-provided +* character buffer, as per snprintf(), and return the buffer. +*/ +char *__init efi_md_typeattr_format (char *buf,size_t size, +const efi_memory_desc_t *md); +/** * efi_range_is_wc - check the WC bit on an address range * @start: starting kvirt address
@@ -1034,6 +1047,7 @@ struct efivar_operations {efi_get_variable_t *get_variable;efi_get_next_variable_t *get_next_variable;efi_set_variable_t *set_variable; +efi_set_variable_nonblocking_t *set_variable_nonblocking;efi_query_variable_store_t *query_variable_store; };
@@ -1227,4 +1241,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); + +bool efi_runtime_disabled (void );#endif /* _LINUX_EFI_H */
include/linux/kernel.h +1 -0
@@ -407,6 +407,7 @@ int vsscanf(const char *, const char *, va_list);extern int get_option (char **str,int *pint);extern char *get_options (const char *str,int nints,int *ints);extern unsigned long long memparse (const char *ptr,char **retptr); +extern bool parse_option_str (const char *str,const char *option);extern int core_kernel_text (unsigned long addr);extern int core_kernel_data (unsigned long addr);
lib/cmdline.c +29 -0
@@ -160,3 +160,32 @@ unsigned long long memparse(const char *ptr, char **retptr)return ret; }EXPORT_SYMBOL (memparse); + +/** +* parse_option_str - Parse a string and check an option is set or not +* @str: String to be parsed +* @option: option name +* +* This function parses a string containing a comma-separated list of +* strings like a=b,c. +* +* Return true if there's such option in the string, or return false. +*/ +bool parse_option_str (const char *str,const char *option) +{ +while (*str) { +if (!strncmp (str, option,strlen (option))) { + str +=strlen (option); +if (!*str || *str ==',' ) +return true; + } + +while (*str && *str !=',' ) + str++; + +if (*str ==',' ) + str++; + } + +return false; +}