Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull EFI updates from Ingo Molnar:
"The main changes are:

- Use separate EFI page tables when executing EFI firmware code.
This isolates the EFI context from the rest of the kernel, which
has security and general robustness advantages. (Matt Fleming)

- Run regular UEFI firmware with interrupts enabled. This is already
the status quo under other OSs. (Ard Biesheuvel)

- Various x86 EFI enhancements, such as the use of non-executable
attributes for EFI memory mappings. (Sai Praneeth Prakhya)

- Various arm64 UEFI enhancements. (Ard Biesheuvel)

- ... various fixes and cleanups.

The separate EFI page tables feature got delayed twice already,
because it's an intrusive change and we didn't feel confident about
it - third time's the charm we hope!"

* 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (37 commits)
x86/mm/pat: Fix boot crash when 1GB pages are not supported by the CPU
x86/efi: Only map kernel text for EFI mixed mode
x86/efi: Map EFI_MEMORY_{XP,RO} memory region bits to EFI page tables
x86/mm/pat: Don't implicitly allow _PAGE_RW in kernel_map_pages_in_pgd()
efi/arm*: Perform hardware compatibility check
efi/arm64: Check for h/w support before booting a >4 KB granular kernel
efi/arm: Check for LPAE support before booting a LPAE kernel
efi/arm-init: Use read-only early mappings
efi/efistub: Prevent __init annotations from being used
arm64/vmlinux.lds.S: Handle .init.rodata.xxx and .init.bss sections
efi/arm64: Drop __init annotation from handle_kernel_image()
x86/mm/pat: Use _PAGE_GLOBAL bit for EFI page table mappings
efi/runtime-wrappers: Run UEFI Runtime Services with interrupts enabled
efi: Reformat GUID tables to follow the format in UEFI spec
efi: Add Persistent Memory type name
efi: Add NV memory attribute
x86/efi: Show actual ending addresses in efi_print_memmap
x86/efi/bgrt: Don't ignore the BGRT if the 'valid' bit is 0
efivars: Use to_efivar_entry
efi: Runtime-wrapper: Get rid of the rtc_lock spinlock
...

