aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 10:13:56 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2019-03-06 10:13:56 -0500
commitc8f5ed6ef972ed4fd10b0c2e2baec3b6803d3c73 (patch)
treee57a12ca1ed3b53c9cafc8bc99dd104bce40425e
parent3717f613f48df0222311f974cf8a06c8a6c97bae (diff)
parent5c418dc789a3898717ebf2caa5716ba91a7150b2 (diff)
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 EFI changes in this cycle were: - Use 32-bit alignment for efi_guid_t - Allow the SetVirtualAddressMap() call to be omitted - Implement earlycon=efifb based on existing earlyprintk code - Various minor fixes and code cleanups from Sai, Ard and me" * 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: efi: Fix build error due to enum collision between efi.h and ima.h efi/x86: Convert x86 EFI earlyprintk into generic earlycon implementation x86: Make ARCH_USE_MEMREMAP_PROT a generic Kconfig symbol efi/arm/arm64: Allow SetVirtualAddressMap() to be omitted efi: Replace GPL license boilerplate with SPDX headers efi/fdt: Apply more cleanups efi: Use 32-bit alignment for efi_guid_t efi/memattr: Don't bail on zero VA if it equals the region's PA x86/efi: Mark can_free_region() as an __init function
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt8
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/x86/Kconfig5
-rw-r--r--arch/x86/Kconfig.debug10
-rw-r--r--arch/x86/include/asm/efi.h1
-rw-r--r--arch/x86/kernel/early_printk.c4
-rw-r--r--arch/x86/mm/ioremap.c4
-rw-r--r--arch/x86/platform/efi/Makefile1
-rw-r--r--arch/x86/platform/efi/early_printk.c240
-rw-r--r--arch/x86/platform/efi/quirks.c6
-rw-r--r--drivers/firmware/efi/Kconfig6
-rw-r--r--drivers/firmware/efi/Makefile1
-rw-r--r--drivers/firmware/efi/apple-properties.c13
-rw-r--r--drivers/firmware/efi/arm-init.c6
-rw-r--r--drivers/firmware/efi/arm-runtime.c6
-rw-r--r--drivers/firmware/efi/capsule-loader.c4
-rw-r--r--drivers/firmware/efi/capsule.c4
-rw-r--r--drivers/firmware/efi/cper-arm.c14
-rw-r--r--drivers/firmware/efi/cper.c14
-rw-r--r--drivers/firmware/efi/dev-path-parser.c9
-rw-r--r--drivers/firmware/efi/earlycon.c206
-rw-r--r--drivers/firmware/efi/efi-bgrt.c5
-rw-r--r--drivers/firmware/efi/efi-pstore.c2
-rw-r--r--drivers/firmware/efi/efibc.c10
-rw-r--r--drivers/firmware/efi/efivars.c58
-rw-r--r--drivers/firmware/efi/esrt.c1
-rw-r--r--drivers/firmware/efi/fake_mem.c16
-rw-r--r--drivers/firmware/efi/libstub/Makefile4
-rw-r--r--drivers/firmware/efi/libstub/arm-stub.c5
-rw-r--r--drivers/firmware/efi/libstub/arm32-stub.c6
-rw-r--r--drivers/firmware/efi/libstub/arm64-stub.c6
-rw-r--r--drivers/firmware/efi/libstub/efi-stub-helper.c15
-rw-r--r--drivers/firmware/efi/libstub/efistub.h12
-rw-r--r--drivers/firmware/efi/libstub/fdt.c115
-rw-r--r--drivers/firmware/efi/libstub/gop.c4
-rw-r--r--drivers/firmware/efi/libstub/random.c6
-rw-r--r--drivers/firmware/efi/libstub/secureboot.c4
-rw-r--r--drivers/firmware/efi/libstub/tpm.c4
-rw-r--r--drivers/firmware/efi/memattr.c7
-rw-r--r--drivers/firmware/efi/runtime-map.c3
-rw-r--r--drivers/firmware/efi/runtime-wrappers.c48
-rw-r--r--drivers/firmware/efi/test/efi_test.c1
-rw-r--r--drivers/firmware/efi/test/efi_test.h2
-rw-r--r--drivers/firmware/efi/tpm.c5
-rw-r--r--drivers/firmware/efi/vars.c15
-rw-r--r--include/linux/efi.h41
46 files changed, 393 insertions, 567 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 74dddbf54cd1..a87418990d39 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1078,9 +1078,15 @@
1078 specified address. The serial port must already be 1078 specified address. The serial port must already be
1079 setup and configured. Options are not yet supported. 1079 setup and configured. Options are not yet supported.
1080 1080
1081 efifb,[options]
1082 Start an early, unaccelerated console on the EFI
1083 memory mapped framebuffer (if available). On cache
1084 coherent non-x86 systems that use system memory for
1085 the framebuffer, pass the 'ram' option so that it is
1086 mapped with the correct attributes.
1087
1081 earlyprintk= [X86,SH,ARM,M68k,S390] 1088 earlyprintk= [X86,SH,ARM,M68k,S390]
1082 earlyprintk=vga 1089 earlyprintk=vga
1083 earlyprintk=efi
1084 earlyprintk=sclp 1090 earlyprintk=sclp
1085 earlyprintk=xen 1091 earlyprintk=xen
1086 earlyprintk=serial[,ttySn[,baudrate]] 1092 earlyprintk=serial[,ttySn[,baudrate]]
diff --git a/arch/Kconfig b/arch/Kconfig
index cd5f443865ec..3aff508ffd86 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -895,6 +895,9 @@ config HAVE_ARCH_PREL32_RELOCATIONS
895 architectures, and don't require runtime relocation on relocatable 895 architectures, and don't require runtime relocation on relocatable
896 kernels. 896 kernels.
897 897
898config ARCH_USE_MEMREMAP_PROT
899 bool
900
898source "kernel/gcov/Kconfig" 901source "kernel/gcov/Kconfig"
899 902
900source "scripts/gcc-plugins/Kconfig" 903source "scripts/gcc-plugins/Kconfig"
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 5a02dd608f74..90b562a34d65 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1510,6 +1510,7 @@ config AMD_MEM_ENCRYPT
1510 bool "AMD Secure Memory Encryption (SME) support" 1510 bool "AMD Secure Memory Encryption (SME) support"
1511 depends on X86_64 && CPU_SUP_AMD 1511 depends on X86_64 && CPU_SUP_AMD
1512 select DYNAMIC_PHYSICAL_MASK 1512 select DYNAMIC_PHYSICAL_MASK
1513 select ARCH_USE_MEMREMAP_PROT
1513 ---help--- 1514 ---help---
1514 Say yes to enable support for the encryption of system memory. 1515 Say yes to enable support for the encryption of system memory.
1515 This requires an AMD processor that supports Secure Memory 1516 This requires an AMD processor that supports Secure Memory
@@ -1529,10 +1530,6 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
1529 If set to N, then the encryption of system memory can be 1530 If set to N, then the encryption of system memory can be
1530 activated with the mem_encrypt=on command line option. 1531 activated with the mem_encrypt=on command line option.
1531 1532
1532config ARCH_USE_MEMREMAP_PROT
1533 def_bool y
1534 depends on AMD_MEM_ENCRYPT
1535
1536# Common NUMA Features 1533# Common NUMA Features
1537config NUMA 1534config NUMA
1538 bool "Numa Memory Allocation and Scheduler Support" 1535 bool "Numa Memory Allocation and Scheduler Support"
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 0723dff17e6c..15d0fbe27872 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -40,16 +40,6 @@ config EARLY_PRINTK_DBGP
40 with klogd/syslogd or the X server. You should normally say N here, 40 with klogd/syslogd or the X server. You should normally say N here,
41 unless you want to debug such a crash. You need usb debug device. 41 unless you want to debug such a crash. You need usb debug device.
42 42
43config EARLY_PRINTK_EFI
44 bool "Early printk via the EFI framebuffer"
45 depends on EFI && EARLY_PRINTK
46 select FONT_SUPPORT
47 ---help---
48 Write kernel log output directly into the EFI framebuffer.
49
50 This is useful for kernel debugging when your machine crashes very
51 early before the console code is initialized.
52
53config EARLY_PRINTK_USB_XDBC 43config EARLY_PRINTK_USB_XDBC
54 bool "Early printk via the xHCI debug port" 44 bool "Early printk via the xHCI debug port"
55 depends on EARLY_PRINTK && PCI 45 depends on EARLY_PRINTK && PCI
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index 107283b1eb1e..606a4b6a9812 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -170,7 +170,6 @@ static inline bool efi_runtime_supported(void)
170 return false; 170 return false;
171} 171}
172 172
173extern struct console early_efi_console;
174extern void parse_efi_setup(u64 phys_addr, u32 data_len); 173extern void parse_efi_setup(u64 phys_addr, u32 data_len);
175 174
176extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt); 175extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt);
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
index 374a52fa5296..9b33904251a9 100644
--- a/arch/x86/kernel/early_printk.c
+++ b/arch/x86/kernel/early_printk.c
@@ -388,10 +388,6 @@ static int __init setup_early_printk(char *buf)
388 if (!strncmp(buf, "xen", 3)) 388 if (!strncmp(buf, "xen", 3))
389 early_console_register(&xenboot_console, keep); 389 early_console_register(&xenboot_console, keep);
390#endif 390#endif
391#ifdef CONFIG_EARLY_PRINTK_EFI
392 if (!strncmp(buf, "efi", 3))
393 early_console_register(&early_efi_console, keep);
394#endif
395#ifdef CONFIG_EARLY_PRINTK_USB_XDBC 391#ifdef CONFIG_EARLY_PRINTK_USB_XDBC
396 if (!strncmp(buf, "xdbc", 4)) 392 if (!strncmp(buf, "xdbc", 4))
397 early_xdbc_parse_parameter(buf + 4); 393 early_xdbc_parse_parameter(buf + 4);
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 5378d10f1d31..0029604af8a4 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -705,7 +705,7 @@ bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size)
705 return arch_memremap_can_ram_remap(phys_addr, size, 0); 705 return arch_memremap_can_ram_remap(phys_addr, size, 0);
706} 706}
707 707
708#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT 708#ifdef CONFIG_AMD_MEM_ENCRYPT
709/* Remap memory with encryption */ 709/* Remap memory with encryption */
710void __init *early_memremap_encrypted(resource_size_t phys_addr, 710void __init *early_memremap_encrypted(resource_size_t phys_addr,
711 unsigned long size) 711 unsigned long size)
@@ -747,7 +747,7 @@ void __init *early_memremap_decrypted_wp(resource_size_t phys_addr,
747 747
748 return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); 748 return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP);
749} 749}
750#endif /* CONFIG_ARCH_USE_MEMREMAP_PROT */ 750#endif /* CONFIG_AMD_MEM_ENCRYPT */
751 751
752static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; 752static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
753 753
diff --git a/arch/x86/platform/efi/Makefile b/arch/x86/platform/efi/Makefile
index e4dc3862d423..fe29f3f5d384 100644
--- a/arch/x86/platform/efi/Makefile
+++ b/arch/x86/platform/efi/Makefile
@@ -3,5 +3,4 @@ OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y
3OBJECT_FILES_NON_STANDARD_efi_stub_$(BITS).o := y 3OBJECT_FILES_NON_STANDARD_efi_stub_$(BITS).o := y
4 4
5obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o 5obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o
6obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o
7obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o 6obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o
diff --git a/arch/x86/platform/efi/early_printk.c b/arch/x86/platform/efi/early_printk.c
deleted file mode 100644
index 7138bc7a265c..000000000000
--- a/arch/x86/platform/efi/early_printk.c
+++ /dev/null
@@ -1,240 +0,0 @@
1/*
2 * Copyright (C) 2013 Intel Corporation; author Matt Fleming
3 *
4 * This file is part of the Linux kernel, and is made available under
5 * the terms of the GNU General Public License version 2.
6 */
7
8#include <linux/console.h>
9#include <linux/efi.h>
10#include <linux/font.h>
11#include <linux/io.h>
12#include <linux/kernel.h>
13#include <asm/setup.h>
14
15static const struct font_desc *font;
16static u32 efi_x, efi_y;
17static void *efi_fb;
18static bool early_efi_keep;
19
20/*
21 * efi earlyprintk need use early_ioremap to map the framebuffer.
22 * But early_ioremap is not usable for earlyprintk=efi,keep, ioremap should
23 * be used instead. ioremap will be available after paging_init() which is
24 * earlier than initcall callbacks. Thus adding this early initcall function
25 * early_efi_map_fb to map the whole efi framebuffer.
26 */
27static __init int early_efi_map_fb(void)
28{
29 u64 base, size;
30
31 if (!early_efi_keep)
32 return 0;
33
34 base = boot_params.screen_info.lfb_base;
35 if (boot_params.screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
36 base |= (u64)boot_params.screen_info.ext_lfb_base << 32;
37 size = boot_params.screen_info.lfb_size;
38 efi_fb = ioremap(base, size);
39
40 return efi_fb ? 0 : -ENOMEM;
41}
42early_initcall(early_efi_map_fb);
43
44/*
45 * early_efi_map maps efi framebuffer region [start, start + len -1]
46 * In case earlyprintk=efi,keep we have the whole framebuffer mapped already
47 * so just return the offset efi_fb + start.
48 */
49static __ref void *early_efi_map(unsigned long start, unsigned long len)
50{
51 u64 base;
52
53 base = boot_params.screen_info.lfb_base;
54 if (boot_params.screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
55 base |= (u64)boot_params.screen_info.ext_lfb_base << 32;
56
57 if (efi_fb)
58 return (efi_fb + start);
59 else
60 return early_ioremap(base + start, len);
61}
62
63static __ref void early_efi_unmap(void *addr, unsigned long len)
64{
65 if (!efi_fb)
66 early_iounmap(addr, len);
67}
68
69static void early_efi_clear_scanline(unsigned int y)
70{
71 unsigned long *dst;
72 u16 len;
73
74 len = boot_params.screen_info.lfb_linelength;
75 dst = early_efi_map(y*len, len);
76 if (!dst)
77 return;
78
79 memset(dst, 0, len);
80 early_efi_unmap(dst, len);
81}
82
83static void early_efi_scroll_up(void)
84{
85 unsigned long *dst, *src;
86 u16 len;
87 u32 i, height;
88
89 len = boot_params.screen_info.lfb_linelength;
90 height = boot_params.screen_info.lfb_height;
91
92 for (i = 0; i < height - font->height; i++) {
93 dst = early_efi_map(i*len, len);
94 if (!dst)
95 return;
96
97 src = early_efi_map((i + font->height) * len, len);
98 if (!src) {
99 early_efi_unmap(dst, len);
100 return;
101 }
102
103 memmove(dst, src, len);
104
105 early_efi_unmap(src, len);
106 early_efi_unmap(dst, len);
107 }
108}
109
110static void early_efi_write_char(u32 *dst, unsigned char c, unsigned int h)
111{
112 const u32 color_black = 0x00000000;
113 const u32 color_white = 0x00ffffff;
114 const u8 *src;
115 u8 s8;
116 int m;
117
118 src = font->data + c * font->height;
119 s8 = *(src + h);
120
121 for (m = 0; m < 8; m++) {
122 if ((s8 >> (7 - m)) & 1)
123 *dst = color_white;
124 else
125 *dst = color_black;
126 dst++;
127 }
128}
129
130static void
131early_efi_write(struct console *con, const char *str, unsigned int num)
132{
133 struct screen_info *si;
134 unsigned int len;
135 const char *s;
136 void *dst;
137
138 si = &boot_params.screen_info;
139 len = si->lfb_linelength;
140
141 while (num) {
142 unsigned int linemax;
143 unsigned int h, count = 0;
144
145 for (s = str; *s && *s != '\n'; s++) {
146 if (count == num)
147 break;
148 count++;
149 }
150
151 linemax = (si->lfb_width - efi_x) / font->width;
152 if (count > linemax)
153 count = linemax;
154
155 for (h = 0; h < font->height; h++) {
156 unsigned int n, x;
157
158 dst = early_efi_map((efi_y + h) * len, len);
159 if (!dst)
160 return;
161
162 s = str;
163 n = count;
164 x = efi_x;
165
166 while (n-- > 0) {
167 early_efi_write_char(dst + x*4, *s, h);
168 x += font->width;
169 s++;
170 }
171
172 early_efi_unmap(dst, len);
173 }
174
175 num -= count;
176 efi_x += count * font->width;
177 str += count;
178
179 if (num > 0 && *s == '\n') {
180 efi_x = 0;
181 efi_y += font->height;
182 str++;
183 num--;
184 }
185
186 if (efi_x + font->width > si->lfb_width) {
187 efi_x = 0;
188 efi_y += font->height;
189 }
190
191 if (efi_y + font->height > si->lfb_height) {
192 u32 i;
193
194 efi_y -= font->height;
195 early_efi_scroll_up();
196
197 for (i = 0; i < font->height; i++)
198 early_efi_clear_scanline(efi_y + i);
199 }
200 }
201}
202
203static __init int early_efi_setup(struct console *con, char *options)
204{
205 struct screen_info *si;
206 u16 xres, yres;
207 u32 i;
208
209 si = &boot_params.screen_info;
210 xres = si->lfb_width;
211 yres = si->lfb_height;
212
213 /*
214 * early_efi_write_char() implicitly assumes a framebuffer with
215 * 32-bits per pixel.
216 */
217 if (si->lfb_depth != 32)
218 return -ENODEV;
219
220 font = get_default_font(xres, yres, -1, -1);
221 if (!font)
222 return -ENODEV;
223
224 efi_y = rounddown(yres, font->height) - font->height;
225 for (i = 0; i < (yres - efi_y) / font->height; i++)
226 early_efi_scroll_up();
227
228 /* early_console_register will unset CON_BOOT in case ,keep */
229 if (!(con->flags & CON_BOOT))
230 early_efi_keep = true;
231 return 0;
232}
233
234struct console early_efi_console = {
235 .name = "earlyefi",
236 .write = early_efi_write,
237 .setup = early_efi_setup,
238 .flags = CON_PRINTBUFFER,
239 .index = -1,
240};
diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
index 17456a1d3f04..458a0e2bcc57 100644
--- a/arch/x86/platform/efi/quirks.c
+++ b/arch/x86/platform/efi/quirks.c
@@ -304,7 +304,7 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
304 * - Not within any part of the kernel 304 * - Not within any part of the kernel
305 * - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc) 305 * - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc)
306 */ 306 */
307static bool can_free_region(u64 start, u64 size) 307static __init bool can_free_region(u64 start, u64 size)
308{ 308{
309 if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end)) 309 if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end))
310 return false; 310 return false;
@@ -717,7 +717,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr)
717 * "efi_mm" cannot be used to check if the page fault had occurred 717 * "efi_mm" cannot be used to check if the page fault had occurred
718 * in the firmware context because efi=old_map doesn't use efi_pgd. 718 * in the firmware context because efi=old_map doesn't use efi_pgd.
719 */ 719 */
720 if (efi_rts_work.efi_rts_id == NONE) 720 if (efi_rts_work.efi_rts_id == EFI_NONE)
721 return; 721 return;
722 722
723 /* 723 /*
@@ -742,7 +742,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr)
742 * because this case occurs *very* rarely and hence could be improved 742 * because this case occurs *very* rarely and hence could be improved
743 * on a need by basis. 743 * on a need by basis.
744 */ 744 */
745 if (efi_rts_work.efi_rts_id == RESET_SYSTEM) { 745 if (efi_rts_work.efi_rts_id == EFI_RESET_SYSTEM) {
746 pr_info("efi_reset_system() buggy! Reboot through BIOS\n"); 746 pr_info("efi_reset_system() buggy! Reboot through BIOS\n");
747 machine_real_restart(MRR_BIOS); 747 machine_real_restart(MRR_BIOS);
748 return; 748 return;
diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig
index 89110dfc7127..190be0b1d109 100644
--- a/drivers/firmware/efi/Kconfig
+++ b/drivers/firmware/efi/Kconfig
@@ -198,3 +198,9 @@ config EFI_DEV_PATH_PARSER
198 bool 198 bool
199 depends on ACPI 199 depends on ACPI
200 default n 200 default n
201
202config EFI_EARLYCON
203 def_bool y
204 depends on SERIAL_EARLYCON && !ARM && !IA64
205 select FONT_SUPPORT
206 select ARCH_USE_MEMREMAP_PROT
diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile
index 5f9f5039de50..d2d0d2030620 100644
--- a/drivers/firmware/efi/Makefile
+++ b/drivers/firmware/efi/Makefile
@@ -30,5 +30,6 @@ arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o
30obj-$(CONFIG_ARM) += $(arm-obj-y) 30obj-$(CONFIG_ARM) += $(arm-obj-y)
31obj-$(CONFIG_ARM64) += $(arm-obj-y) 31obj-$(CONFIG_ARM64) += $(arm-obj-y)
32obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o 32obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o
33obj-$(CONFIG_EFI_EARLYCON) += earlycon.o
33obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o 34obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o
34obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o 35obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o
diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c
index ac1654f74dc7..0e206c9e0d7a 100644
--- a/drivers/firmware/efi/apple-properties.c
+++ b/drivers/firmware/efi/apple-properties.c
@@ -1,19 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * apple-properties.c - EFI device properties on Macs 3 * apple-properties.c - EFI device properties on Macs
3 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> 4 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
4 * 5 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License (version 2) as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 *
17 * Note, all properties are considered as u8 arrays. 6 * Note, all properties are considered as u8 arrays.
18 * To get a value of any of them the caller must use device_property_read_u8_array(). 7 * To get a value of any of them the caller must use device_property_read_u8_array().
19 */ 8 */
diff --git a/drivers/firmware/efi/arm-init.c b/drivers/firmware/efi/arm-init.c
index 1a6a77df8a5e..311cd349a862 100644
--- a/drivers/firmware/efi/arm-init.c
+++ b/drivers/firmware/efi/arm-init.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Extensible Firmware Interface 3 * Extensible Firmware Interface
3 * 4 *
4 * Based on Extensible Firmware Interface Specification version 2.4 5 * Based on Extensible Firmware Interface Specification version 2.4
5 * 6 *
6 * Copyright (C) 2013 - 2015 Linaro Ltd. 7 * Copyright (C) 2013 - 2015 Linaro Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */ 8 */
13 9
14#define pr_fmt(fmt) "efi: " fmt 10#define pr_fmt(fmt) "efi: " fmt
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c
index 352bd2473162..f99995666f86 100644
--- a/drivers/firmware/efi/arm-runtime.c
+++ b/drivers/firmware/efi/arm-runtime.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Extensible Firmware Interface 3 * Extensible Firmware Interface
3 * 4 *
4 * Based on Extensible Firmware Interface Specification version 2.4 5 * Based on Extensible Firmware Interface Specification version 2.4
5 * 6 *
6 * Copyright (C) 2013, 2014 Linaro Ltd. 7 * Copyright (C) 2013, 2014 Linaro Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */ 8 */
13 9
14#include <linux/dmi.h> 10#include <linux/dmi.h>
diff --git a/drivers/firmware/efi/capsule-loader.c b/drivers/firmware/efi/capsule-loader.c
index 96688986da56..b1395133389e 100644
--- a/drivers/firmware/efi/capsule-loader.c
+++ b/drivers/firmware/efi/capsule-loader.c
@@ -1,10 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * EFI capsule loader driver. 3 * EFI capsule loader driver.
3 * 4 *
4 * Copyright 2015 Intel Corporation 5 * Copyright 2015 Intel Corporation
5 *
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
8 */ 6 */
9 7
10#define pr_fmt(fmt) "efi: " fmt 8#define pr_fmt(fmt) "efi: " fmt
diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c
index 4938c29b7c5d..598b7800d14e 100644
--- a/drivers/firmware/efi/capsule.c
+++ b/drivers/firmware/efi/capsule.c
@@ -1,10 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * EFI capsule support. 3 * EFI capsule support.
3 * 4 *
4 * Copyright 2013 Intel Corporation; author Matt Fleming 5 * Copyright 2013 Intel Corporation; author Matt Fleming
5 *
6 * This file is part of the Linux kernel, and is made available under
7 * the terms of the GNU General Public License version 2.
8 */ 6 */
9 7
10#define pr_fmt(fmt) "efi: " fmt 8#define pr_fmt(fmt) "efi: " fmt
diff --git a/drivers/firmware/efi/cper-arm.c b/drivers/firmware/efi/cper-arm.c
index 502811344e81..36d3b8b9da47 100644
--- a/drivers/firmware/efi/cper-arm.c
+++ b/drivers/firmware/efi/cper-arm.c
@@ -1,20 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * UEFI Common Platform Error Record (CPER) support 3 * UEFI Common Platform Error Record (CPER) support
3 * 4 *
4 * Copyright (C) 2017, The Linux Foundation. All rights reserved. 5 * Copyright (C) 2017, The Linux Foundation. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License version
8 * 2 as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 6 */
19 7
20#include <linux/kernel.h> 8#include <linux/kernel.h>
diff --git a/drivers/firmware/efi/cper.c b/drivers/firmware/efi/cper.c
index a7902fccdcfa..6a966ecdd80a 100644
--- a/drivers/firmware/efi/cper.c
+++ b/drivers/firmware/efi/cper.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * UEFI Common Platform Error Record (CPER) support 3 * UEFI Common Platform Error Record (CPER) support
3 * 4 *
@@ -9,19 +10,6 @@
9 * 10 *
10 * For more information about CPER, please refer to Appendix N of UEFI 11 * For more information about CPER, please refer to Appendix N of UEFI
11 * Specification version 2.4. 12 * Specification version 2.4.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License version
15 * 2 as published by the Free Software Foundation.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 */ 13 */
26 14
27#include <linux/kernel.h> 15#include <linux/kernel.h>
diff --git a/drivers/firmware/efi/dev-path-parser.c b/drivers/firmware/efi/dev-path-parser.c
index 85d1834ee9b7..85ec99f97841 100644
--- a/drivers/firmware/efi/dev-path-parser.c
+++ b/drivers/firmware/efi/dev-path-parser.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * dev-path-parser.c - EFI Device Path parser 3 * dev-path-parser.c - EFI Device Path parser
3 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> 4 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
@@ -5,14 +6,6 @@
5 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License (version 2) as 7 * it under the terms of the GNU General Public License (version 2) as
7 * published by the Free Software Foundation. 8 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
16 */ 9 */
17 10
18#include <linux/acpi.h> 11#include <linux/acpi.h>
diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
new file mode 100644
index 000000000000..c9a0efca17b0
--- /dev/null
+++ b/drivers/firmware/efi/earlycon.c
@@ -0,0 +1,206 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2013 Intel Corporation; author Matt Fleming
4 */
5
6#include <linux/console.h>
7#include <linux/efi.h>
8#include <linux/font.h>
9#include <linux/io.h>
10#include <linux/kernel.h>
11#include <linux/serial_core.h>
12#include <linux/screen_info.h>
13
14#include <asm/early_ioremap.h>
15
16static const struct font_desc *font;
17static u32 efi_x, efi_y;
18static u64 fb_base;
19static pgprot_t fb_prot;
20
21static __ref void *efi_earlycon_map(unsigned long start, unsigned long len)
22{
23 return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot));
24}
25
26static __ref void efi_earlycon_unmap(void *addr, unsigned long len)
27{
28 early_memunmap(addr, len);
29}
30
31static void efi_earlycon_clear_scanline(unsigned int y)
32{
33 unsigned long *dst;
34 u16 len;
35
36 len = screen_info.lfb_linelength;
37 dst = efi_earlycon_map(y*len, len);
38 if (!dst)
39 return;
40
41 memset(dst, 0, len);
42 efi_earlycon_unmap(dst, len);
43}
44
45static void efi_earlycon_scroll_up(void)
46{
47 unsigned long *dst, *src;
48 u16 len;
49 u32 i, height;
50
51 len = screen_info.lfb_linelength;
52 height = screen_info.lfb_height;
53
54 for (i = 0; i < height - font->height; i++) {
55 dst = efi_earlycon_map(i*len, len);
56 if (!dst)
57 return;
58
59 src = efi_earlycon_map((i + font->height) * len, len);
60 if (!src) {
61 efi_earlycon_unmap(dst, len);
62 return;
63 }
64
65 memmove(dst, src, len);
66
67 efi_earlycon_unmap(src, len);
68 efi_earlycon_unmap(dst, len);
69 }
70}
71
72static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
73{
74 const u32 color_black = 0x00000000;
75 const u32 color_white = 0x00ffffff;
76 const u8 *src;
77 u8 s8;
78 int m;
79
80 src = font->data + c * font->height;
81 s8 = *(src + h);
82
83 for (m = 0; m < 8; m++) {
84 if ((s8 >> (7 - m)) & 1)
85 *dst = color_white;
86 else
87 *dst = color_black;
88 dst++;
89 }
90}
91
92static void
93efi_earlycon_write(struct console *con, const char *str, unsigned int num)
94{
95 struct screen_info *si;
96 unsigned int len;
97 const char *s;
98 void *dst;
99
100 si = &screen_info;
101 len = si->lfb_linelength;
102
103 while (num) {
104 unsigned int linemax;
105 unsigned int h, count = 0;
106
107 for (s = str; *s && *s != '\n'; s++) {
108 if (count == num)
109 break;
110 count++;
111 }
112
113 linemax = (si->lfb_width - efi_x) / font->width;
114 if (count > linemax)
115 count = linemax;
116
117 for (h = 0; h < font->height; h++) {
118 unsigned int n, x;
119
120 dst = efi_earlycon_map((efi_y + h) * len, len);
121 if (!dst)
122 return;
123
124 s = str;
125 n = count;
126 x = efi_x;
127
128 while (n-- > 0) {
129 efi_earlycon_write_char(dst + x*4, *s, h);
130 x += font->width;
131 s++;
132 }
133
134 efi_earlycon_unmap(dst, len);
135 }
136
137 num -= count;
138 efi_x += count * font->width;
139 str += count;
140
141 if (num > 0 && *s == '\n') {
142 efi_x = 0;
143 efi_y += font->height;
144 str++;
145 num--;
146 }
147
148 if (efi_x + font->width > si->lfb_width) {
149 efi_x = 0;
150 efi_y += font->height;
151 }
152
153 if (efi_y + font->height > si->lfb_height) {
154 u32 i;
155
156 efi_y -= font->height;
157 efi_earlycon_scroll_up();
158
159 for (i = 0; i < font->height; i++)
160 efi_earlycon_clear_scanline(efi_y + i);
161 }
162 }
163}
164
165static int __init efi_earlycon_setup(struct earlycon_device *device,
166 const char *opt)
167{
168 struct screen_info *si;
169 u16 xres, yres;
170 u32 i;
171
172 if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
173 return -ENODEV;
174
175 fb_base = screen_info.lfb_base;
176 if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
177 fb_base |= (u64)screen_info.ext_lfb_base << 32;
178
179 if (opt && !strcmp(opt, "ram"))
180 fb_prot = PAGE_KERNEL;
181 else
182 fb_prot = pgprot_writecombine(PAGE_KERNEL);
183
184 si = &screen_info;
185 xres = si->lfb_width;
186 yres = si->lfb_height;
187
188 /*
189 * efi_earlycon_write_char() implicitly assumes a framebuffer with
190 * 32 bits per pixel.
191 */
192 if (si->lfb_depth != 32)
193 return -ENODEV;
194
195 font = get_default_font(xres, yres, -1, -1);
196 if (!font)
197 return -ENODEV;
198
199 efi_y = rounddown(yres, font->height) - font->height;
200 for (i = 0; i < (yres - efi_y) / font->height; i++)
201 efi_earlycon_scroll_up();
202
203 device->con->write = efi_earlycon_write;
204 return 0;
205}
206EARLYCON_DECLARE(efifb, efi_earlycon_setup);
diff --git a/drivers/firmware/efi/efi-bgrt.c b/drivers/firmware/efi/efi-bgrt.c
index b22ccfb0c991..a2384184a7de 100644
--- a/drivers/firmware/efi/efi-bgrt.c
+++ b/drivers/firmware/efi/efi-bgrt.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright 2012 Intel Corporation 3 * Copyright 2012 Intel Corporation
3 * Author: Josh Triplett <josh@joshtriplett.org> 4 * Author: Josh Triplett <josh@joshtriplett.org>
@@ -5,10 +6,6 @@
5 * Based on the bgrt driver: 6 * Based on the bgrt driver:
6 * Copyright 2012 Red Hat, Inc <mjg@redhat.com> 7 * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
7 * Author: Matthew Garrett 8 * Author: Matthew Garrett
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */ 9 */
13 10
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 11#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 0f7d97917197..9ea13e8d12ec 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -1,3 +1,5 @@
1// SPDX-License-Identifier: GPL-2.0+
2
1#include <linux/efi.h> 3#include <linux/efi.h>
2#include <linux/module.h> 4#include <linux/module.h>
3#include <linux/pstore.h> 5#include <linux/pstore.h>
diff --git a/drivers/firmware/efi/efibc.c b/drivers/firmware/efi/efibc.c
index 503bbe2a9d49..61e099826cbb 100644
--- a/drivers/firmware/efi/efibc.c
+++ b/drivers/firmware/efi/efibc.c
@@ -1,15 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * efibc: control EFI bootloaders which obey LoaderEntryOneShot var 3 * efibc: control EFI bootloaders which obey LoaderEntryOneShot var
3 * Copyright (c) 2013-2016, Intel Corporation. 4 * Copyright (c) 2013-2016, Intel Corporation.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 */ 5 */
14 6
15#define pr_fmt(fmt) "efibc: " fmt 7#define pr_fmt(fmt) "efibc: " fmt
diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
index 8061667a6765..7576450c8254 100644
--- a/drivers/firmware/efi/efivars.c
+++ b/drivers/firmware/efi/efivars.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Originally from efivars.c, 3 * Originally from efivars.c,
3 * 4 *
@@ -6,63 +7,6 @@
6 * 7 *
7 * This code takes all variables accessible from EFI runtime and 8 * This code takes all variables accessible from EFI runtime and
8 * exports them via sysfs 9 * exports them via sysfs
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 *
24 * Changelog:
25 *
26 * 17 May 2004 - Matt Domsch <Matt_Domsch@dell.com>
27 * remove check for efi_enabled in exit
28 * add MODULE_VERSION
29 *
30 * 26 Apr 2004 - Matt Domsch <Matt_Domsch@dell.com>
31 * minor bug fixes
32 *
33 * 21 Apr 2004 - Matt Tolentino <matthew.e.tolentino@intel.com)
34 * converted driver to export variable information via sysfs
35 * and moved to drivers/firmware directory
36 * bumped revision number to v0.07 to reflect conversion & move
37 *
38 * 10 Dec 2002 - Matt Domsch <Matt_Domsch@dell.com>
39 * fix locking per Peter Chubb's findings
40 *
41 * 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com>
42 * move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_to_str()
43 *
44 * 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com>
45 * use list_for_each_safe when deleting vars.
46 * remove ifdef CONFIG_SMP around include <linux/smp.h>
47 * v0.04 release to linux-ia64@linuxia64.org
48 *
49 * 20 April 2001 - Matt Domsch <Matt_Domsch@dell.com>
50 * Moved vars from /proc/efi to /proc/efi/vars, and made
51 * efi.c own the /proc/efi directory.
52 * v0.03 release to linux-ia64@linuxia64.org
53 *
54 * 26 March 2001 - Matt Domsch <Matt_Domsch@dell.com>
55 * At the request of Stephane, moved ownership of /proc/efi
56 * to efi.c, and now efivars lives under /proc/efi/vars.
57 *
58 * 12 March 2001 - Matt Domsch <Matt_Domsch@dell.com>
59 * Feedback received from Stephane Eranian incorporated.
60 * efivar_write() checks copy_from_user() return value.
61 * efivar_read/write() returns proper errno.
62 * v0.02 release to linux-ia64@linuxia64.org
63 *
64 * 26 February 2001 - Matt Domsch <Matt_Domsch@dell.com>
65 * v0.01 release to linux-ia64@linuxia64.org
66 */ 10 */
67 11
68#include <linux/efi.h> 12#include <linux/efi.h>
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index 5d06bd247d07..d6dd5f503fa2 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * esrt.c 3 * esrt.c
3 * 4 *
diff --git a/drivers/firmware/efi/fake_mem.c b/drivers/firmware/efi/fake_mem.c
index 6c7d60c239b5..9501edc0fcfb 100644
--- a/drivers/firmware/efi/fake_mem.c
+++ b/drivers/firmware/efi/fake_mem.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fake_mem.c 3 * fake_mem.c
3 * 4 *
@@ -8,21 +9,6 @@
8 * By specifying this parameter, you can add arbitrary attribute to 9 * By specifying this parameter, you can add arbitrary attribute to
9 * specific memory range by updating original (firmware provided) EFI 10 * specific memory range by updating original (firmware provided) EFI
10 * memmap. 11 * memmap.
11 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms and conditions of the GNU General Public License,
14 * version 2, as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
19 * more details.
20 *
21 * You should have received a copy of the GNU General Public License along with
22 * this program; if not, see <http://www.gnu.org/licenses/>.
23 *
24 * The full GNU General Public License is included in this distribution in
25 * the file called "COPYING".
26 */ 12 */
27 13
28#include <linux/kernel.h> 14#include <linux/kernel.h>
diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile
index d9845099635e..b0103e16fc1b 100644
--- a/drivers/firmware/efi/libstub/Makefile
+++ b/drivers/firmware/efi/libstub/Makefile
@@ -52,7 +52,7 @@ lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \
52 52
53lib-$(CONFIG_ARM) += arm32-stub.o 53lib-$(CONFIG_ARM) += arm32-stub.o
54lib-$(CONFIG_ARM64) += arm64-stub.o 54lib-$(CONFIG_ARM64) += arm64-stub.o
55CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 55CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
56 56
57# 57#
58# arm64 puts the stub in the kernel proper, which will unnecessarily retain all 58# arm64 puts the stub in the kernel proper, which will unnecessarily retain all
@@ -89,7 +89,7 @@ quiet_cmd_stubcopy = STUBCPY $@
89 cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \ 89 cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \
90 then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \ 90 then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \
91 then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \ 91 then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
92 rm -f $@; /bin/false); \ 92 rm -f $@; /bin/false); \
93 else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \ 93 else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \
94 else /bin/false; fi 94 else /bin/false; fi
95 95
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index c037c6c5d0b7..04e6ecd72cd9 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -367,6 +367,11 @@ void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
367 paddr = in->phys_addr; 367 paddr = in->phys_addr;
368 size = in->num_pages * EFI_PAGE_SIZE; 368 size = in->num_pages * EFI_PAGE_SIZE;
369 369
370 if (novamap()) {
371 in->virt_addr = in->phys_addr;
372 continue;
373 }
374
370 /* 375 /*
371 * Make the mapping compatible with 64k pages: this allows 376 * Make the mapping compatible with 64k pages: this allows
372 * a 4k page size kernel to kexec a 64k page size kernel and 377 * a 4k page size kernel to kexec a 64k page size kernel and
diff --git a/drivers/firmware/efi/libstub/arm32-stub.c b/drivers/firmware/efi/libstub/arm32-stub.c
index becbda445913..e8f7aefb6813 100644
--- a/drivers/firmware/efi/libstub/arm32-stub.c
+++ b/drivers/firmware/efi/libstub/arm32-stub.c
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2013 Linaro Ltd; <roy.franz@linaro.org> 3 * Copyright (C) 2013 Linaro Ltd; <roy.franz@linaro.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 */ 4 */
9#include <linux/efi.h> 5#include <linux/efi.h>
10#include <asm/efi.h> 6#include <asm/efi.h>
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c
index 1b4d465cc5d9..1550d244e996 100644
--- a/drivers/firmware/efi/libstub/arm64-stub.c
+++ b/drivers/firmware/efi/libstub/arm64-stub.c
@@ -1,13 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org> 3 * Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org>
3 * 4 *
4 * This file implements the EFI boot stub for the arm64 kernel. 5 * This file implements the EFI boot stub for the arm64 kernel.
5 * Adapted from ARM version by Mark Salter <msalter@redhat.com> 6 * Adapted from ARM version by Mark Salter <msalter@redhat.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */ 7 */
12 8
13/* 9/*
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index e94975f4655b..e4610e72b78f 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Helper functions used by the EFI stub on multiple 3 * Helper functions used by the EFI stub on multiple
3 * architectures. This should be #included by the EFI stub 4 * architectures. This should be #included by the EFI stub
4 * implementation files. 5 * implementation files.
5 * 6 *
6 * Copyright 2011 Intel Corporation; author Matt Fleming 7 * Copyright 2011 Intel Corporation; author Matt Fleming
7 *
8 * This file is part of the Linux kernel, and is made available
9 * under the terms of the GNU General Public License version 2.
10 *
11 */ 8 */
12 9
13#include <linux/efi.h> 10#include <linux/efi.h>
@@ -34,6 +31,7 @@ static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE;
34 31
35static int __section(.data) __nokaslr; 32static int __section(.data) __nokaslr;
36static int __section(.data) __quiet; 33static int __section(.data) __quiet;
34static int __section(.data) __novamap;
37 35
38int __pure nokaslr(void) 36int __pure nokaslr(void)
39{ 37{
@@ -43,6 +41,10 @@ int __pure is_quiet(void)
43{ 41{
44 return __quiet; 42 return __quiet;
45} 43}
44int __pure novamap(void)
45{
46 return __novamap;
47}
46 48
47#define EFI_MMAP_NR_SLACK_SLOTS 8 49#define EFI_MMAP_NR_SLACK_SLOTS 8
48 50
@@ -482,6 +484,11 @@ efi_status_t efi_parse_options(char const *cmdline)
482 __chunk_size = -1UL; 484 __chunk_size = -1UL;
483 } 485 }
484 486
487 if (!strncmp(str, "novamap", 7)) {
488 str += strlen("novamap");
489 __novamap = 1;
490 }
491
485 /* Group words together, delimited by "," */ 492 /* Group words together, delimited by "," */
486 while (*str && *str != ' ' && *str != ',') 493 while (*str && *str != ' ' && *str != ',')
487 str++; 494 str++;
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 32799cf039ef..1b1dfcaa6fb9 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -27,6 +27,7 @@
27 27
28extern int __pure nokaslr(void); 28extern int __pure nokaslr(void);
29extern int __pure is_quiet(void); 29extern int __pure is_quiet(void);
30extern int __pure novamap(void);
30 31
31#define pr_efi(sys_table, msg) do { \ 32#define pr_efi(sys_table, msg) do { \
32 if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \ 33 if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \
@@ -64,4 +65,15 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
64 65
65efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); 66efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
66 67
68/* Helper macros for the usual case of using simple C variables: */
69#ifndef fdt_setprop_inplace_var
70#define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
71 fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var))
72#endif
73
74#ifndef fdt_setprop_var
75#define fdt_setprop_var(fdt, node_offset, name, var) \
76 fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var))
77#endif
78
67#endif 79#endif
diff --git a/drivers/firmware/efi/libstub/fdt.c b/drivers/firmware/efi/libstub/fdt.c
index 0dc7b4987cc2..5440ba17a1c5 100644
--- a/drivers/firmware/efi/libstub/fdt.c
+++ b/drivers/firmware/efi/libstub/fdt.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * FDT related Helper functions used by the EFI stub on multiple 3 * FDT related Helper functions used by the EFI stub on multiple
3 * architectures. This should be #included by the EFI stub 4 * architectures. This should be #included by the EFI stub
4 * implementation files. 5 * implementation files.
5 * 6 *
6 * Copyright 2013 Linaro Limited; author Roy Franz 7 * Copyright 2013 Linaro Limited; author Roy Franz
7 *
8 * This file is part of the Linux kernel, and is made available
9 * under the terms of the GNU General Public License version 2.
10 *
11 */ 8 */
12 9
13#include <linux/efi.h> 10#include <linux/efi.h>
@@ -26,10 +23,8 @@ static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt)
26 offset = fdt_path_offset(fdt, "/"); 23 offset = fdt_path_offset(fdt, "/");
27 /* Set the #address-cells and #size-cells values for an empty tree */ 24 /* Set the #address-cells and #size-cells values for an empty tree */
28 25
29 fdt_setprop_u32(fdt, offset, "#address-cells", 26 fdt_setprop_u32(fdt, offset, "#address-cells", EFI_DT_ADDR_CELLS_DEFAULT);
30 EFI_DT_ADDR_CELLS_DEFAULT); 27 fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
31
32 fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
33} 28}
34 29
35static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, 30static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
@@ -42,7 +37,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
42 u32 fdt_val32; 37 u32 fdt_val32;
43 u64 fdt_val64; 38 u64 fdt_val64;
44 39
45 /* Do some checks on provided FDT, if it exists*/ 40 /* Do some checks on provided FDT, if it exists: */
46 if (orig_fdt) { 41 if (orig_fdt) {
47 if (fdt_check_header(orig_fdt)) { 42 if (fdt_check_header(orig_fdt)) {
48 pr_efi_err(sys_table, "Device Tree header not valid!\n"); 43 pr_efi_err(sys_table, "Device Tree header not valid!\n");
@@ -50,7 +45,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
50 } 45 }
51 /* 46 /*
52 * We don't get the size of the FDT if we get if from a 47 * We don't get the size of the FDT if we get if from a
53 * configuration table. 48 * configuration table:
54 */ 49 */
55 if (orig_fdt_size && fdt_totalsize(orig_fdt) > orig_fdt_size) { 50 if (orig_fdt_size && fdt_totalsize(orig_fdt) > orig_fdt_size) {
56 pr_efi_err(sys_table, "Truncated device tree! foo!\n"); 51 pr_efi_err(sys_table, "Truncated device tree! foo!\n");
@@ -64,8 +59,8 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
64 status = fdt_create_empty_tree(fdt, new_fdt_size); 59 status = fdt_create_empty_tree(fdt, new_fdt_size);
65 if (status == 0) { 60 if (status == 0) {
66 /* 61 /*
67 * Any failure from the following function is non 62 * Any failure from the following function is
68 * critical 63 * non-critical:
69 */ 64 */
70 fdt_update_cell_size(sys_table, fdt); 65 fdt_update_cell_size(sys_table, fdt);
71 } 66 }
@@ -86,12 +81,13 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
86 if (node < 0) { 81 if (node < 0) {
87 node = fdt_add_subnode(fdt, 0, "chosen"); 82 node = fdt_add_subnode(fdt, 0, "chosen");
88 if (node < 0) { 83 if (node < 0) {
89 status = node; /* node is error code when negative */ 84 /* 'node' is an error code when negative: */
85 status = node;
90 goto fdt_set_fail; 86 goto fdt_set_fail;
91 } 87 }
92 } 88 }
93 89
94 if ((cmdline_ptr != NULL) && (strlen(cmdline_ptr) > 0)) { 90 if (cmdline_ptr != NULL && strlen(cmdline_ptr) > 0) {
95 status = fdt_setprop(fdt, node, "bootargs", cmdline_ptr, 91 status = fdt_setprop(fdt, node, "bootargs", cmdline_ptr,
96 strlen(cmdline_ptr) + 1); 92 strlen(cmdline_ptr) + 1);
97 if (status) 93 if (status)
@@ -103,13 +99,12 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
103 u64 initrd_image_end; 99 u64 initrd_image_end;
104 u64 initrd_image_start = cpu_to_fdt64(initrd_addr); 100 u64 initrd_image_start = cpu_to_fdt64(initrd_addr);
105 101
106 status = fdt_setprop(fdt, node, "linux,initrd-start", 102 status = fdt_setprop_var(fdt, node, "linux,initrd-start", initrd_image_start);
107 &initrd_image_start, sizeof(u64));
108 if (status) 103 if (status)
109 goto fdt_set_fail; 104 goto fdt_set_fail;
105
110 initrd_image_end = cpu_to_fdt64(initrd_addr + initrd_size); 106 initrd_image_end = cpu_to_fdt64(initrd_addr + initrd_size);
111 status = fdt_setprop(fdt, node, "linux,initrd-end", 107 status = fdt_setprop_var(fdt, node, "linux,initrd-end", initrd_image_end);
112 &initrd_image_end, sizeof(u64));
113 if (status) 108 if (status)
114 goto fdt_set_fail; 109 goto fdt_set_fail;
115 } 110 }
@@ -117,30 +112,28 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
117 /* Add FDT entries for EFI runtime services in chosen node. */ 112 /* Add FDT entries for EFI runtime services in chosen node. */
118 node = fdt_subnode_offset(fdt, 0, "chosen"); 113 node = fdt_subnode_offset(fdt, 0, "chosen");
119 fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table); 114 fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table);
120 status = fdt_setprop(fdt, node, "linux,uefi-system-table", 115
121 &fdt_val64, sizeof(fdt_val64)); 116 status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64);
122 if (status) 117 if (status)
123 goto fdt_set_fail; 118 goto fdt_set_fail;
124 119
125 fdt_val64 = U64_MAX; /* placeholder */ 120 fdt_val64 = U64_MAX; /* placeholder */
126 status = fdt_setprop(fdt, node, "linux,uefi-mmap-start", 121
127 &fdt_val64, sizeof(fdt_val64)); 122 status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-start", fdt_val64);
128 if (status) 123 if (status)
129 goto fdt_set_fail; 124 goto fdt_set_fail;
130 125
131 fdt_val32 = U32_MAX; /* placeholder */ 126 fdt_val32 = U32_MAX; /* placeholder */
132 status = fdt_setprop(fdt, node, "linux,uefi-mmap-size", 127
133 &fdt_val32, sizeof(fdt_val32)); 128 status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-size", fdt_val32);
134 if (status) 129 if (status)
135 goto fdt_set_fail; 130 goto fdt_set_fail;
136 131
137 status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-size", 132 status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-desc-size", fdt_val32);
138 &fdt_val32, sizeof(fdt_val32));
139 if (status) 133 if (status)
140 goto fdt_set_fail; 134 goto fdt_set_fail;
141 135
142 status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-ver", 136 status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-desc-ver", fdt_val32);
143 &fdt_val32, sizeof(fdt_val32));
144 if (status) 137 if (status)
145 goto fdt_set_fail; 138 goto fdt_set_fail;
146 139
@@ -150,8 +143,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
150 efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64), 143 efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64),
151 (u8 *)&fdt_val64); 144 (u8 *)&fdt_val64);
152 if (efi_status == EFI_SUCCESS) { 145 if (efi_status == EFI_SUCCESS) {
153 status = fdt_setprop(fdt, node, "kaslr-seed", 146 status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64);
154 &fdt_val64, sizeof(fdt_val64));
155 if (status) 147 if (status)
156 goto fdt_set_fail; 148 goto fdt_set_fail;
157 } else if (efi_status != EFI_NOT_FOUND) { 149 } else if (efi_status != EFI_NOT_FOUND) {
@@ -159,7 +151,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
159 } 151 }
160 } 152 }
161 153
162 /* shrink the FDT back to its minimum size */ 154 /* Shrink the FDT back to its minimum size: */
163 fdt_pack(fdt); 155 fdt_pack(fdt);
164 156
165 return EFI_SUCCESS; 157 return EFI_SUCCESS;
@@ -182,26 +174,26 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map)
182 return EFI_LOAD_ERROR; 174 return EFI_LOAD_ERROR;
183 175
184 fdt_val64 = cpu_to_fdt64((unsigned long)*map->map); 176 fdt_val64 = cpu_to_fdt64((unsigned long)*map->map);
185 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-start", 177
186 &fdt_val64, sizeof(fdt_val64)); 178 err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-start", fdt_val64);
187 if (err) 179 if (err)
188 return EFI_LOAD_ERROR; 180 return EFI_LOAD_ERROR;
189 181
190 fdt_val32 = cpu_to_fdt32(*map->map_size); 182 fdt_val32 = cpu_to_fdt32(*map->map_size);
191 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-size", 183
192 &fdt_val32, sizeof(fdt_val32)); 184 err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-size", fdt_val32);
193 if (err) 185 if (err)
194 return EFI_LOAD_ERROR; 186 return EFI_LOAD_ERROR;
195 187
196 fdt_val32 = cpu_to_fdt32(*map->desc_size); 188 fdt_val32 = cpu_to_fdt32(*map->desc_size);
197 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-size", 189
198 &fdt_val32, sizeof(fdt_val32)); 190 err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-desc-size", fdt_val32);
199 if (err) 191 if (err)
200 return EFI_LOAD_ERROR; 192 return EFI_LOAD_ERROR;
201 193
202 fdt_val32 = cpu_to_fdt32(*map->desc_ver); 194 fdt_val32 = cpu_to_fdt32(*map->desc_ver);
203 err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-ver", 195
204 &fdt_val32, sizeof(fdt_val32)); 196 err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-desc-ver", fdt_val32);
205 if (err) 197 if (err)
206 return EFI_LOAD_ERROR; 198 return EFI_LOAD_ERROR;
207 199
@@ -209,13 +201,13 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map)
209} 201}
210 202
211#ifndef EFI_FDT_ALIGN 203#ifndef EFI_FDT_ALIGN
212#define EFI_FDT_ALIGN EFI_PAGE_SIZE 204# define EFI_FDT_ALIGN EFI_PAGE_SIZE
213#endif 205#endif
214 206
215struct exit_boot_struct { 207struct exit_boot_struct {
216 efi_memory_desc_t *runtime_map; 208 efi_memory_desc_t *runtime_map;
217 int *runtime_entry_count; 209 int *runtime_entry_count;
218 void *new_fdt_addr; 210 void *new_fdt_addr;
219}; 211};
220 212
221static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, 213static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg,
@@ -235,7 +227,7 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg,
235} 227}
236 228
237#ifndef MAX_FDT_SIZE 229#ifndef MAX_FDT_SIZE
238#define MAX_FDT_SIZE SZ_2M 230# define MAX_FDT_SIZE SZ_2M
239#endif 231#endif
240 232
241/* 233/*
@@ -266,16 +258,16 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
266 unsigned long mmap_key; 258 unsigned long mmap_key;
267 efi_memory_desc_t *memory_map, *runtime_map; 259 efi_memory_desc_t *memory_map, *runtime_map;
268 efi_status_t status; 260 efi_status_t status;
269 int runtime_entry_count = 0; 261 int runtime_entry_count;
270 struct efi_boot_memmap map; 262 struct efi_boot_memmap map;
271 struct exit_boot_struct priv; 263 struct exit_boot_struct priv;
272 264
273 map.map = &runtime_map; 265 map.map = &runtime_map;
274 map.map_size = &map_size; 266 map.map_size = &map_size;
275 map.desc_size = &desc_size; 267 map.desc_size = &desc_size;
276 map.desc_ver = &desc_ver; 268 map.desc_ver = &desc_ver;
277 map.key_ptr = &mmap_key; 269 map.key_ptr = &mmap_key;
278 map.buff_size = &buff_size; 270 map.buff_size = &buff_size;
279 271
280 /* 272 /*
281 * Get a copy of the current memory map that we will use to prepare 273 * Get a copy of the current memory map that we will use to prepare
@@ -289,15 +281,13 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
289 return status; 281 return status;
290 } 282 }
291 283
292 pr_efi(sys_table, 284 pr_efi(sys_table, "Exiting boot services and installing virtual address map...\n");
293 "Exiting boot services and installing virtual address map...\n");
294 285
295 map.map = &memory_map; 286 map.map = &memory_map;
296 status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN, 287 status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN,
297 new_fdt_addr, max_addr); 288 new_fdt_addr, max_addr);
298 if (status != EFI_SUCCESS) { 289 if (status != EFI_SUCCESS) {
299 pr_efi_err(sys_table, 290 pr_efi_err(sys_table, "Unable to allocate memory for new device tree.\n");
300 "Unable to allocate memory for new device tree.\n");
301 goto fail; 291 goto fail;
302 } 292 }
303 293
@@ -318,15 +308,19 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
318 goto fail_free_new_fdt; 308 goto fail_free_new_fdt;
319 } 309 }
320 310
321 priv.runtime_map = runtime_map; 311 runtime_entry_count = 0;
322 priv.runtime_entry_count = &runtime_entry_count; 312 priv.runtime_map = runtime_map;
323 priv.new_fdt_addr = (void *)*new_fdt_addr; 313 priv.runtime_entry_count = &runtime_entry_count;
324 status = efi_exit_boot_services(sys_table, handle, &map, &priv, 314 priv.new_fdt_addr = (void *)*new_fdt_addr;
325 exit_boot_func); 315
316 status = efi_exit_boot_services(sys_table, handle, &map, &priv, exit_boot_func);
326 317
327 if (status == EFI_SUCCESS) { 318 if (status == EFI_SUCCESS) {
328 efi_set_virtual_address_map_t *svam; 319 efi_set_virtual_address_map_t *svam;
329 320
321 if (novamap())
322 return EFI_SUCCESS;
323
330 /* Install the new virtual address map */ 324 /* Install the new virtual address map */
331 svam = sys_table->runtime->set_virtual_address_map; 325 svam = sys_table->runtime->set_virtual_address_map;
332 status = svam(runtime_entry_count * desc_size, desc_size, 326 status = svam(runtime_entry_count * desc_size, desc_size,
@@ -363,6 +357,7 @@ fail_free_new_fdt:
363 357
364fail: 358fail:
365 sys_table->boottime->free_pool(runtime_map); 359 sys_table->boottime->free_pool(runtime_map);
360
366 return EFI_LOAD_ERROR; 361 return EFI_LOAD_ERROR;
367} 362}
368 363
diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
index 24c461dea7af..0101ca4c13b1 100644
--- a/drivers/firmware/efi/libstub/gop.c
+++ b/drivers/firmware/efi/libstub/gop.c
@@ -1,10 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* ----------------------------------------------------------------------- 2/* -----------------------------------------------------------------------
2 * 3 *
3 * Copyright 2011 Intel Corporation; author Matt Fleming 4 * Copyright 2011 Intel Corporation; author Matt Fleming
4 * 5 *
5 * This file is part of the Linux kernel, and is made available under
6 * the terms of the GNU General Public License version 2.
7 *
8 * ----------------------------------------------------------------------- */ 6 * ----------------------------------------------------------------------- */
9 7
10#include <linux/efi.h> 8#include <linux/efi.h>
diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c
index e0e603a89aa9..b4b1d1dcb5fd 100644
--- a/drivers/firmware/efi/libstub/random.c
+++ b/drivers/firmware/efi/libstub/random.c
@@ -1,10 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> 3 * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 */ 4 */
9 5
10#include <linux/efi.h> 6#include <linux/efi.h>
diff --git a/drivers/firmware/efi/libstub/secureboot.c b/drivers/firmware/efi/libstub/secureboot.c
index 72d9dfbebf08..edba5e7a3743 100644
--- a/drivers/firmware/efi/libstub/secureboot.c
+++ b/drivers/firmware/efi/libstub/secureboot.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Secure boot handling. 3 * Secure boot handling.
3 * 4 *
@@ -5,9 +6,6 @@
5 * Roy Franz <roy.franz@linaro.org 6 * Roy Franz <roy.franz@linaro.org
6 * Copyright (C) 2013 Red Hat, Inc. 7 * Copyright (C) 2013 Red Hat, Inc.
7 * Mark Salter <msalter@redhat.com> 8 * Mark Salter <msalter@redhat.com>
8 *
9 * This file is part of the Linux kernel, and is made available under the
10 * terms of the GNU General Public License version 2.
11 */ 9 */
12#include <linux/efi.h> 10#include <linux/efi.h>
13#include <asm/efi.h> 11#include <asm/efi.h>
diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c
index a90b0b8fc69a..5bd04f75d8d6 100644
--- a/drivers/firmware/efi/libstub/tpm.c
+++ b/drivers/firmware/efi/libstub/tpm.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * TPM handling. 3 * TPM handling.
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (C) 2017 Google, Inc. 6 * Copyright (C) 2017 Google, Inc.
6 * Matthew Garrett <mjg59@google.com> 7 * Matthew Garrett <mjg59@google.com>
7 * Thiebaud Weksteen <tweek@google.com> 8 * Thiebaud Weksteen <tweek@google.com>
8 *
9 * This file is part of the Linux kernel, and is made available under the
10 * terms of the GNU General Public License version 2.
11 */ 9 */
12#include <linux/efi.h> 10#include <linux/efi.h>
13#include <linux/tpm_eventlog.h> 11#include <linux/tpm_eventlog.h>
diff --git a/drivers/firmware/efi/memattr.c b/drivers/firmware/efi/memattr.c
index 8986757eafaf..58452fde92cc 100644
--- a/drivers/firmware/efi/memattr.c
+++ b/drivers/firmware/efi/memattr.c
@@ -1,9 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org> 3 * Copyright (C) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */ 4 */
8 5
9#define pr_fmt(fmt) "efi: memattr: " fmt 6#define pr_fmt(fmt) "efi: memattr: " fmt
@@ -94,7 +91,7 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
94 91
95 if (!(md->attribute & EFI_MEMORY_RUNTIME)) 92 if (!(md->attribute & EFI_MEMORY_RUNTIME))
96 continue; 93 continue;
97 if (md->virt_addr == 0) { 94 if (md->virt_addr == 0 && md->phys_addr != 0) {
98 /* no virtual mapping has been installed by the stub */ 95 /* no virtual mapping has been installed by the stub */
99 break; 96 break;
100 } 97 }
diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c
index 84a11d0a8023..ad9ddefc9dcb 100644
--- a/drivers/firmware/efi/runtime-map.c
+++ b/drivers/firmware/efi/runtime-map.c
@@ -1,8 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/drivers/efi/runtime-map.c 3 * linux/drivers/efi/runtime-map.c
3 * Copyright (C) 2013 Red Hat, Inc., Dave Young <dyoung@redhat.com> 4 * Copyright (C) 2013 Red Hat, Inc., Dave Young <dyoung@redhat.com>
4 *
5 * This file is released under the GPLv2.
6 */ 5 */
7 6
8#include <linux/string.h> 7#include <linux/string.h>
diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c
index e2abfdb5cee6..698745c249e8 100644
--- a/drivers/firmware/efi/runtime-wrappers.c
+++ b/drivers/firmware/efi/runtime-wrappers.c
@@ -85,7 +85,7 @@ struct efi_runtime_work efi_rts_work;
85 pr_err("Failed to queue work to efi_rts_wq.\n"); \ 85 pr_err("Failed to queue work to efi_rts_wq.\n"); \
86 \ 86 \
87exit: \ 87exit: \
88 efi_rts_work.efi_rts_id = NONE; \ 88 efi_rts_work.efi_rts_id = EFI_NONE; \
89 efi_rts_work.status; \ 89 efi_rts_work.status; \
90}) 90})
91 91
@@ -175,50 +175,50 @@ static void efi_call_rts(struct work_struct *work)
175 arg5 = efi_rts_work.arg5; 175 arg5 = efi_rts_work.arg5;
176 176
177 switch (efi_rts_work.efi_rts_id) { 177 switch (efi_rts_work.efi_rts_id) {
178 case GET_TIME: 178 case EFI_GET_TIME:
179 status = efi_call_virt(get_time, (efi_time_t *)arg1, 179 status = efi_call_virt(get_time, (efi_time_t *)arg1,
180 (efi_time_cap_t *)arg2); 180 (efi_time_cap_t *)arg2);
181 break; 181 break;
182 case SET_TIME: 182 case EFI_SET_TIME:
183 status = efi_call_virt(set_time, (efi_time_t *)arg1); 183 status = efi_call_virt(set_time, (efi_time_t *)arg1);
184 break; 184 break;
185 case GET_WAKEUP_TIME: 185 case EFI_GET_WAKEUP_TIME:
186 status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1, 186 status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1,
187 (efi_bool_t *)arg2, (efi_time_t *)arg3); 187 (efi_bool_t *)arg2, (efi_time_t *)arg3);
188 break; 188 break;
189 case SET_WAKEUP_TIME: 189 case EFI_SET_WAKEUP_TIME:
190 status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1, 190 status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1,
191 (efi_time_t *)arg2); 191 (efi_time_t *)arg2);
192 break; 192 break;
193 case GET_VARIABLE: 193 case EFI_GET_VARIABLE:
194 status = efi_call_virt(get_variable, (efi_char16_t *)arg1, 194 status = efi_call_virt(get_variable, (efi_char16_t *)arg1,
195 (efi_guid_t *)arg2, (u32 *)arg3, 195 (efi_guid_t *)arg2, (u32 *)arg3,
196 (unsigned long *)arg4, (void *)arg5); 196 (unsigned long *)arg4, (void *)arg5);
197 break; 197 break;
198 case GET_NEXT_VARIABLE: 198 case EFI_GET_NEXT_VARIABLE:
199 status = efi_call_virt(get_next_variable, (unsigned long *)arg1, 199 status = efi_call_virt(get_next_variable, (unsigned long *)arg1,
200 (efi_char16_t *)arg2, 200 (efi_char16_t *)arg2,
201 (efi_guid_t *)arg3); 201 (efi_guid_t *)arg3);
202 break; 202 break;
203 case SET_VARIABLE: 203 case EFI_SET_VARIABLE:
204 status = efi_call_virt(set_variable, (efi_char16_t *)arg1, 204 status = efi_call_virt(set_variable, (efi_char16_t *)arg1,
205 (efi_guid_t *)arg2, *(u32 *)arg3, 205 (efi_guid_t *)arg2, *(u32 *)arg3,
206 *(unsigned long *)arg4, (void *)arg5); 206 *(unsigned long *)arg4, (void *)arg5);
207 break; 207 break;
208 case QUERY_VARIABLE_INFO: 208 case EFI_QUERY_VARIABLE_INFO:
209 status = efi_call_virt(query_variable_info, *(u32 *)arg1, 209 status = efi_call_virt(query_variable_info, *(u32 *)arg1,
210 (u64 *)arg2, (u64 *)arg3, (u64 *)arg4); 210 (u64 *)arg2, (u64 *)arg3, (u64 *)arg4);
211 break; 211 break;
212 case GET_NEXT_HIGH_MONO_COUNT: 212 case EFI_GET_NEXT_HIGH_MONO_COUNT:
213 status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1); 213 status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1);
214 break; 214 break;
215 case UPDATE_CAPSULE: 215 case EFI_UPDATE_CAPSULE:
216 status = efi_call_virt(update_capsule, 216 status = efi_call_virt(update_capsule,
217 (efi_capsule_header_t **)arg1, 217 (efi_capsule_header_t **)arg1,
218 *(unsigned long *)arg2, 218 *(unsigned long *)arg2,
219 *(unsigned long *)arg3); 219 *(unsigned long *)arg3);
220 break; 220 break;
221 case QUERY_CAPSULE_CAPS: 221 case EFI_QUERY_CAPSULE_CAPS:
222 status = efi_call_virt(query_capsule_caps, 222 status = efi_call_virt(query_capsule_caps,
223 (efi_capsule_header_t **)arg1, 223 (efi_capsule_header_t **)arg1,
224 *(unsigned long *)arg2, (u64 *)arg3, 224 *(unsigned long *)arg2, (u64 *)arg3,
@@ -242,7 +242,7 @@ static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
242 242
243 if (down_interruptible(&efi_runtime_lock)) 243 if (down_interruptible(&efi_runtime_lock))
244 return EFI_ABORTED; 244 return EFI_ABORTED;
245 status = efi_queue_work(GET_TIME, tm, tc, NULL, NULL, NULL); 245 status = efi_queue_work(EFI_GET_TIME, tm, tc, NULL, NULL, NULL);
246 up(&efi_runtime_lock); 246 up(&efi_runtime_lock);
247 return status; 247 return status;
248} 248}
@@ -253,7 +253,7 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm)
253 253
254 if (down_interruptible(&efi_runtime_lock)) 254 if (down_interruptible(&efi_runtime_lock))
255 return EFI_ABORTED; 255 return EFI_ABORTED;
256 status = efi_queue_work(SET_TIME, tm, NULL, NULL, NULL, NULL); 256 status = efi_queue_work(EFI_SET_TIME, tm, NULL, NULL, NULL, NULL);
257 up(&efi_runtime_lock); 257 up(&efi_runtime_lock);
258 return status; 258 return status;
259} 259}
@@ -266,7 +266,7 @@ static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled,
266 266
267 if (down_interruptible(&efi_runtime_lock)) 267 if (down_interruptible(&efi_runtime_lock))
268 return EFI_ABORTED; 268 return EFI_ABORTED;
269 status = efi_queue_work(GET_WAKEUP_TIME, enabled, pending, tm, NULL, 269 status = efi_queue_work(EFI_GET_WAKEUP_TIME, enabled, pending, tm, NULL,
270 NULL); 270 NULL);
271 up(&efi_runtime_lock); 271 up(&efi_runtime_lock);
272 return status; 272 return status;
@@ -278,7 +278,7 @@ static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
278 278
279 if (down_interruptible(&efi_runtime_lock)) 279 if (down_interruptible(&efi_runtime_lock))
280 return EFI_ABORTED; 280 return EFI_ABORTED;
281 status = efi_queue_work(SET_WAKEUP_TIME, &enabled, tm, NULL, NULL, 281 status = efi_queue_work(EFI_SET_WAKEUP_TIME, &enabled, tm, NULL, NULL,
282 NULL); 282 NULL);
283 up(&efi_runtime_lock); 283 up(&efi_runtime_lock);
284 return status; 284 return status;
@@ -294,7 +294,7 @@ static efi_status_t virt_efi_get_variable(efi_char16_t *name,
294 294
295 if (down_interruptible(&efi_runtime_lock)) 295 if (down_interruptible(&efi_runtime_lock))
296 return EFI_ABORTED; 296 return EFI_ABORTED;
297 status = efi_queue_work(GET_VARIABLE, name, vendor, attr, data_size, 297 status = efi_queue_work(EFI_GET_VARIABLE, name, vendor, attr, data_size,
298 data); 298 data);
299 up(&efi_runtime_lock); 299 up(&efi_runtime_lock);
300 return status; 300 return status;
@@ -308,7 +308,7 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
308 308
309 if (down_interruptible(&efi_runtime_lock)) 309 if (down_interruptible(&efi_runtime_lock))
310 return EFI_ABORTED; 310 return EFI_ABORTED;
311 status = efi_queue_work(GET_NEXT_VARIABLE, name_size, name, vendor, 311 status = efi_queue_work(EFI_GET_NEXT_VARIABLE, name_size, name, vendor,
312 NULL, NULL); 312 NULL, NULL);
313 up(&efi_runtime_lock); 313 up(&efi_runtime_lock);
314 return status; 314 return status;
@@ -324,7 +324,7 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name,
324 324
325 if (down_interruptible(&efi_runtime_lock)) 325 if (down_interruptible(&efi_runtime_lock))
326 return EFI_ABORTED; 326 return EFI_ABORTED;
327 status = efi_queue_work(SET_VARIABLE, name, vendor, &attr, &data_size, 327 status = efi_queue_work(EFI_SET_VARIABLE, name, vendor, &attr, &data_size,
328 data); 328 data);
329 up(&efi_runtime_lock); 329 up(&efi_runtime_lock);
330 return status; 330 return status;
@@ -359,7 +359,7 @@ static efi_status_t virt_efi_query_variable_info(u32 attr,
359 359
360 if (down_interruptible(&efi_runtime_lock)) 360 if (down_interruptible(&efi_runtime_lock))
361 return EFI_ABORTED; 361 return EFI_ABORTED;
362 status = efi_queue_work(QUERY_VARIABLE_INFO, &attr, storage_space, 362 status = efi_queue_work(EFI_QUERY_VARIABLE_INFO, &attr, storage_space,
363 remaining_space, max_variable_size, NULL); 363 remaining_space, max_variable_size, NULL);
364 up(&efi_runtime_lock); 364 up(&efi_runtime_lock);
365 return status; 365 return status;
@@ -391,7 +391,7 @@ static efi_status_t virt_efi_get_next_high_mono_count(u32 *count)
391 391
392 if (down_interruptible(&efi_runtime_lock)) 392 if (down_interruptible(&efi_runtime_lock))
393 return EFI_ABORTED; 393 return EFI_ABORTED;
394 status = efi_queue_work(GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL, 394 status = efi_queue_work(EFI_GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL,
395 NULL, NULL); 395 NULL, NULL);
396 up(&efi_runtime_lock); 396 up(&efi_runtime_lock);
397 return status; 397 return status;
@@ -407,7 +407,7 @@ static void virt_efi_reset_system(int reset_type,
407 "could not get exclusive access to the firmware\n"); 407 "could not get exclusive access to the firmware\n");
408 return; 408 return;
409 } 409 }
410 efi_rts_work.efi_rts_id = RESET_SYSTEM; 410 efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
411 __efi_call_virt(reset_system, reset_type, status, data_size, data); 411 __efi_call_virt(reset_system, reset_type, status, data_size, data);
412 up(&efi_runtime_lock); 412 up(&efi_runtime_lock);
413} 413}
@@ -423,7 +423,7 @@ static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules,
423 423
424 if (down_interruptible(&efi_runtime_lock)) 424 if (down_interruptible(&efi_runtime_lock))
425 return EFI_ABORTED; 425 return EFI_ABORTED;
426 status = efi_queue_work(UPDATE_CAPSULE, capsules, &count, &sg_list, 426 status = efi_queue_work(EFI_UPDATE_CAPSULE, capsules, &count, &sg_list,
427 NULL, NULL); 427 NULL, NULL);
428 up(&efi_runtime_lock); 428 up(&efi_runtime_lock);
429 return status; 429 return status;
@@ -441,7 +441,7 @@ static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules,
441 441
442 if (down_interruptible(&efi_runtime_lock)) 442 if (down_interruptible(&efi_runtime_lock))
443 return EFI_ABORTED; 443 return EFI_ABORTED;
444 status = efi_queue_work(QUERY_CAPSULE_CAPS, capsules, &count, 444 status = efi_queue_work(EFI_QUERY_CAPSULE_CAPS, capsules, &count,
445 max_size, reset_type, NULL); 445 max_size, reset_type, NULL);
446 up(&efi_runtime_lock); 446 up(&efi_runtime_lock);
447 return status; 447 return status;
diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
index 51ecf7d6da48..877745c3aaf2 100644
--- a/drivers/firmware/efi/test/efi_test.c
+++ b/drivers/firmware/efi/test/efi_test.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * EFI Test Driver for Runtime Services 3 * EFI Test Driver for Runtime Services
3 * 4 *
diff --git a/drivers/firmware/efi/test/efi_test.h b/drivers/firmware/efi/test/efi_test.h
index 5f4818bf112f..f2446aa1c2e3 100644
--- a/drivers/firmware/efi/test/efi_test.h
+++ b/drivers/firmware/efi/test/efi_test.h
@@ -1,4 +1,4 @@
1/* SPDX-License-Identifier: GPL-2.0 */ 1/* SPDX-License-Identifier: GPL-2.0+ */
2/* 2/*
3 * EFI Test driver Header 3 * EFI Test driver Header
4 * 4 *
diff --git a/drivers/firmware/efi/tpm.c b/drivers/firmware/efi/tpm.c
index 0cbeb3d46b18..3a689b40ccc0 100644
--- a/drivers/firmware/efi/tpm.c
+++ b/drivers/firmware/efi/tpm.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2017 Google, Inc. 3 * Copyright (C) 2017 Google, Inc.
3 * Thiebaud Weksteen <tweek@google.com> 4 * Thiebaud Weksteen <tweek@google.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */ 5 */
9 6
10#include <linux/efi.h> 7#include <linux/efi.h>
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index fceaafd67ec6..436d1776bc7b 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -1,22 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Originally from efivars.c 3 * Originally from efivars.c
3 * 4 *
4 * Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com> 5 * Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com>
5 * Copyright (C) 2004 Intel Corporation <matthew.e.tolentino@intel.com> 6 * Copyright (C) 2004 Intel Corporation <matthew.e.tolentino@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */ 7 */
21 8
22#include <linux/capability.h> 9#include <linux/capability.h>
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 28604a8d0aa9..ae96ea145ae3 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -48,7 +48,20 @@ typedef u16 efi_char16_t; /* UNICODE character */
48typedef u64 efi_physical_addr_t; 48typedef u64 efi_physical_addr_t;
49typedef void *efi_handle_t; 49typedef void *efi_handle_t;
50 50
51typedef guid_t efi_guid_t; 51/*
52 * The UEFI spec and EDK2 reference implementation both define EFI_GUID as
53 * struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment
54 * is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM),
55 * this means that firmware services invoked by the kernel may assume that
56 * efi_guid_t* arguments are 32-bit aligned, and use memory accessors that
57 * do not tolerate misalignment. So let's set the minimum alignment to 32 bits.
58 *
59 * Note that the UEFI spec as well as some comments in the EDK2 code base
60 * suggest that EFI_GUID should be 64-bit aligned, but this appears to be
61 * a mistake, given that no code seems to exist that actually enforces that
62 * or relies on it.
63 */
64typedef guid_t efi_guid_t __aligned(__alignof__(u32));
52 65
53#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 66#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
54 GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 67 GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)
@@ -1699,19 +1712,19 @@ extern int efi_tpm_eventlog_init(void);
1699 * fault happened while executing an efi runtime service. 1712 * fault happened while executing an efi runtime service.
1700 */ 1713 */
1701enum efi_rts_ids { 1714enum efi_rts_ids {
1702 NONE, 1715 EFI_NONE,
1703 GET_TIME, 1716 EFI_GET_TIME,
1704 SET_TIME, 1717 EFI_SET_TIME,
1705 GET_WAKEUP_TIME, 1718 EFI_GET_WAKEUP_TIME,
1706 SET_WAKEUP_TIME, 1719 EFI_SET_WAKEUP_TIME,
1707 GET_VARIABLE, 1720 EFI_GET_VARIABLE,
1708 GET_NEXT_VARIABLE, 1721 EFI_GET_NEXT_VARIABLE,
1709 SET_VARIABLE, 1722 EFI_SET_VARIABLE,
1710 QUERY_VARIABLE_INFO, 1723 EFI_QUERY_VARIABLE_INFO,
1711 GET_NEXT_HIGH_MONO_COUNT, 1724 EFI_GET_NEXT_HIGH_MONO_COUNT,
1712 RESET_SYSTEM, 1725 EFI_RESET_SYSTEM,
1713 UPDATE_CAPSULE, 1726 EFI_UPDATE_CAPSULE,
1714 QUERY_CAPSULE_CAPS, 1727 EFI_QUERY_CAPSULE_CAPS,
1715}; 1728};
1716 1729
1717/* 1730/*