+513 -324
+2 -2
Documentation/efi-stub.txt
··· 10 10 respectively. For ARM the EFI stub is implemented in 11 11 arch/arm/boot/compressed/efi-header.S and 12 12 arch/arm/boot/compressed/efi-stub.c. EFI stub code that is shared 13 - between architectures is in drivers/firmware/efi/efi-stub-helper.c. 13 + between architectures is in drivers/firmware/efi/libstub. 14 14 15 15 For arm64, there is no compressed kernel support, so the Image itself 16 16 masquerades as a PE/COFF image and the EFI stub is linked into the 17 17 kernel. The arm64 EFI stub lives in arch/arm64/kernel/efi-entry.S 18 - and arch/arm64/kernel/efi-stub.c. 18 + and drivers/firmware/efi/libstub/arm64-stub.c. 19 19 20 20 By using the EFI boot stub it's possible to boot a Linux kernel 21 21 without the use of a conventional EFI boot loader, such as grub or
+6 -6
Documentation/x86/x86_64/mm.txt
··· 16 16 ... unused hole ... 17 17 ffffff0000000000 - ffffff7fffffffff (=39 bits) %esp fixup stacks 18 18 ... unused hole ... 19 + ffffffef00000000 - ffffffff00000000 (=64 GB) EFI region mapping space 20 + ... unused hole ... 19 21 ffffffff80000000 - ffffffffa0000000 (=512 MB) kernel text mapping, from phys 0 20 22 ffffffffa0000000 - ffffffffff5fffff (=1525 MB) module mapping space 21 23 ffffffffff600000 - ffffffffffdfffff (=8 MB) vsyscalls ··· 34 32 Current X86-64 implementations only support 40 bits of address space, 35 33 but we support up to 46 bits. This expands into MBZ space in the page tables. 36 34 37 - ->trampoline_pgd: 38 - 39 - We map EFI runtime services in the aforementioned PGD in the virtual 40 - range of 64Gb (arbitrarily set, can be raised if needed) 41 - 42 - 0xffffffef00000000 - 0xffffffff00000000 35 + We map EFI runtime services in the 'efi_pgd' PGD in a 64Gb large virtual 36 + memory window (this size is arbitrary, it can be raised later if needed). 37 + The mappings are not part of any other kernel PGD and are only available 38 + during EFI runtime calls. 43 39 44 40 -Andi Kleen, Jul 2004
+1
arch/arm64/kernel/vmlinux.lds.S
··· 135 135 CON_INITCALL 136 136 SECURITY_INITCALL 137 137 INIT_RAM_FS 138 + *(.init.rodata.* .init.bss) /* from the EFI stub */ 138 139 } 139 140 .exit.data : { 140 141 ARM_EXIT_KEEP(EXIT_DATA)
+27 -1
arch/x86/include/asm/efi.h
··· 3 3 4 4 #include <asm/fpu/api.h> 5 5 #include <asm/pgtable.h> 6 + #include <asm/tlb.h> 6 7 7 8 /* 8 9 * We map the EFI regions needed for runtime services non-contiguously, ··· 67 66 68 67 #define efi_call_phys(f, args...) efi_call((f), args) 69 68 69 + /* 70 + * Scratch space used for switching the pagetable in the EFI stub 71 + */ 72 + struct efi_scratch { 73 + u64 r15; 74 + u64 prev_cr3; 75 + pgd_t *efi_pgt; 76 + bool use_pgd; 77 + u64 phys_stack; 78 + } __packed; 79 + 70 80 #define efi_call_virt(f, ...) \ 71 81 ({ \ 72 82 efi_status_t __s; \ ··· 85 73 efi_sync_low_kernel_mappings(); \ 86 74 preempt_disable(); \ 87 75 __kernel_fpu_begin(); \ 76 + \ 77 + if (efi_scratch.use_pgd) { \ 78 + efi_scratch.prev_cr3 = read_cr3(); \ 79 + write_cr3((unsigned long)efi_scratch.efi_pgt); \ 80 + __flush_tlb_all(); \ 81 + } \ 82 + \ 88 83 __s = efi_call((void *)efi.systab->runtime->f, __VA_ARGS__); \ 84 + \ 85 + if (efi_scratch.use_pgd) { \ 86 + write_cr3(efi_scratch.prev_cr3); \ 87 + __flush_tlb_all(); \ 88 + } \ 89 + \ 89 90 __kernel_fpu_end(); \ 90 91 preempt_enable(); \ 91 92 __s; \ ··· 138 113 extern void __init efi_map_region(efi_memory_desc_t *md); 139 114 extern void __init efi_map_region_fixed(efi_memory_desc_t *md); 140 115 extern void efi_sync_low_kernel_mappings(void); 116 + extern int __init efi_alloc_page_tables(void); 141 117 extern int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages); 142 118 extern void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages); 143 119 extern void __init old_map_region(efi_memory_desc_t *md); 144 120 extern void __init runtime_code_page_mkexec(void); 145 - extern void __init efi_runtime_mkexec(void); 121 + extern void __init efi_runtime_update_mappings(void); 146 122 extern void __init efi_dump_pagetable(void); 147 123 extern void __init efi_apply_memmap_quirks(void); 148 124 extern int __init efi_reuse_config(u64 tables, int nr_tables);
+1
arch/x86/kernel/vmlinux.lds.S
··· 333 333 __brk_limit = .; 334 334 } 335 335 336 + . = ALIGN(PAGE_SIZE); 336 337 _end = .; 337 338 338 339 STABS_DEBUG
+24 -12
arch/x86/mm/pageattr.c
··· 909 909 910 910 pte = pte_offset_kernel(pmd, start); 911 911 912 + /* 913 + * Set the GLOBAL flags only if the PRESENT flag is 914 + * set otherwise pte_present will return true even on 915 + * a non present pte. The canon_pgprot will clear 916 + * _PAGE_GLOBAL for the ancient hardware that doesn't 917 + * support it. 918 + */ 919 + if (pgprot_val(pgprot) & _PAGE_PRESENT) 920 + pgprot_val(pgprot) |= _PAGE_GLOBAL; 921 + else 922 + pgprot_val(pgprot) &= ~_PAGE_GLOBAL; 923 + 924 + pgprot = canon_pgprot(pgprot); 925 + 912 926 while (num_pages-- && start < end) { 913 - 914 - /* deal with the NX bit */ 915 - if (!(pgprot_val(pgprot) & _PAGE_NX)) 916 - cpa->pfn &= ~_PAGE_NX; 917 - 918 - set_pte(pte, pfn_pte(cpa->pfn >> PAGE_SHIFT, pgprot)); 927 + set_pte(pte, pfn_pte(cpa->pfn, pgprot)); 919 928 920 929 start += PAGE_SIZE; 921 - cpa->pfn += PAGE_SIZE; 930 + cpa->pfn++; 922 931 pte++; 923 932 } 924 933 } ··· 983 974 984 975 pmd = pmd_offset(pud, start); 985 976 986 - set_pmd(pmd, __pmd(cpa->pfn | _PAGE_PSE | 977 + set_pmd(pmd, __pmd(cpa->pfn << PAGE_SHIFT | _PAGE_PSE | 987 978 massage_pgprot(pmd_pgprot))); 988 979 989 980 start += PMD_SIZE; 990 - cpa->pfn += PMD_SIZE; 981 + cpa->pfn += PMD_SIZE >> PAGE_SHIFT; 991 982 cur_pages += PMD_SIZE >> PAGE_SHIFT; 992 983 } 993 984 ··· 1055 1046 /* 1056 1047 * Map everything starting from the Gb boundary, possibly with 1G pages 1057 1048 */ 1058 - while (end - start >= PUD_SIZE) { 1059 - set_pud(pud, __pud(cpa->pfn | _PAGE_PSE | 1049 + while (cpu_has_gbpages && end - start >= PUD_SIZE) { 1050 + set_pud(pud, __pud(cpa->pfn << PAGE_SHIFT | _PAGE_PSE | 1060 1051 massage_pgprot(pud_pgprot))); 1061 1052 1062 1053 start += PUD_SIZE; 1063 - cpa->pfn += PUD_SIZE; 1054 + cpa->pfn += PUD_SIZE >> PAGE_SHIFT; 1064 1055 cur_pages += PUD_SIZE >> PAGE_SHIFT; 1065 1056 pud++; 1066 1057 } ··· 1972 1963 1973 1964 if (!(page_flags & _PAGE_NX)) 1974 1965 cpa.mask_clr = __pgprot(_PAGE_NX); 1966 + 1967 + if (!(page_flags & _PAGE_RW)) 1968 + cpa.mask_clr = __pgprot(_PAGE_RW); 1975 1969 1976 1970 cpa.mask_set = __pgprot(_PAGE_PRESENT | page_flags); 1977 1971
+22 -30
arch/x86/platform/efi/efi-bgrt.c
··· 10 10 * it under the terms of the GNU General Public License version 2 as 11 11 * published by the Free Software Foundation. 12 12 */ 13 + 14 + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 15 + 13 16 #include <linux/kernel.h> 14 17 #include <linux/init.h> 15 18 #include <linux/acpi.h> ··· 31 28 void __init efi_bgrt_init(void) 32 29 { 33 30 acpi_status status; 34 - void __iomem *image; 35 - bool ioremapped = false; 31 + void *image; 36 32 struct bmp_header bmp_header; 37 33 38 34 if (acpi_disabled) ··· 57 55 bgrt_tab->status); 58 56 return; 59 57 } 60 - if (bgrt_tab->status != 1) { 61 - pr_debug("Ignoring BGRT: invalid status %u (expected 1)\n", 62 - bgrt_tab->status); 63 - return; 64 - } 65 58 if (bgrt_tab->image_type != 0) { 66 59 pr_err("Ignoring BGRT: invalid image type %u (expected 0)\n", 67 60 bgrt_tab->image_type); ··· 67 70 return; 68 71 } 69 72 70 - image = efi_lookup_mapped_addr(bgrt_tab->image_address); 73 + image = memremap(bgrt_tab->image_address, sizeof(bmp_header), MEMREMAP_WB); 71 74 if (!image) { 72 - image = early_ioremap(bgrt_tab->image_address, 73 - sizeof(bmp_header)); 74 - ioremapped = true; 75 - if (!image) { 76 - pr_err("Ignoring BGRT: failed to map image header memory\n"); 77 - return; 78 - } 75 + pr_err("Ignoring BGRT: failed to map image header memory\n"); 76 + return; 79 77 } 80 78 81 - memcpy_fromio(&bmp_header, image, sizeof(bmp_header)); 82 - if (ioremapped) 83 - early_iounmap(image, sizeof(bmp_header)); 79 + memcpy(&bmp_header, image, sizeof(bmp_header)); 80 + memunmap(image); 81 + if (bmp_header.id != 0x4d42) { 82 + pr_err("Ignoring BGRT: Incorrect BMP magic number 0x%x (expected 0x4d42)\n", 83 + bmp_header.id); 84 + return; 85 + } 84 86 bgrt_image_size = bmp_header.size; 85 87 86 88 bgrt_image = kmalloc(bgrt_image_size, GFP_KERNEL | __GFP_NOWARN); ··· 89 93 return; 90 94 } 91 95 92 - if (ioremapped) { 93 - image = early_ioremap(bgrt_tab->image_address, 94 - bmp_header.size); 95 - if (!image) { 96 - pr_err("Ignoring BGRT: failed to map image memory\n"); 97 - kfree(bgrt_image); 98 - bgrt_image = NULL; 99 - return; 100 - } 96 + image = memremap(bgrt_tab->image_address, bmp_header.size, MEMREMAP_WB); 97 + if (!image) { 98 + pr_err("Ignoring BGRT: failed to map image memory\n"); 99 + kfree(bgrt_image); 100 + bgrt_image = NULL; 101 + return; 101 102 } 102 103 103 - memcpy_fromio(bgrt_image, image, bgrt_image_size); 104 - if (ioremapped) 105 - early_iounmap(image, bmp_header.size); 104 + memcpy(bgrt_image, image, bgrt_image_size); 105 + memunmap(image); 106 106 }
+38 -29
arch/x86/platform/efi/efi.c
··· 235 235 char buf[64]; 236 236 237 237 md = p; 238 - pr_info("mem%02u: %s range=[0x%016llx-0x%016llx) (%lluMB)\n", 238 + pr_info("mem%02u: %s range=[0x%016llx-0x%016llx] (%lluMB)\n", 239 239 i, efi_md_typeattr_format(buf, sizeof(buf), md), 240 240 md->phys_addr, 241 - md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), 241 + md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1, 242 242 (md->num_pages >> (20 - EFI_PAGE_SHIFT))); 243 243 } 244 244 #endif /* EFI_DEBUG */ ··· 815 815 { 816 816 #ifdef CONFIG_KEXEC_CORE 817 817 efi_memory_desc_t *md; 818 + unsigned int num_pages; 818 819 void *p; 819 820 820 821 efi.systab = NULL; ··· 826 825 */ 827 826 if (!efi_is_native()) { 828 827 efi_unmap_memmap(); 828 + clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); 829 + return; 830 + } 831 + 832 + if (efi_alloc_page_tables()) { 833 + pr_err("Failed to allocate EFI page tables\n"); 829 834 clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); 830 835 return; 831 836 } ··· 849 842 save_runtime_map(); 850 843 851 844 BUG_ON(!efi.systab); 845 + 846 + num_pages = ALIGN(memmap.nr_map * memmap.desc_size, PAGE_SIZE); 847 + num_pages >>= PAGE_SHIFT; 848 + 849 + if (efi_setup_page_tables(memmap.phys_map, num_pages)) { 850 + clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); 851 + return; 852 + } 852 853 853 854 efi_sync_low_kernel_mappings(); 854 855 ··· 884 869 * This function will switch the EFI runtime services to virtual mode. 885 870 * Essentially, we look through the EFI memmap and map every region that 886 871 * has the runtime attribute bit set in its memory descriptor into the 887 - * ->trampoline_pgd page table using a top-down VA allocation scheme. 872 + * efi_pgd page table. 888 873 * 889 874 * The old method which used to update that memory descriptor with the 890 875 * virtual address obtained from ioremap() is still supported when the ··· 894 879 * 895 880 * The new method does a pagetable switch in a preemption-safe manner 896 881 * so that we're in a different address space when calling a runtime 897 - * function. For function arguments passing we do copy the PGDs of the 898 - * kernel page table into ->trampoline_pgd prior to each call. 882 + * function. For function arguments passing we do copy the PUDs of the 883 + * kernel page table into efi_pgd prior to each call. 899 884 * 900 885 * Specially for kexec boot, efi runtime maps in previous kernel should 901 886 * be passed in via setup_data. In that case runtime ranges will be mapped ··· 909 894 efi_status_t status; 910 895 911 896 efi.systab = NULL; 897 + 898 + if (efi_alloc_page_tables()) { 899 + pr_err("Failed to allocate EFI page tables\n"); 900 + clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); 901 + return; 902 + } 912 903 913 904 efi_merge_regions(); 914 905 new_memmap = efi_map_regions(&count, &pg_shift); ··· 934 913 } 935 914 936 915 efi_sync_low_kernel_mappings(); 937 - efi_dump_pagetable(); 938 916 939 917 if (efi_is_native()) { 940 918 status = phys_efi_set_virtual_address_map( ··· 971 951 972 952 efi.set_virtual_address_map = NULL; 973 953 974 - efi_runtime_mkexec(); 954 + /* 955 + * Apply more restrictive page table mapping attributes now that 956 + * SVAM() has been called and the firmware has performed all 957 + * necessary relocation fixups for the new virtual addresses. 958 + */ 959 + efi_runtime_update_mappings(); 960 + efi_dump_pagetable(); 975 961 976 962 /* 977 - * We mapped the descriptor array into the EFI pagetable above but we're 978 - * not unmapping it here. Here's why: 979 - * 980 - * We're copying select PGDs from the kernel page table to the EFI page 981 - * table and when we do so and make changes to those PGDs like unmapping 982 - * stuff from them, those changes appear in the kernel page table and we 983 - * go boom. 984 - * 985 - * From setup_real_mode(): 986 - * 987 - * ... 988 - * trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd; 989 - * 990 - * In this particular case, our allocation is in PGD 0 of the EFI page 991 - * table but we've copied that PGD from PGD[272] of the EFI page table: 992 - * 993 - * pgd_index(__PAGE_OFFSET = 0xffff880000000000) = 272 994 - * 995 - * where the direct memory mapping in kernel space is. 996 - * 997 - * new_memmap's VA comes from that direct mapping and thus clearing it, 998 - * it would get cleared in the kernel page table too. 963 + * We mapped the descriptor array into the EFI pagetable above 964 + * but we're not unmapping it here because if we're running in 965 + * EFI mixed mode we need all of memory to be accessible when 966 + * we pass parameters to the EFI runtime services in the 967 + * thunking code. 999 968 * 1000 969 * efi_cleanup_page_tables(__pa(new_memmap), 1 << pg_shift); 1001 970 */
+6 -1
arch/x86/platform/efi/efi_32.c
··· 38 38 * say 0 - 3G. 39 39 */ 40 40 41 + int __init efi_alloc_page_tables(void) 42 + { 43 + return 0; 44 + } 45 + 41 46 void efi_sync_low_kernel_mappings(void) {} 42 47 void __init efi_dump_pagetable(void) {} 43 48 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) ··· 90 85 __flush_tlb_all(); 91 86 } 92 87 93 - void __init efi_runtime_mkexec(void) 88 + void __init efi_runtime_update_mappings(void) 94 89 { 95 90 if (__supported_pte_mask & _PAGE_NX) 96 91 runtime_code_page_mkexec();
+167 -39
arch/x86/platform/efi/efi_64.c
··· 15 15 * 16 16 */ 17 17 18 + #define pr_fmt(fmt) "efi: " fmt 19 + 18 20 #include <linux/kernel.h> 19 21 #include <linux/init.h> 20 22 #include <linux/mm.h> ··· 42 40 #include <asm/fixmap.h> 43 41 #include <asm/realmode.h> 44 42 #include <asm/time.h> 43 + #include <asm/pgalloc.h> 45 44 46 45 /* 47 46 * We allocate runtime services regions bottom-up, starting from -4G, i.e. ··· 50 47 */ 51 48 static u64 efi_va = EFI_VA_START; 52 49 53 - /* 54 - * Scratch space used for switching the pagetable in the EFI stub 55 - */ 56 - struct efi_scratch { 57 - u64 r15; 58 - u64 prev_cr3; 59 - pgd_t *efi_pgt; 60 - bool use_pgd; 61 - u64 phys_stack; 62 - } __packed; 50 + struct efi_scratch efi_scratch; 63 51 64 52 static void __init early_code_mapping_set_exec(int executable) 65 53 { ··· 77 83 int pgd; 78 84 int n_pgds; 79 85 80 - if (!efi_enabled(EFI_OLD_MEMMAP)) 81 - return NULL; 86 + if (!efi_enabled(EFI_OLD_MEMMAP)) { 87 + save_pgd = (pgd_t *)read_cr3(); 88 + write_cr3((unsigned long)efi_scratch.efi_pgt); 89 + goto out; 90 + } 82 91 83 92 early_code_mapping_set_exec(1); 84 93 ··· 93 96 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE); 94 97 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress)); 95 98 } 99 + out: 96 100 __flush_tlb_all(); 97 101 98 102 return save_pgd; ··· 107 109 int pgd_idx; 108 110 int nr_pgds; 109 111 110 - if (!save_pgd) 112 + if (!efi_enabled(EFI_OLD_MEMMAP)) { 113 + write_cr3((unsigned long)save_pgd); 114 + __flush_tlb_all(); 111 115 return; 116 + } 112 117 113 118 nr_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT) , PGDIR_SIZE); 114 119 ··· 124 123 early_code_mapping_set_exec(0); 125 124 } 126 125 126 + static pgd_t *efi_pgd; 127 + 128 + /* 129 + * We need our own copy of the higher levels of the page tables 130 + * because we want to avoid inserting EFI region mappings (EFI_VA_END 131 + * to EFI_VA_START) into the standard kernel page tables. Everything 132 + * else can be shared, see efi_sync_low_kernel_mappings(). 133 + */ 134 + int __init efi_alloc_page_tables(void) 135 + { 136 + pgd_t *pgd; 137 + pud_t *pud; 138 + gfp_t gfp_mask; 139 + 140 + if (efi_enabled(EFI_OLD_MEMMAP)) 141 + return 0; 142 + 143 + gfp_mask = GFP_KERNEL | __GFP_NOTRACK | __GFP_REPEAT | __GFP_ZERO; 144 + efi_pgd = (pgd_t *)__get_free_page(gfp_mask); 145 + if (!efi_pgd) 146 + return -ENOMEM; 147 + 148 + pgd = efi_pgd + pgd_index(EFI_VA_END); 149 + 150 + pud = pud_alloc_one(NULL, 0); 151 + if (!pud) { 152 + free_page((unsigned long)efi_pgd); 153 + return -ENOMEM; 154 + } 155 + 156 + pgd_populate(NULL, pgd, pud); 157 + 158 + return 0; 159 + } 160 + 127 161 /* 128 162 * Add low kernel mappings for passing arguments to EFI functions. 129 163 */ 130 164 void efi_sync_low_kernel_mappings(void) 131 165 { 132 - unsigned num_pgds; 133 - pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd); 166 + unsigned num_entries; 167 + pgd_t *pgd_k, *pgd_efi; 168 + pud_t *pud_k, *pud_efi; 134 169 135 170 if (efi_enabled(EFI_OLD_MEMMAP)) 136 171 return; 137 172 138 - num_pgds = pgd_index(MODULES_END - 1) - pgd_index(PAGE_OFFSET); 173 + /* 174 + * We can share all PGD entries apart from the one entry that 175 + * covers the EFI runtime mapping space. 176 + * 177 + * Make sure the EFI runtime region mappings are guaranteed to 178 + * only span a single PGD entry and that the entry also maps 179 + * other important kernel regions. 180 + */ 181 + BUILD_BUG_ON(pgd_index(EFI_VA_END) != pgd_index(MODULES_END)); 182 + BUILD_BUG_ON((EFI_VA_START & PGDIR_MASK) != 183 + (EFI_VA_END & PGDIR_MASK)); 139 184 140 - memcpy(pgd + pgd_index(PAGE_OFFSET), 141 - init_mm.pgd + pgd_index(PAGE_OFFSET), 142 - sizeof(pgd_t) * num_pgds); 185 + pgd_efi = efi_pgd + pgd_index(PAGE_OFFSET); 186 + pgd_k = pgd_offset_k(PAGE_OFFSET); 187 + 188 + num_entries = pgd_index(EFI_VA_END) - pgd_index(PAGE_OFFSET); 189 + memcpy(pgd_efi, pgd_k, sizeof(pgd_t) * num_entries); 190 + 191 + /* 192 + * We share all the PUD entries apart from those that map the 193 + * EFI regions. Copy around them. 194 + */ 195 + BUILD_BUG_ON((EFI_VA_START & ~PUD_MASK) != 0); 196 + BUILD_BUG_ON((EFI_VA_END & ~PUD_MASK) != 0); 197 + 198 + pgd_efi = efi_pgd + pgd_index(EFI_VA_END); 199 + pud_efi = pud_offset(pgd_efi, 0); 200 + 201 + pgd_k = pgd_offset_k(EFI_VA_END); 202 + pud_k = pud_offset(pgd_k, 0); 203 + 204 + num_entries = pud_index(EFI_VA_END); 205 + memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries); 206 + 207 + pud_efi = pud_offset(pgd_efi, EFI_VA_START); 208 + pud_k = pud_offset(pgd_k, EFI_VA_START); 209 + 210 + num_entries = PTRS_PER_PUD - pud_index(EFI_VA_START); 211 + memcpy(pud_efi, pud_k, sizeof(pud_t) * num_entries); 143 212 } 144 213 145 214 int __init efi_setup_page_tables(unsigned long pa_memmap, unsigned num_pages) 146 215 { 147 - unsigned long text; 216 + unsigned long pfn, text; 217 + efi_memory_desc_t *md; 148 218 struct page *page; 149 219 unsigned npages; 150 220 pgd_t *pgd; ··· 223 151 if (efi_enabled(EFI_OLD_MEMMAP)) 224 152 return 0; 225 153 226 - efi_scratch.efi_pgt = (pgd_t *)(unsigned long)real_mode_header->trampoline_pgd; 227 - pgd = __va(efi_scratch.efi_pgt); 154 + efi_scratch.efi_pgt = (pgd_t *)__pa(efi_pgd); 155 + pgd = efi_pgd; 228 156 229 157 /* 230 158 * It can happen that the physical address of new_memmap lands in memory ··· 232 160 * and ident-map those pages containing the map before calling 233 161 * phys_efi_set_virtual_address_map(). 234 162 */ 235 - if (kernel_map_pages_in_pgd(pgd, pa_memmap, pa_memmap, num_pages, _PAGE_NX)) { 163 + pfn = pa_memmap >> PAGE_SHIFT; 164 + if (kernel_map_pages_in_pgd(pgd, pfn, pa_memmap, num_pages, _PAGE_NX | _PAGE_RW)) { 236 165 pr_err("Error ident-mapping new memmap (0x%lx)!\n", pa_memmap); 237 166 return 1; 238 167 } ··· 249 176 if (!IS_ENABLED(CONFIG_EFI_MIXED)) 250 177 return 0; 251 178 179 + /* 180 + * Map all of RAM so that we can access arguments in the 1:1 181 + * mapping when making EFI runtime calls. 182 + */ 183 + for_each_efi_memory_desc(&memmap, md) { 184 + if (md->type != EFI_CONVENTIONAL_MEMORY && 185 + md->type != EFI_LOADER_DATA && 186 + md->type != EFI_LOADER_CODE) 187 + continue; 188 + 189 + pfn = md->phys_addr >> PAGE_SHIFT; 190 + npages = md->num_pages; 191 + 192 + if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, npages, _PAGE_RW)) { 193 + pr_err("Failed to map 1:1 memory\n"); 194 + return 1; 195 + } 196 + } 197 + 252 198 page = alloc_page(GFP_KERNEL|__GFP_DMA32); 253 199 if (!page) 254 200 panic("Unable to allocate EFI runtime stack < 4GB\n"); ··· 275 183 efi_scratch.phys_stack = virt_to_phys(page_address(page)); 276 184 efi_scratch.phys_stack += PAGE_SIZE; /* stack grows down */ 277 185 278 - npages = (_end - _text) >> PAGE_SHIFT; 186 + npages = (_etext - _text) >> PAGE_SHIFT; 279 187 text = __pa(_text); 188 + pfn = text >> PAGE_SHIFT; 280 189 281 - if (kernel_map_pages_in_pgd(pgd, text >> PAGE_SHIFT, text, npages, 0)) { 190 + if (kernel_map_pages_in_pgd(pgd, pfn, text, npages, _PAGE_RW)) { 282 191 pr_err("Failed to map kernel text 1:1\n"); 283 192 return 1; 284 193 } ··· 289 196 290 197 void __init efi_cleanup_page_tables(unsigned long pa_memmap, unsigned num_pages) 291 198 { 292 - pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd); 293 - 294 - kernel_unmap_pages_in_pgd(pgd, pa_memmap, num_pages); 199 + kernel_unmap_pages_in_pgd(efi_pgd, pa_memmap, num_pages); 295 200 } 296 201 297 202 static void __init __map_region(efi_memory_desc_t *md, u64 va) 298 203 { 299 - pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd); 300 - unsigned long pf = 0; 204 + unsigned long flags = _PAGE_RW; 205 + unsigned long pfn; 206 + pgd_t *pgd = efi_pgd; 301 207 302 208 if (!(md->attribute & EFI_MEMORY_WB)) 303 - pf |= _PAGE_PCD; 209 + flags |= _PAGE_PCD; 304 210 305 - if (kernel_map_pages_in_pgd(pgd, md->phys_addr, va, md->num_pages, pf)) 211 + pfn = md->phys_addr >> PAGE_SHIFT; 212 + if (kernel_map_pages_in_pgd(pgd, pfn, va, md->num_pages, flags)) 306 213 pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n", 307 214 md->phys_addr, va); 308 215 } ··· 393 300 efi_setup = phys_addr + sizeof(struct setup_data); 394 301 } 395 302 396 - void __init efi_runtime_mkexec(void) 303 + void __init efi_runtime_update_mappings(void) 397 304 { 398 - if (!efi_enabled(EFI_OLD_MEMMAP)) 305 + unsigned long pfn; 306 + pgd_t *pgd = efi_pgd; 307 + efi_memory_desc_t *md; 308 + void *p; 309 + 310 + if (efi_enabled(EFI_OLD_MEMMAP)) { 311 + if (__supported_pte_mask & _PAGE_NX) 312 + runtime_code_page_mkexec(); 313 + return; 314 + } 315 + 316 + if (!efi_enabled(EFI_NX_PE_DATA)) 399 317 return; 400 318 401 - if (__supported_pte_mask & _PAGE_NX) 402 - runtime_code_page_mkexec(); 319 + for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { 320 + unsigned long pf = 0; 321 + md = p; 322 + 323 + if (!(md->attribute & EFI_MEMORY_RUNTIME)) 324 + continue; 325 + 326 + if (!(md->attribute & EFI_MEMORY_WB)) 327 + pf |= _PAGE_PCD; 328 + 329 + if ((md->attribute & EFI_MEMORY_XP) || 330 + (md->type == EFI_RUNTIME_SERVICES_DATA)) 331 + pf |= _PAGE_NX; 332 + 333 + if (!(md->attribute & EFI_MEMORY_RO) && 334 + (md->type != EFI_RUNTIME_SERVICES_CODE)) 335 + pf |= _PAGE_RW; 336 + 337 + /* Update the 1:1 mapping */ 338 + pfn = md->phys_addr >> PAGE_SHIFT; 339 + if (kernel_map_pages_in_pgd(pgd, pfn, md->phys_addr, md->num_pages, pf)) 340 + pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n", 341 + md->phys_addr, md->virt_addr); 342 + 343 + if (kernel_map_pages_in_pgd(pgd, pfn, md->virt_addr, md->num_pages, pf)) 344 + pr_warn("Error mapping PA 0x%llx -> VA 0x%llx!\n", 345 + md->phys_addr, md->virt_addr); 346 + } 403 347 } 404 348 405 349 void __init efi_dump_pagetable(void) 406 350 { 407 351 #ifdef CONFIG_EFI_PGT_DUMP 408 - pgd_t *pgd = (pgd_t *)__va(real_mode_header->trampoline_pgd); 409 - 410 - ptdump_walk_pgd_level(NULL, pgd); 352 + ptdump_walk_pgd_level(NULL, efi_pgd); 411 353 #endif 412 354 } 413 355
-43
arch/x86/platform/efi/efi_stub_64.S
··· 39 39 mov %rsi, %cr0; \ 40 40 mov (%rsp), %rsp 41 41 42 - /* stolen from gcc */ 43 - .macro FLUSH_TLB_ALL 44 - movq %r15, efi_scratch(%rip) 45 - movq %r14, efi_scratch+8(%rip) 46 - movq %cr4, %r15 47 - movq %r15, %r14 48 - andb $0x7f, %r14b 49 - movq %r14, %cr4 50 - movq %r15, %cr4 51 - movq efi_scratch+8(%rip), %r14 52 - movq efi_scratch(%rip), %r15 53 - .endm 54 - 55 - .macro SWITCH_PGT 56 - cmpb $0, efi_scratch+24(%rip) 57 - je 1f 58 - movq %r15, efi_scratch(%rip) # r15 59 - # save previous CR3 60 - movq %cr3, %r15 61 - movq %r15, efi_scratch+8(%rip) # prev_cr3 62 - movq efi_scratch+16(%rip), %r15 # EFI pgt 63 - movq %r15, %cr3 64 - 1: 65 - .endm 66 - 67 - .macro RESTORE_PGT 68 - cmpb $0, efi_scratch+24(%rip) 69 - je 2f 70 - movq efi_scratch+8(%rip), %r15 71 - movq %r15, %cr3 72 - movq efi_scratch(%rip), %r15 73 - FLUSH_TLB_ALL 74 - 2: 75 - .endm 76 - 77 42 ENTRY(efi_call) 78 43 FRAME_BEGIN 79 44 SAVE_XMM ··· 50 85 mov %r8, %r9 51 86 mov %rcx, %r8 52 87 mov %rsi, %rcx 53 - SWITCH_PGT 54 88 call *%rdi 55 - RESTORE_PGT 56 89 addq $48, %rsp 57 90 RESTORE_XMM 58 91 FRAME_END 59 92 ret 60 93 ENDPROC(efi_call) 61 - 62 - .data 63 - ENTRY(efi_scratch) 64 - .fill 3,8,0 65 - .byte 0 66 - .quad 0
+35 -2
arch/x86/platform/efi/quirks.c
··· 1 + #define pr_fmt(fmt) "efi: " fmt 2 + 1 3 #include <linux/init.h> 2 4 #include <linux/kernel.h> 3 5 #include <linux/string.h> ··· 57 55 } 58 56 59 57 /* 58 + * In the nonblocking case we do not attempt to perform garbage 59 + * collection if we do not have enough free space. Rather, we do the 60 + * bare minimum check and give up immediately if the available space 61 + * is below EFI_MIN_RESERVE. 62 + * 63 + * This function is intended to be small and simple because it is 64 + * invoked from crash handler paths. 65 + */ 66 + static efi_status_t 67 + query_variable_store_nonblocking(u32 attributes, unsigned long size) 68 + { 69 + efi_status_t status; 70 + u64 storage_size, remaining_size, max_size; 71 + 72 + status = efi.query_variable_info_nonblocking(attributes, &storage_size, 73 + &remaining_size, 74 + &max_size); 75 + if (status != EFI_SUCCESS) 76 + return status; 77 + 78 + if (remaining_size - size < EFI_MIN_RESERVE) 79 + return EFI_OUT_OF_RESOURCES; 80 + 81 + return EFI_SUCCESS; 82 + } 83 + 84 + /* 60 85 * Some firmware implementations refuse to boot if there's insufficient space 61 86 * in the variable store. Ensure that we never use more than a safe limit. 62 87 * 63 88 * Return EFI_SUCCESS if it is safe to write 'size' bytes to the variable 64 89 * store. 65 90 */ 66 - efi_status_t efi_query_variable_store(u32 attributes, unsigned long size) 91 + efi_status_t efi_query_variable_store(u32 attributes, unsigned long size, 92 + bool nonblocking) 67 93 { 68 94 efi_status_t status; 69 95 u64 storage_size, remaining_size, max_size; 70 96 71 97 if (!(attributes & EFI_VARIABLE_NON_VOLATILE)) 72 98 return 0; 99 + 100 + if (nonblocking) 101 + return query_variable_store_nonblocking(attributes, size); 73 102 74 103 status = efi.query_variable_info(attributes, &storage_size, 75 104 &remaining_size, &max_size); ··· 345 312 * services. 346 313 */ 347 314 if (!efi_runtime_supported()) { 348 - pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n"); 315 + pr_info("Setup done, disabling due to 32/64-bit mismatch\n"); 349 316 efi_unmap_memmap(); 350 317 } 351 318
+7 -7
drivers/firmware/efi/arm-init.c
··· 61 61 char vendor[100] = "unknown"; 62 62 int i, retval; 63 63 64 - efi.systab = early_memremap(efi_system_table, 65 - sizeof(efi_system_table_t)); 64 + efi.systab = early_memremap_ro(efi_system_table, 65 + sizeof(efi_system_table_t)); 66 66 if (efi.systab == NULL) { 67 67 pr_warn("Unable to map EFI system table.\n"); 68 68 return -ENOMEM; ··· 86 86 efi.systab->hdr.revision & 0xffff); 87 87 88 88 /* Show what we know for posterity */ 89 - c16 = early_memremap(efi_to_phys(efi.systab->fw_vendor), 90 - sizeof(vendor) * sizeof(efi_char16_t)); 89 + c16 = early_memremap_ro(efi_to_phys(efi.systab->fw_vendor), 90 + sizeof(vendor) * sizeof(efi_char16_t)); 91 91 if (c16) { 92 92 for (i = 0; i < (int) sizeof(vendor) - 1 && *c16; ++i) 93 93 vendor[i] = c16[i]; ··· 100 100 efi.systab->hdr.revision & 0xffff, vendor); 101 101 102 102 table_size = sizeof(efi_config_table_64_t) * efi.systab->nr_tables; 103 - config_tables = early_memremap(efi_to_phys(efi.systab->tables), 104 - table_size); 103 + config_tables = early_memremap_ro(efi_to_phys(efi.systab->tables), 104 + table_size); 105 105 if (config_tables == NULL) { 106 106 pr_warn("Unable to map EFI config table array.\n"); 107 107 retval = -ENOMEM; ··· 185 185 efi_system_table = params.system_table; 186 186 187 187 memmap.phys_map = params.mmap; 188 - memmap.map = early_memremap(params.mmap, params.mmap_size); 188 + memmap.map = early_memremap_ro(params.mmap, params.mmap_size); 189 189 if (memmap.map == NULL) { 190 190 /* 191 191 * If we are booting via UEFI, the UEFI memory map is the only
+7 -34
drivers/firmware/efi/efi.c
··· 182 182 { 183 183 generic_ops.get_variable = efi.get_variable; 184 184 generic_ops.set_variable = efi.set_variable; 185 + generic_ops.set_variable_nonblocking = efi.set_variable_nonblocking; 185 186 generic_ops.get_next_variable = efi.get_next_variable; 186 187 generic_ops.query_variable_store = efi_query_variable_store; 187 188 ··· 325 324 u64 size = md->num_pages << EFI_PAGE_SHIFT; 326 325 u64 end = md->phys_addr + size; 327 326 return end; 328 - } 329 - 330 - /* 331 - * We can't ioremap data in EFI boot services RAM, because we've already mapped 332 - * it as RAM. So, look it up in the existing EFI memory map instead. Only 333 - * callable after efi_enter_virtual_mode and before efi_free_boot_services. 334 - */ 335 - void __iomem *efi_lookup_mapped_addr(u64 phys_addr) 336 - { 337 - struct efi_memory_map *map; 338 - void *p; 339 - map = efi.memmap; 340 - if (!map) 341 - return NULL; 342 - if (WARN_ON(!map->map)) 343 - return NULL; 344 - for (p = map->map; p < map->map_end; p += map->desc_size) { 345 - efi_memory_desc_t *md = p; 346 - u64 size = md->num_pages << EFI_PAGE_SHIFT; 347 - u64 end = md->phys_addr + size; 348 - if (!(md->attribute & EFI_MEMORY_RUNTIME) && 349 - md->type != EFI_BOOT_SERVICES_CODE && 350 - md->type != EFI_BOOT_SERVICES_DATA) 351 - continue; 352 - if (!md->virt_addr) 353 - continue; 354 - if (phys_addr >= md->phys_addr && phys_addr < end) { 355 - phys_addr += md->virt_addr - md->phys_addr; 356 - return (__force void __iomem *)(unsigned long)phys_addr; 357 - } 358 - } 359 - return NULL; 360 327 } 361 328 362 329 static __initdata efi_config_table_type_t common_tables[] = { ··· 555 586 "ACPI Memory NVS", 556 587 "Memory Mapped I/O", 557 588 "MMIO Port Space", 558 - "PAL Code" 589 + "PAL Code", 590 + "Persistent Memory", 559 591 }; 560 592 561 593 char * __init efi_md_typeattr_format(char *buf, size_t size, ··· 583 613 if (attr & ~(EFI_MEMORY_UC | EFI_MEMORY_WC | EFI_MEMORY_WT | 584 614 EFI_MEMORY_WB | EFI_MEMORY_UCE | EFI_MEMORY_RO | 585 615 EFI_MEMORY_WP | EFI_MEMORY_RP | EFI_MEMORY_XP | 616 + EFI_MEMORY_NV | 586 617 EFI_MEMORY_RUNTIME | EFI_MEMORY_MORE_RELIABLE)) 587 618 snprintf(pos, size, "|attr=0x%016llx]", 588 619 (unsigned long long)attr); 589 620 else 590 - snprintf(pos, size, "|%3s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", 621 + snprintf(pos, size, 622 + "|%3s|%2s|%2s|%2s|%2s|%2s|%2s|%3s|%2s|%2s|%2s|%2s]", 591 623 attr & EFI_MEMORY_RUNTIME ? "RUN" : "", 592 624 attr & EFI_MEMORY_MORE_RELIABLE ? "MR" : "", 625 + attr & EFI_MEMORY_NV ? "NV" : "", 593 626 attr & EFI_MEMORY_XP ? "XP" : "", 594 627 attr & EFI_MEMORY_RP ? "RP" : "", 595 628 attr & EFI_MEMORY_WP ? "WP" : "",
+1 -1
drivers/firmware/efi/efivars.c
··· 386 386 387 387 static void efivar_release(struct kobject *kobj) 388 388 { 389 - struct efivar_entry *var = container_of(kobj, struct efivar_entry, kobj); 389 + struct efivar_entry *var = to_efivar_entry(kobj); 390 390 kfree(var); 391 391 } 392 392
+1 -4
drivers/firmware/efi/esrt.c
··· 167 167 static int esre_create_sysfs_entry(void *esre, int entry_num) 168 168 { 169 169 struct esre_entry *entry; 170 - char name[20]; 171 170 172 171 entry = kzalloc(sizeof(*entry), GFP_KERNEL); 173 172 if (!entry) 174 173 return -ENOMEM; 175 - 176 - sprintf(name, "entry%d", entry_num); 177 174 178 175 entry->kobj.kset = esrt_kset; 179 176 ··· 179 182 180 183 entry->esre.esre1 = esre; 181 184 rc = kobject_init_and_add(&entry->kobj, &esre1_ktype, NULL, 182 - "%s", name); 185 + "entry%d", entry_num); 183 186 if (rc) { 184 187 kfree(entry); 185 188 return rc;
+4
drivers/firmware/efi/libstub/arm-stub.c
··· 192 192 193 193 pr_efi(sys_table, "Booting Linux Kernel...\n"); 194 194 195 + status = check_platform_features(sys_table); 196 + if (status != EFI_SUCCESS) 197 + goto fail; 198 + 195 199 /* 196 200 * Get a handle to the loaded image protocol. This is used to get 197 201 * information about the running image, such as size and the command
+17
drivers/firmware/efi/libstub/arm32-stub.c
··· 9 9 #include <linux/efi.h> 10 10 #include <asm/efi.h> 11 11 12 + efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) 13 + { 14 + int block; 15 + 16 + /* non-LPAE kernels can run anywhere */ 17 + if (!IS_ENABLED(CONFIG_ARM_LPAE)) 18 + return EFI_SUCCESS; 19 + 20 + /* LPAE kernels need compatible hardware */ 21 + block = cpuid_feature_extract(CPUID_EXT_MMFR0, 0); 22 + if (block < 5) { 23 + pr_efi_err(sys_table_arg, "This LPAE kernel is not supported by your CPU\n"); 24 + return EFI_UNSUPPORTED; 25 + } 26 + return EFI_SUCCESS; 27 + } 28 + 12 29 efi_status_t handle_kernel_image(efi_system_table_t *sys_table, 13 30 unsigned long *image_addr, 14 31 unsigned long *image_size,
+27 -7
drivers/firmware/efi/libstub/arm64-stub.c
··· 12 12 #include <linux/efi.h> 13 13 #include <asm/efi.h> 14 14 #include <asm/sections.h> 15 + #include <asm/sysreg.h> 15 16 16 17 #include "efistub.h" 17 18 18 19 extern bool __nokaslr; 19 20 20 - efi_status_t __init handle_kernel_image(efi_system_table_t *sys_table_arg, 21 - unsigned long *image_addr, 22 - unsigned long *image_size, 23 - unsigned long *reserve_addr, 24 - unsigned long *reserve_size, 25 - unsigned long dram_base, 26 - efi_loaded_image_t *image) 21 + efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) 22 + { 23 + u64 tg; 24 + 25 + /* UEFI mandates support for 4 KB granularity, no need to check */ 26 + if (IS_ENABLED(CONFIG_ARM64_4K_PAGES)) 27 + return EFI_SUCCESS; 28 + 29 + tg = (read_cpuid(ID_AA64MMFR0_EL1) >> ID_AA64MMFR0_TGRAN_SHIFT) & 0xf; 30 + if (tg != ID_AA64MMFR0_TGRAN_SUPPORTED) { 31 + if (IS_ENABLED(CONFIG_ARM64_64K_PAGES)) 32 + pr_efi_err(sys_table_arg, "This 64 KB granular kernel is not supported by your CPU\n"); 33 + else 34 + pr_efi_err(sys_table_arg, "This 16 KB granular kernel is not supported by your CPU\n"); 35 + return EFI_UNSUPPORTED; 36 + } 37 + return EFI_SUCCESS; 38 + } 39 + 40 + efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg, 41 + unsigned long *image_addr, 42 + unsigned long *image_size, 43 + unsigned long *reserve_addr, 44 + unsigned long *reserve_size, 45 + unsigned long dram_base, 46 + efi_loaded_image_t *image) 27 47 { 28 48 efi_status_t status; 29 49 unsigned long kernel_size, kernel_memsize = 0;
+12
drivers/firmware/efi/libstub/efistub.h
··· 5 5 /* error code which can't be mistaken for valid address */ 6 6 #define EFI_ERROR (~0UL) 7 7 8 + /* 9 + * __init annotations should not be used in the EFI stub, since the code is 10 + * either included in the decompressor (x86, ARM) where they have no effect, 11 + * or the whole stub is __init annotated at the section level (arm64), by 12 + * renaming the sections, in which case the __init annotation will be 13 + * redundant, and will result in section names like .init.init.text, and our 14 + * linker script does not expect that. 15 + */ 16 + #undef __init 17 + 8 18 void efi_char16_printk(efi_system_table_t *, efi_char16_t *); 9 19 10 20 efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image, ··· 59 49 efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, 60 50 unsigned long size, unsigned long align, 61 51 unsigned long *addr, unsigned long random_seed); 52 + 53 + efi_status_t check_platform_features(efi_system_table_t *sys_table_arg); 62 54 63 55 #endif
+39 -74
drivers/firmware/efi/runtime-wrappers.c
··· 61 61 */ 62 62 static DEFINE_SPINLOCK(efi_runtime_lock); 63 63 64 - /* 65 - * Some runtime services calls can be reentrant under NMI, even if the table 66 - * above says they are not. (source: UEFI Specification v2.4A) 67 - * 68 - * Table 32. Functions that may be called after Machine Check, INIT and NMI 69 - * +----------------------------+------------------------------------------+ 70 - * | Function | Called after Machine Check, INIT and NMI | 71 - * +----------------------------+------------------------------------------+ 72 - * | GetTime() | Yes, even if previously busy. | 73 - * | GetVariable() | Yes, even if previously busy | 74 - * | GetNextVariableName() | Yes, even if previously busy | 75 - * | QueryVariableInfo() | Yes, even if previously busy | 76 - * | SetVariable() | Yes, even if previously busy | 77 - * | UpdateCapsule() | Yes, even if previously busy | 78 - * | QueryCapsuleCapabilities() | Yes, even if previously busy | 79 - * | ResetSystem() | Yes, even if previously busy | 80 - * +----------------------------+------------------------------------------+ 81 - * 82 - * In order to prevent deadlocks under NMI, the wrappers for these functions 83 - * may only grab the efi_runtime_lock or rtc_lock spinlocks if !efi_in_nmi(). 84 - * However, not all of the services listed are reachable through NMI code paths, 85 - * so the the special handling as suggested by the UEFI spec is only implemented 86 - * for QueryVariableInfo() and SetVariable(), as these can be reached in NMI 87 - * context through efi_pstore_write(). 88 - */ 89 - 90 - /* 91 - * As per commit ef68c8f87ed1 ("x86: Serialize EFI time accesses on rtc_lock"), 92 - * the EFI specification requires that callers of the time related runtime 93 - * functions serialize with other CMOS accesses in the kernel, as the EFI time 94 - * functions may choose to also use the legacy CMOS RTC. 95 - */ 96 - __weak DEFINE_SPINLOCK(rtc_lock); 97 - 98 64 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc) 99 65 { 100 - unsigned long flags; 101 66 efi_status_t status; 102 67 103 - spin_lock_irqsave(&rtc_lock, flags); 104 68 spin_lock(&efi_runtime_lock); 105 69 status = efi_call_virt(get_time, tm, tc); 106 70 spin_unlock(&efi_runtime_lock); 107 - spin_unlock_irqrestore(&rtc_lock, flags); 108 71 return status; 109 72 } 110 73 111 74 static efi_status_t virt_efi_set_time(efi_time_t *tm) 112 75 { 113 - unsigned long flags; 114 76 efi_status_t status; 115 77 116 - spin_lock_irqsave(&rtc_lock, flags); 117 78 spin_lock(&efi_runtime_lock); 118 79 status = efi_call_virt(set_time, tm); 119 80 spin_unlock(&efi_runtime_lock); 120 - spin_unlock_irqrestore(&rtc_lock, flags); 121 81 return status; 122 82 } 123 83 ··· 85 125 efi_bool_t *pending, 86 126 efi_time_t *tm) 87 127 { 88 - unsigned long flags; 89 128 efi_status_t status; 90 129 91 - spin_lock_irqsave(&rtc_lock, flags); 92 130 spin_lock(&efi_runtime_lock); 93 131 status = efi_call_virt(get_wakeup_time, enabled, pending, tm); 94 132 spin_unlock(&efi_runtime_lock); 95 - spin_unlock_irqrestore(&rtc_lock, flags); 96 133 return status; 97 134 } 98 135 99 136 static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) 100 137 { 101 - unsigned long flags; 102 138 efi_status_t status; 103 139 104 - spin_lock_irqsave(&rtc_lock, flags); 105 140 spin_lock(&efi_runtime_lock); 106 141 status = efi_call_virt(set_wakeup_time, enabled, tm); 107 142 spin_unlock(&efi_runtime_lock); 108 - spin_unlock_irqrestore(&rtc_lock, flags); 109 143 return status; 110 144 } 111 145 ··· 109 155 unsigned long *data_size, 110 156 void *data) 111 157 { 112 - unsigned long flags; 113 158 efi_status_t status; 114 159 115 - spin_lock_irqsave(&efi_runtime_lock, flags); 160 + spin_lock(&efi_runtime_lock); 116 161 status = efi_call_virt(get_variable, name, vendor, attr, data_size, 117 162 data); 118 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 163 + spin_unlock(&efi_runtime_lock); 119 164 return status; 120 165 } 121 166 ··· 122 169 efi_char16_t *name, 123 170 efi_guid_t *vendor) 124 171 { 125 - unsigned long flags; 126 172 efi_status_t status; 127 173 128 - spin_lock_irqsave(&efi_runtime_lock, flags); 174 + spin_lock(&efi_runtime_lock); 129 175 status = efi_call_virt(get_next_variable, name_size, name, vendor); 130 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 176 + spin_unlock(&efi_runtime_lock); 131 177 return status; 132 178 } 133 179 ··· 136 184 unsigned long data_size, 137 185 void *data) 138 186 { 139 - unsigned long flags; 140 187 efi_status_t status; 141 188 142 - spin_lock_irqsave(&efi_runtime_lock, flags); 189 + spin_lock(&efi_runtime_lock); 143 190 status = efi_call_virt(set_variable, name, vendor, attr, data_size, 144 191 data); 145 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 192 + spin_unlock(&efi_runtime_lock); 146 193 return status; 147 194 } 148 195 ··· 150 199 u32 attr, unsigned long data_size, 151 200 void *data) 152 201 { 153 - unsigned long flags; 154 202 efi_status_t status; 155 203 156 - if (!spin_trylock_irqsave(&efi_runtime_lock, flags)) 204 + if (!spin_trylock(&efi_runtime_lock)) 157 205 return EFI_NOT_READY; 158 206 159 207 status = efi_call_virt(set_variable, name, vendor, attr, data_size, 160 208 data); 161 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 209 + spin_unlock(&efi_runtime_lock); 162 210 return status; 163 211 } 164 212 ··· 167 217 u64 *remaining_space, 168 218 u64 *max_variable_size) 169 219 { 170 - unsigned long flags; 171 220 efi_status_t status; 172 221 173 222 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 174 223 return EFI_UNSUPPORTED; 175 224 176 - spin_lock_irqsave(&efi_runtime_lock, flags); 225 + spin_lock(&efi_runtime_lock); 177 226 status = efi_call_virt(query_variable_info, attr, storage_space, 178 227 remaining_space, max_variable_size); 179 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 228 + spin_unlock(&efi_runtime_lock); 229 + return status; 230 + } 231 + 232 + static efi_status_t 233 + virt_efi_query_variable_info_nonblocking(u32 attr, 234 + u64 *storage_space, 235 + u64 *remaining_space, 236 + u64 *max_variable_size) 237 + { 238 + efi_status_t status; 239 + 240 + if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 241 + return EFI_UNSUPPORTED; 242 + 243 + if (!spin_trylock(&efi_runtime_lock)) 244 + return EFI_NOT_READY; 245 + 246 + status = efi_call_virt(query_variable_info, attr, storage_space, 247 + remaining_space, max_variable_size); 248 + spin_unlock(&efi_runtime_lock); 180 249 return status; 181 250 } 182 251 183 252 static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) 184 253 { 185 - unsigned long flags; 186 254 efi_status_t status; 187 255 188 - spin_lock_irqsave(&efi_runtime_lock, flags); 256 + spin_lock(&efi_runtime_lock); 189 257 status = efi_call_virt(get_next_high_mono_count, count); 190 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 258 + spin_unlock(&efi_runtime_lock); 191 259 return status; 192 260 } 193 261 ··· 214 246 unsigned long data_size, 215 247 efi_char16_t *data) 216 248 { 217 - unsigned long flags; 218 - 219 - spin_lock_irqsave(&efi_runtime_lock, flags); 249 + spin_lock(&efi_runtime_lock); 220 250 __efi_call_virt(reset_system, reset_type, status, data_size, data); 221 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 251 + spin_unlock(&efi_runtime_lock); 222 252 } 223 253 224 254 static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, 225 255 unsigned long count, 226 256 unsigned long sg_list) 227 257 { 228 - unsigned long flags; 229 258 efi_status_t status; 230 259 231 260 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 232 261 return EFI_UNSUPPORTED; 233 262 234 - spin_lock_irqsave(&efi_runtime_lock, flags); 263 + spin_lock(&efi_runtime_lock); 235 264 status = efi_call_virt(update_capsule, capsules, count, sg_list); 236 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 265 + spin_unlock(&efi_runtime_lock); 237 266 return status; 238 267 } 239 268 ··· 239 274 u64 *max_size, 240 275 int *reset_type) 241 276 { 242 - unsigned long flags; 243 277 efi_status_t status; 244 278 245 279 if (efi.runtime_version < EFI_2_00_SYSTEM_TABLE_REVISION) 246 280 return EFI_UNSUPPORTED; 247 281 248 - spin_lock_irqsave(&efi_runtime_lock, flags); 282 + spin_lock(&efi_runtime_lock); 249 283 status = efi_call_virt(query_capsule_caps, capsules, count, max_size, 250 284 reset_type); 251 - spin_unlock_irqrestore(&efi_runtime_lock, flags); 285 + spin_unlock(&efi_runtime_lock); 252 286 return status; 253 287 } 254 288 ··· 264 300 efi.get_next_high_mono_count = virt_efi_get_next_high_mono_count; 265 301 efi.reset_system = virt_efi_reset_system; 266 302 efi.query_variable_info = virt_efi_query_variable_info; 303 + efi.query_variable_info_nonblocking = virt_efi_query_variable_info_nonblocking; 267 304 efi.update_capsule = virt_efi_update_capsule; 268 305 efi.query_capsule_caps = virt_efi_query_capsule_caps; 269 306 }
+14 -2
drivers/firmware/efi/vars.c
··· 300 300 if (!fops->query_variable_store) 301 301 return EFI_UNSUPPORTED; 302 302 303 - return fops->query_variable_store(attributes, size); 303 + return fops->query_variable_store(attributes, size, false); 304 + } 305 + 306 + static efi_status_t 307 + check_var_size_nonblocking(u32 attributes, unsigned long size) 308 + { 309 + const struct efivar_operations *fops = __efivars->ops; 310 + 311 + if (!fops->query_variable_store) 312 + return EFI_UNSUPPORTED; 313 + 314 + return fops->query_variable_store(attributes, size, true); 304 315 } 305 316 306 317 static int efi_status_to_err(efi_status_t status) ··· 692 681 if (!spin_trylock_irqsave(&__efivars->lock, flags)) 693 682 return -EBUSY; 694 683 695 - status = check_var_size(attributes, size + ucs2_strsize(name, 1024)); 684 + status = check_var_size_nonblocking(attributes, 685 + size + ucs2_strsize(name, 1024)); 696 686 if (status != EFI_SUCCESS) { 697 687 spin_unlock_irqrestore(&__efivars->lock, flags); 698 688 return -ENOSPC;
+55 -30
include/linux/efi.h
··· 97 97 #define EFI_MEMORY_WP ((u64)0x0000000000001000ULL) /* write-protect */ 98 98 #define EFI_MEMORY_RP ((u64)0x0000000000002000ULL) /* read-protect */ 99 99 #define EFI_MEMORY_XP ((u64)0x0000000000004000ULL) /* execute-protect */ 100 + #define EFI_MEMORY_NV ((u64)0x0000000000008000ULL) /* non-volatile */ 100 101 #define EFI_MEMORY_MORE_RELIABLE \ 101 102 ((u64)0x0000000000010000ULL) /* higher reliability */ 102 103 #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ ··· 508 507 typedef efi_status_t efi_set_variable_t (efi_char16_t *name, efi_guid_t *vendor, 509 508 u32 attr, unsigned long data_size, 510 509 void *data); 511 - typedef efi_status_t 512 - efi_set_variable_nonblocking_t(efi_char16_t *name, efi_guid_t *vendor, 513 - u32 attr, unsigned long data_size, void *data); 514 - 515 510 typedef efi_status_t efi_get_next_high_mono_count_t (u32 *count); 516 511 typedef void efi_reset_system_t (int reset_type, efi_status_t status, 517 512 unsigned long data_size, efi_char16_t *data); ··· 526 529 unsigned long count, 527 530 u64 *max_size, 528 531 int *reset_type); 529 - typedef efi_status_t efi_query_variable_store_t(u32 attributes, unsigned long size); 532 + typedef efi_status_t efi_query_variable_store_t(u32 attributes, 533 + unsigned long size, 534 + bool nonblocking); 530 535 531 536 void efi_native_runtime_setup(void); 532 537 ··· 536 537 * EFI Configuration Table and GUID definitions 537 538 */ 538 539 #define NULL_GUID \ 539 - EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ) 540 + EFI_GUID(0x00000000, 0x0000, 0x0000, \ 541 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00) 540 542 541 543 #define MPS_TABLE_GUID \ 542 - EFI_GUID( 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 544 + EFI_GUID(0xeb9d2d2f, 0x2d88, 0x11d3, \ 545 + 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 543 546 544 547 #define ACPI_TABLE_GUID \ 545 - EFI_GUID( 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 548 + EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3, \ 549 + 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 546 550 547 551 #define ACPI_20_TABLE_GUID \ 548 - EFI_GUID( 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 ) 552 + EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, \ 553 + 0xbc, 0x22, 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81) 549 554 550 555 #define SMBIOS_TABLE_GUID \ 551 - EFI_GUID( 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 556 + EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, \ 557 + 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 552 558 553 559 #define SMBIOS3_TABLE_GUID \ 554 - EFI_GUID( 0xf2fd1544, 0x9794, 0x4a2c, 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94 ) 560 + EFI_GUID(0xf2fd1544, 0x9794, 0x4a2c, \ 561 + 0x99, 0x2e, 0xe5, 0xbb, 0xcf, 0x20, 0xe3, 0x94) 555 562 556 563 #define SAL_SYSTEM_TABLE_GUID \ 557 - EFI_GUID( 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d ) 564 + EFI_GUID(0xeb9d2d32, 0x2d88, 0x11d3, \ 565 + 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) 558 566 559 567 #define HCDP_TABLE_GUID \ 560 - EFI_GUID( 0xf951938d, 0x620b, 0x42ef, 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 ) 568 + EFI_GUID(0xf951938d, 0x620b, 0x42ef, \ 569 + 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98) 561 570 562 571 #define UGA_IO_PROTOCOL_GUID \ 563 - EFI_GUID( 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 ) 572 + EFI_GUID(0x61a4d49e, 0x6f68, 0x4f1b, \ 573 + 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0x0b, 0x07, 0xa2) 564 574 565 575 #define EFI_GLOBAL_VARIABLE_GUID \ 566 - EFI_GUID( 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c ) 576 + EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, \ 577 + 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) 567 578 568 579 #define UV_SYSTEM_TABLE_GUID \ 569 - EFI_GUID( 0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 ) 580 + EFI_GUID(0x3b13a7d4, 0x633e, 0x11dd, \ 581 + 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93) 570 582 571 583 #define LINUX_EFI_CRASH_GUID \ 572 - EFI_GUID( 0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 ) 584 + EFI_GUID(0xcfc8fc79, 0xbe2e, 0x4ddc, \ 585 + 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0) 573 586 574 587 #define LOADED_IMAGE_PROTOCOL_GUID \ 575 - EFI_GUID( 0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 588 + EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \ 589 + 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 576 590 577 591 #define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ 578 - EFI_GUID( 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a ) 592 + EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \ 593 + 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) 579 594 580 595 #define EFI_UGA_PROTOCOL_GUID \ 581 - EFI_GUID( 0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 ) 596 + EFI_GUID(0x982c298b, 0xf4fa, 0x41cb, \ 597 + 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39) 582 598 583 599 #define EFI_PCI_IO_PROTOCOL_GUID \ 584 - EFI_GUID( 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a ) 600 + EFI_GUID(0x4cf5b200, 0x68b8, 0x4ca5, \ 601 + 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x02, 0x9a) 585 602 586 603 #define EFI_FILE_INFO_ID \ 587 - EFI_GUID( 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 604 + EFI_GUID(0x9576e92, 0x6d3f, 0x11d2, \ 605 + 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 588 606 589 607 #define EFI_SYSTEM_RESOURCE_TABLE_GUID \ 590 - EFI_GUID( 0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 ) 608 + EFI_GUID(0xb122a263, 0x3661, 0x4f68, \ 609 + 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80) 591 610 592 611 #define EFI_FILE_SYSTEM_GUID \ 593 - EFI_GUID( 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b ) 612 + EFI_GUID(0x964e5b22, 0x6459, 0x11d2, \ 613 + 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) 594 614 595 615 #define DEVICE_TREE_GUID \ 596 - EFI_GUID( 0xb1b621d5, 0xf19c, 0x41a5, 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 ) 616 + EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \ 617 + 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) 597 618 598 619 #define EFI_PROPERTIES_TABLE_GUID \ 599 - EFI_GUID( 0x880aaca3, 0x4adc, 0x4a04, 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5 ) 620 + EFI_GUID(0x880aaca3, 0x4adc, 0x4a04, \ 621 + 0x90, 0x79, 0xb7, 0x47, 0x34, 0x08, 0x25, 0xe5) 600 622 601 623 #define EFI_RNG_PROTOCOL_GUID \ 602 624 EFI_GUID(0x3152bca5, 0xeade, 0x433d, \ ··· 875 855 efi_get_variable_t *get_variable; 876 856 efi_get_next_variable_t *get_next_variable; 877 857 efi_set_variable_t *set_variable; 878 - efi_set_variable_nonblocking_t *set_variable_nonblocking; 858 + efi_set_variable_t *set_variable_nonblocking; 879 859 efi_query_variable_info_t *query_variable_info; 860 + efi_query_variable_info_t *query_variable_info_nonblocking; 880 861 efi_update_capsule_t *update_capsule; 881 862 efi_query_capsule_caps_t *query_capsule_caps; 882 863 efi_get_next_high_mono_count_t *get_next_high_mono_count; ··· 909 888 #ifdef CONFIG_X86 910 889 extern void efi_late_init(void); 911 890 extern void efi_free_boot_services(void); 912 - extern efi_status_t efi_query_variable_store(u32 attributes, unsigned long size); 891 + extern efi_status_t efi_query_variable_store(u32 attributes, 892 + unsigned long size, 893 + bool nonblocking); 913 894 extern void efi_find_mirror(void); 914 895 #else 915 896 static inline void efi_late_init(void) {} 916 897 static inline void efi_free_boot_services(void) {} 917 898 918 - static inline efi_status_t efi_query_variable_store(u32 attributes, unsigned long size) 899 + static inline efi_status_t efi_query_variable_store(u32 attributes, 900 + unsigned long size, 901 + bool nonblocking) 919 902 { 920 903 return EFI_SUCCESS; 921 904 } ··· 1120 1095 efi_get_variable_t *get_variable; 1121 1096 efi_get_next_variable_t *get_next_variable; 1122 1097 efi_set_variable_t *set_variable; 1123 - efi_set_variable_nonblocking_t *set_variable_nonblocking; 1098 + efi_set_variable_t *set_variable_nonblocking; 1124 1099 efi_query_variable_store_t *query_variable_store; 1125 1100 }; 1126 1101