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 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

+393 -567
+7 -1
Documentation/admin-guide/kernel-parameters.txt
··· 1078 1078 specified address. The serial port must already be 1079 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 1088 earlyprintk= [X86,SH,ARM,M68k,S390] 1082 1089 earlyprintk=vga 1083 - earlyprintk=efi 1084 1090 earlyprintk=sclp 1085 1091 earlyprintk=xen 1086 1092 earlyprintk=serial[,ttySn[,baudrate]]
+3
arch/Kconfig
··· 895 895 architectures, and don't require runtime relocation on relocatable 896 896 kernels. 897 897 898 + config ARCH_USE_MEMREMAP_PROT 899 + bool 900 + 898 901 source "kernel/gcov/Kconfig" 899 902 900 903 source "scripts/gcc-plugins/Kconfig"
+1 -4
arch/x86/Kconfig
··· 1510 1510 bool "AMD Secure Memory Encryption (SME) support" 1511 1511 depends on X86_64 && CPU_SUP_AMD 1512 1512 select DYNAMIC_PHYSICAL_MASK 1513 + select ARCH_USE_MEMREMAP_PROT 1513 1514 ---help--- 1514 1515 Say yes to enable support for the encryption of system memory. 1515 1516 This requires an AMD processor that supports Secure Memory ··· 1529 1528 1530 1529 If set to N, then the encryption of system memory can be 1531 1530 activated with the mem_encrypt=on command line option. 1532 - 1533 - config ARCH_USE_MEMREMAP_PROT 1534 - def_bool y 1535 - depends on AMD_MEM_ENCRYPT 1536 1531 1537 1532 # Common NUMA Features 1538 1533 config NUMA
-10
arch/x86/Kconfig.debug
··· 40 40 with klogd/syslogd or the X server. You should normally say N here, 41 41 unless you want to debug such a crash. You need usb debug device. 42 42 43 - config 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 - 53 43 config EARLY_PRINTK_USB_XDBC 54 44 bool "Early printk via the xHCI debug port" 55 45 depends on EARLY_PRINTK && PCI
-1
arch/x86/include/asm/efi.h
··· 170 170 return false; 171 171 } 172 172 173 - extern struct console early_efi_console; 174 173 extern void parse_efi_setup(u64 phys_addr, u32 data_len); 175 174 176 175 extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt);
-4
arch/x86/kernel/early_printk.c
··· 388 388 if (!strncmp(buf, "xen", 3)) 389 389 early_console_register(&xenboot_console, keep); 390 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 391 #ifdef CONFIG_EARLY_PRINTK_USB_XDBC 396 392 if (!strncmp(buf, "xdbc", 4)) 397 393 early_xdbc_parse_parameter(buf + 4);
+2 -2
arch/x86/mm/ioremap.c
··· 705 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 709 /* Remap memory with encryption */ 710 710 void __init *early_memremap_encrypted(resource_size_t phys_addr, 711 711 unsigned long size) ··· 747 747 748 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 752 752 static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; 753 753
-1
arch/x86/platform/efi/Makefile
··· 3 3 OBJECT_FILES_NON_STANDARD_efi_stub_$(BITS).o := y 4 4 5 5 obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o 6 - obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o 7 6 obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o
-240
arch/x86/platform/efi/early_printk.c
··· 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 - 15 - static const struct font_desc *font; 16 - static u32 efi_x, efi_y; 17 - static void *efi_fb; 18 - static 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 - */ 27 - static __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 - } 42 - early_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 - */ 49 - static __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 - 63 - static __ref void early_efi_unmap(void *addr, unsigned long len) 64 - { 65 - if (!efi_fb) 66 - early_iounmap(addr, len); 67 - } 68 - 69 - static 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 - 83 - static 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 - 110 - static 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 - 130 - static void 131 - early_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 - 203 - static __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 - 234 - struct 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 - };
+3 -3
arch/x86/platform/efi/quirks.c
··· 304 304 * - Not within any part of the kernel 305 305 * - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc) 306 306 */ 307 - static bool can_free_region(u64 start, u64 size) 307 + static __init bool can_free_region(u64 start, u64 size) 308 308 { 309 309 if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end)) 310 310 return false; ··· 717 717 * "efi_mm" cannot be used to check if the page fault had occurred 718 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 721 return; 722 722 723 723 /* ··· 742 742 * because this case occurs *very* rarely and hence could be improved 743 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 746 pr_info("efi_reset_system() buggy! Reboot through BIOS\n"); 747 747 machine_real_restart(MRR_BIOS); 748 748 return;
+6
drivers/firmware/efi/Kconfig
··· 198 198 bool 199 199 depends on ACPI 200 200 default n 201 + 202 + config EFI_EARLYCON 203 + def_bool y 204 + depends on SERIAL_EARLYCON && !ARM && !IA64 205 + select FONT_SUPPORT 206 + select ARCH_USE_MEMREMAP_PROT
+1
drivers/firmware/efi/Makefile
··· 30 30 obj-$(CONFIG_ARM) += $(arm-obj-y) 31 31 obj-$(CONFIG_ARM64) += $(arm-obj-y) 32 32 obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o 33 + obj-$(CONFIG_EFI_EARLYCON) += earlycon.o 33 34 obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o 34 35 obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o
+1 -12
drivers/firmware/efi/apple-properties.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * apple-properties.c - EFI device properties on Macs 3 4 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> 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 - * 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 5 * 17 6 * Note, all properties are considered as u8 arrays. 18 7 * To get a value of any of them the caller must use device_property_read_u8_array().
+1 -5
drivers/firmware/efi/arm-init.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Extensible Firmware Interface 3 4 * 4 5 * Based on Extensible Firmware Interface Specification version 2.4 5 6 * 6 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 10 #define pr_fmt(fmt) "efi: " fmt
+1 -5
drivers/firmware/efi/arm-runtime.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Extensible Firmware Interface 3 4 * 4 5 * Based on Extensible Firmware Interface Specification version 2.4 5 6 * 6 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 10 #include <linux/dmi.h>
+1 -3
drivers/firmware/efi/capsule-loader.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * EFI capsule loader driver. 3 4 * 4 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 8 #define pr_fmt(fmt) "efi: " fmt
+1 -3
drivers/firmware/efi/capsule.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * EFI capsule support. 3 4 * 4 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 8 #define pr_fmt(fmt) "efi: " fmt
+1 -13
drivers/firmware/efi/cper-arm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * UEFI Common Platform Error Record (CPER) support 3 4 * 4 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 8 #include <linux/kernel.h>
+1 -13
drivers/firmware/efi/cper.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * UEFI Common Platform Error Record (CPER) support 3 4 * ··· 10 9 * 11 10 * For more information about CPER, please refer to Appendix N of UEFI 12 11 * Specification version 2.4. 13 - * 14 - * This program is free software; you can redistribute it and/or 15 - * modify it under the terms of the GNU General Public License version 16 - * 2 as published by the Free Software Foundation. 17 - * 18 - * This program is distributed in the hope that it will be useful, 19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 - * GNU General Public License for more details. 22 - * 23 - * You should have received a copy of the GNU General Public License 24 - * along with this program; if not, write to the Free Software 25 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 26 12 */ 27 13 28 14 #include <linux/kernel.h>
+1 -8
drivers/firmware/efi/dev-path-parser.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * dev-path-parser.c - EFI Device Path parser 3 4 * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> ··· 6 5 * This program is free software; you can redistribute it and/or modify 7 6 * it under the terms of the GNU General Public License (version 2) as 8 7 * 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, see <http://www.gnu.org/licenses/>. 17 8 */ 18 9 19 10 #include <linux/acpi.h>
+206
drivers/firmware/efi/earlycon.c
··· 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 + 16 + static const struct font_desc *font; 17 + static u32 efi_x, efi_y; 18 + static u64 fb_base; 19 + static pgprot_t fb_prot; 20 + 21 + static __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 + 26 + static __ref void efi_earlycon_unmap(void *addr, unsigned long len) 27 + { 28 + early_memunmap(addr, len); 29 + } 30 + 31 + static 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 + 45 + static 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 + 72 + static 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 + 92 + static void 93 + efi_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 + 165 + static 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 + } 206 + EARLYCON_DECLARE(efifb, efi_earlycon_setup);
+1 -4
drivers/firmware/efi/efi-bgrt.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright 2012 Intel Corporation 3 4 * Author: Josh Triplett <josh@joshtriplett.org> ··· 6 5 * Based on the bgrt driver: 7 6 * Copyright 2012 Red Hat, Inc <mjg@redhat.com> 8 7 * Author: Matthew Garrett 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 version 2 as 12 - * published by the Free Software Foundation. 13 8 */ 14 9 15 10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+2
drivers/firmware/efi/efi-pstore.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + 1 3 #include <linux/efi.h> 2 4 #include <linux/module.h> 3 5 #include <linux/pstore.h>
+1 -9
drivers/firmware/efi/efibc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * efibc: control EFI bootloaders which obey LoaderEntryOneShot var 3 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 7 #define pr_fmt(fmt) "efibc: " fmt
+1 -57
drivers/firmware/efi/efivars.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Originally from efivars.c, 3 4 * ··· 7 6 * 8 7 * This code takes all variables accessible from EFI runtime and 9 8 * exports them via sysfs 10 - * 11 - * This program is free software; you can redistribute it and/or modify 12 - * it under the terms of the GNU General Public License as published by 13 - * the Free Software Foundation; either version 2 of the License, or 14 - * (at your option) any later version. 15 - * 16 - * This program is distributed in the hope that it will be useful, 17 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 - * GNU General Public License for more details. 20 - * 21 - * You should have received a copy of the GNU General Public License 22 - * along with this program; if not, write to the Free Software 23 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 - * 25 - * Changelog: 26 - * 27 - * 17 May 2004 - Matt Domsch <Matt_Domsch@dell.com> 28 - * remove check for efi_enabled in exit 29 - * add MODULE_VERSION 30 - * 31 - * 26 Apr 2004 - Matt Domsch <Matt_Domsch@dell.com> 32 - * minor bug fixes 33 - * 34 - * 21 Apr 2004 - Matt Tolentino <matthew.e.tolentino@intel.com) 35 - * converted driver to export variable information via sysfs 36 - * and moved to drivers/firmware directory 37 - * bumped revision number to v0.07 to reflect conversion & move 38 - * 39 - * 10 Dec 2002 - Matt Domsch <Matt_Domsch@dell.com> 40 - * fix locking per Peter Chubb's findings 41 - * 42 - * 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com> 43 - * move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_to_str() 44 - * 45 - * 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com> 46 - * use list_for_each_safe when deleting vars. 47 - * remove ifdef CONFIG_SMP around include <linux/smp.h> 48 - * v0.04 release to linux-ia64@linuxia64.org 49 - * 50 - * 20 April 2001 - Matt Domsch <Matt_Domsch@dell.com> 51 - * Moved vars from /proc/efi to /proc/efi/vars, and made 52 - * efi.c own the /proc/efi directory. 53 - * v0.03 release to linux-ia64@linuxia64.org 54 - * 55 - * 26 March 2001 - Matt Domsch <Matt_Domsch@dell.com> 56 - * At the request of Stephane, moved ownership of /proc/efi 57 - * to efi.c, and now efivars lives under /proc/efi/vars. 58 - * 59 - * 12 March 2001 - Matt Domsch <Matt_Domsch@dell.com> 60 - * Feedback received from Stephane Eranian incorporated. 61 - * efivar_write() checks copy_from_user() return value. 62 - * efivar_read/write() returns proper errno. 63 - * v0.02 release to linux-ia64@linuxia64.org 64 - * 65 - * 26 February 2001 - Matt Domsch <Matt_Domsch@dell.com> 66 - * v0.01 release to linux-ia64@linuxia64.org 67 9 */ 68 10 69 11 #include <linux/efi.h>
+1
drivers/firmware/efi/esrt.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * esrt.c 3 4 *
+1 -15
drivers/firmware/efi/fake_mem.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * fake_mem.c 3 4 * ··· 9 8 * By specifying this parameter, you can add arbitrary attribute to 10 9 * specific memory range by updating original (firmware provided) EFI 11 10 * memmap. 12 - * 13 - * This program is free software; you can redistribute it and/or modify it 14 - * under the terms and conditions of the GNU General Public License, 15 - * version 2, as published by the Free Software Foundation. 16 - * 17 - * This program is distributed in the hope it will be useful, but WITHOUT 18 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 20 - * more details. 21 - * 22 - * You should have received a copy of the GNU General Public License along with 23 - * this program; if not, see <http://www.gnu.org/licenses/>. 24 - * 25 - * The full GNU General Public License is included in this distribution in 26 - * the file called "COPYING". 27 11 */ 28 12 29 13 #include <linux/kernel.h>
+2 -2
drivers/firmware/efi/libstub/Makefile
··· 52 52 53 53 lib-$(CONFIG_ARM) += arm32-stub.o 54 54 lib-$(CONFIG_ARM64) += arm64-stub.o 55 - CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 55 + CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) 56 56 57 57 # 58 58 # arm64 puts the stub in the kernel proper, which will unnecessarily retain all ··· 89 89 cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \ 90 90 then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \ 91 91 then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \ 92 - rm -f $@; /bin/false); \ 92 + rm -f $@; /bin/false); \ 93 93 else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \ 94 94 else /bin/false; fi 95 95
+5
drivers/firmware/efi/libstub/arm-stub.c
··· 367 367 paddr = in->phys_addr; 368 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 376 * Make the mapping compatible with 64k pages: this allows 372 377 * a 4k page size kernel to kexec a 64k page size kernel and
+1 -5
drivers/firmware/efi/libstub/arm32-stub.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 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 5 #include <linux/efi.h> 10 6 #include <asm/efi.h>
+1 -5
drivers/firmware/efi/libstub/arm64-stub.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org> 3 4 * 4 5 * This file implements the EFI boot stub for the arm64 kernel. 5 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 /*
+11 -4
drivers/firmware/efi/libstub/efi-stub-helper.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Helper functions used by the EFI stub on multiple 3 4 * architectures. This should be #included by the EFI stub 4 5 * implementation files. 5 6 * 6 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 10 #include <linux/efi.h> ··· 31 34 32 35 static int __section(.data) __nokaslr; 33 36 static int __section(.data) __quiet; 37 + static int __section(.data) __novamap; 34 38 35 39 int __pure nokaslr(void) 36 40 { ··· 40 42 int __pure is_quiet(void) 41 43 { 42 44 return __quiet; 45 + } 46 + int __pure novamap(void) 47 + { 48 + return __novamap; 43 49 } 44 50 45 51 #define EFI_MMAP_NR_SLACK_SLOTS 8 ··· 482 480 if (!strncmp(str, "nochunk", 7)) { 483 481 str += strlen("nochunk"); 484 482 __chunk_size = -1UL; 483 + } 484 + 485 + if (!strncmp(str, "novamap", 7)) { 486 + str += strlen("novamap"); 487 + __novamap = 1; 485 488 } 486 489 487 490 /* Group words together, delimited by "," */
+12
drivers/firmware/efi/libstub/efistub.h
··· 27 27 28 28 extern int __pure nokaslr(void); 29 29 extern int __pure is_quiet(void); 30 + extern int __pure novamap(void); 30 31 31 32 #define pr_efi(sys_table, msg) do { \ 32 33 if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \ ··· 64 63 efi_status_t check_platform_features(efi_system_table_t *sys_table_arg); 65 64 66 65 efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); 66 + 67 + /* Helper macros for the usual case of using simple C variables: */ 68 + #ifndef fdt_setprop_inplace_var 69 + #define fdt_setprop_inplace_var(fdt, node_offset, name, var) \ 70 + fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var)) 71 + #endif 72 + 73 + #ifndef fdt_setprop_var 74 + #define fdt_setprop_var(fdt, node_offset, name, var) \ 75 + fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var)) 76 + #endif 67 77 68 78 #endif
+55 -60
drivers/firmware/efi/libstub/fdt.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * FDT related Helper functions used by the EFI stub on multiple 3 4 * architectures. This should be #included by the EFI stub 4 5 * implementation files. 5 6 * 6 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 10 #include <linux/efi.h> ··· 23 26 offset = fdt_path_offset(fdt, "/"); 24 27 /* Set the #address-cells and #size-cells values for an empty tree */ 25 28 26 - fdt_setprop_u32(fdt, offset, "#address-cells", 27 - EFI_DT_ADDR_CELLS_DEFAULT); 28 - 29 - fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT); 29 + fdt_setprop_u32(fdt, offset, "#address-cells", EFI_DT_ADDR_CELLS_DEFAULT); 30 + fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT); 30 31 } 31 32 32 33 static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ··· 37 42 u32 fdt_val32; 38 43 u64 fdt_val64; 39 44 40 - /* Do some checks on provided FDT, if it exists*/ 45 + /* Do some checks on provided FDT, if it exists: */ 41 46 if (orig_fdt) { 42 47 if (fdt_check_header(orig_fdt)) { 43 48 pr_efi_err(sys_table, "Device Tree header not valid!\n"); ··· 45 50 } 46 51 /* 47 52 * We don't get the size of the FDT if we get if from a 48 - * configuration table. 53 + * configuration table: 49 54 */ 50 55 if (orig_fdt_size && fdt_totalsize(orig_fdt) > orig_fdt_size) { 51 56 pr_efi_err(sys_table, "Truncated device tree! foo!\n"); ··· 59 64 status = fdt_create_empty_tree(fdt, new_fdt_size); 60 65 if (status == 0) { 61 66 /* 62 - * Any failure from the following function is non 63 - * critical 67 + * Any failure from the following function is 68 + * non-critical: 64 69 */ 65 70 fdt_update_cell_size(sys_table, fdt); 66 71 } ··· 81 86 if (node < 0) { 82 87 node = fdt_add_subnode(fdt, 0, "chosen"); 83 88 if (node < 0) { 84 - status = node; /* node is error code when negative */ 89 + /* 'node' is an error code when negative: */ 90 + status = node; 85 91 goto fdt_set_fail; 86 92 } 87 93 } 88 94 89 - if ((cmdline_ptr != NULL) && (strlen(cmdline_ptr) > 0)) { 95 + if (cmdline_ptr != NULL && strlen(cmdline_ptr) > 0) { 90 96 status = fdt_setprop(fdt, node, "bootargs", cmdline_ptr, 91 97 strlen(cmdline_ptr) + 1); 92 98 if (status) ··· 99 103 u64 initrd_image_end; 100 104 u64 initrd_image_start = cpu_to_fdt64(initrd_addr); 101 105 102 - status = fdt_setprop(fdt, node, "linux,initrd-start", 103 - &initrd_image_start, sizeof(u64)); 106 + status = fdt_setprop_var(fdt, node, "linux,initrd-start", initrd_image_start); 104 107 if (status) 105 108 goto fdt_set_fail; 109 + 106 110 initrd_image_end = cpu_to_fdt64(initrd_addr + initrd_size); 107 - status = fdt_setprop(fdt, node, "linux,initrd-end", 108 - &initrd_image_end, sizeof(u64)); 111 + status = fdt_setprop_var(fdt, node, "linux,initrd-end", initrd_image_end); 109 112 if (status) 110 113 goto fdt_set_fail; 111 114 } ··· 112 117 /* Add FDT entries for EFI runtime services in chosen node. */ 113 118 node = fdt_subnode_offset(fdt, 0, "chosen"); 114 119 fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table); 115 - status = fdt_setprop(fdt, node, "linux,uefi-system-table", 116 - &fdt_val64, sizeof(fdt_val64)); 120 + 121 + status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64); 117 122 if (status) 118 123 goto fdt_set_fail; 119 124 120 125 fdt_val64 = U64_MAX; /* placeholder */ 121 - status = fdt_setprop(fdt, node, "linux,uefi-mmap-start", 122 - &fdt_val64, sizeof(fdt_val64)); 126 + 127 + status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-start", fdt_val64); 123 128 if (status) 124 129 goto fdt_set_fail; 125 130 126 131 fdt_val32 = U32_MAX; /* placeholder */ 127 - status = fdt_setprop(fdt, node, "linux,uefi-mmap-size", 128 - &fdt_val32, sizeof(fdt_val32)); 132 + 133 + status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-size", fdt_val32); 129 134 if (status) 130 135 goto fdt_set_fail; 131 136 132 - status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-size", 133 - &fdt_val32, sizeof(fdt_val32)); 137 + status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-desc-size", fdt_val32); 134 138 if (status) 135 139 goto fdt_set_fail; 136 140 137 - status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-ver", 138 - &fdt_val32, sizeof(fdt_val32)); 141 + status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-desc-ver", fdt_val32); 139 142 if (status) 140 143 goto fdt_set_fail; 141 144 ··· 143 150 efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64), 144 151 (u8 *)&fdt_val64); 145 152 if (efi_status == EFI_SUCCESS) { 146 - status = fdt_setprop(fdt, node, "kaslr-seed", 147 - &fdt_val64, sizeof(fdt_val64)); 153 + status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64); 148 154 if (status) 149 155 goto fdt_set_fail; 150 156 } else if (efi_status != EFI_NOT_FOUND) { ··· 151 159 } 152 160 } 153 161 154 - /* shrink the FDT back to its minimum size */ 162 + /* Shrink the FDT back to its minimum size: */ 155 163 fdt_pack(fdt); 156 164 157 165 return EFI_SUCCESS; ··· 174 182 return EFI_LOAD_ERROR; 175 183 176 184 fdt_val64 = cpu_to_fdt64((unsigned long)*map->map); 177 - err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-start", 178 - &fdt_val64, sizeof(fdt_val64)); 185 + 186 + err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-start", fdt_val64); 179 187 if (err) 180 188 return EFI_LOAD_ERROR; 181 189 182 190 fdt_val32 = cpu_to_fdt32(*map->map_size); 183 - err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-size", 184 - &fdt_val32, sizeof(fdt_val32)); 191 + 192 + err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-size", fdt_val32); 185 193 if (err) 186 194 return EFI_LOAD_ERROR; 187 195 188 196 fdt_val32 = cpu_to_fdt32(*map->desc_size); 189 - err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-size", 190 - &fdt_val32, sizeof(fdt_val32)); 197 + 198 + err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-desc-size", fdt_val32); 191 199 if (err) 192 200 return EFI_LOAD_ERROR; 193 201 194 202 fdt_val32 = cpu_to_fdt32(*map->desc_ver); 195 - err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-ver", 196 - &fdt_val32, sizeof(fdt_val32)); 203 + 204 + err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-desc-ver", fdt_val32); 197 205 if (err) 198 206 return EFI_LOAD_ERROR; 199 207 ··· 201 209 } 202 210 203 211 #ifndef EFI_FDT_ALIGN 204 - #define EFI_FDT_ALIGN EFI_PAGE_SIZE 212 + # define EFI_FDT_ALIGN EFI_PAGE_SIZE 205 213 #endif 206 214 207 215 struct exit_boot_struct { 208 - efi_memory_desc_t *runtime_map; 209 - int *runtime_entry_count; 210 - void *new_fdt_addr; 216 + efi_memory_desc_t *runtime_map; 217 + int *runtime_entry_count; 218 + void *new_fdt_addr; 211 219 }; 212 220 213 221 static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, ··· 227 235 } 228 236 229 237 #ifndef MAX_FDT_SIZE 230 - #define MAX_FDT_SIZE SZ_2M 238 + # define MAX_FDT_SIZE SZ_2M 231 239 #endif 232 240 233 241 /* ··· 258 266 unsigned long mmap_key; 259 267 efi_memory_desc_t *memory_map, *runtime_map; 260 268 efi_status_t status; 261 - int runtime_entry_count = 0; 269 + int runtime_entry_count; 262 270 struct efi_boot_memmap map; 263 271 struct exit_boot_struct priv; 264 272 265 - map.map = &runtime_map; 266 - map.map_size = &map_size; 267 - map.desc_size = &desc_size; 268 - map.desc_ver = &desc_ver; 269 - map.key_ptr = &mmap_key; 270 - map.buff_size = &buff_size; 273 + map.map = &runtime_map; 274 + map.map_size = &map_size; 275 + map.desc_size = &desc_size; 276 + map.desc_ver = &desc_ver; 277 + map.key_ptr = &mmap_key; 278 + map.buff_size = &buff_size; 271 279 272 280 /* 273 281 * Get a copy of the current memory map that we will use to prepare ··· 281 289 return status; 282 290 } 283 291 284 - pr_efi(sys_table, 285 - "Exiting boot services and installing virtual address map...\n"); 292 + pr_efi(sys_table, "Exiting boot services and installing virtual address map...\n"); 286 293 287 294 map.map = &memory_map; 288 295 status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN, 289 296 new_fdt_addr, max_addr); 290 297 if (status != EFI_SUCCESS) { 291 - pr_efi_err(sys_table, 292 - "Unable to allocate memory for new device tree.\n"); 298 + pr_efi_err(sys_table, "Unable to allocate memory for new device tree.\n"); 293 299 goto fail; 294 300 } 295 301 ··· 308 318 goto fail_free_new_fdt; 309 319 } 310 320 311 - priv.runtime_map = runtime_map; 312 - priv.runtime_entry_count = &runtime_entry_count; 313 - priv.new_fdt_addr = (void *)*new_fdt_addr; 314 - status = efi_exit_boot_services(sys_table, handle, &map, &priv, 315 - exit_boot_func); 321 + runtime_entry_count = 0; 322 + priv.runtime_map = runtime_map; 323 + priv.runtime_entry_count = &runtime_entry_count; 324 + priv.new_fdt_addr = (void *)*new_fdt_addr; 325 + 326 + status = efi_exit_boot_services(sys_table, handle, &map, &priv, exit_boot_func); 316 327 317 328 if (status == EFI_SUCCESS) { 318 329 efi_set_virtual_address_map_t *svam; 330 + 331 + if (novamap()) 332 + return EFI_SUCCESS; 319 333 320 334 /* Install the new virtual address map */ 321 335 svam = sys_table->runtime->set_virtual_address_map; ··· 357 363 358 364 fail: 359 365 sys_table->boottime->free_pool(runtime_map); 366 + 360 367 return EFI_LOAD_ERROR; 361 368 } 362 369
+1 -3
drivers/firmware/efi/libstub/gop.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* ----------------------------------------------------------------------- 2 3 * 3 4 * Copyright 2011 Intel Corporation; author Matt Fleming 4 - * 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 5 * 8 6 * ----------------------------------------------------------------------- */ 9 7
+1 -5
drivers/firmware/efi/libstub/random.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 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 6 #include <linux/efi.h>
+1 -3
drivers/firmware/efi/libstub/secureboot.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Secure boot handling. 3 4 * ··· 6 5 * Roy Franz <roy.franz@linaro.org 7 6 * Copyright (C) 2013 Red Hat, Inc. 8 7 * Mark Salter <msalter@redhat.com> 9 - * 10 - * This file is part of the Linux kernel, and is made available under the 11 - * terms of the GNU General Public License version 2. 12 8 */ 13 9 #include <linux/efi.h> 14 10 #include <asm/efi.h>
+1 -3
drivers/firmware/efi/libstub/tpm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * TPM handling. 3 4 * ··· 6 5 * Copyright (C) 2017 Google, Inc. 7 6 * Matthew Garrett <mjg59@google.com> 8 7 * Thiebaud Weksteen <tweek@google.com> 9 - * 10 - * This file is part of the Linux kernel, and is made available under the 11 - * terms of the GNU General Public License version 2. 12 8 */ 13 9 #include <linux/efi.h> 14 10 #include <linux/tpm_eventlog.h>
+2 -5
drivers/firmware/efi/memattr.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 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 6 #define pr_fmt(fmt) "efi: memattr: " fmt ··· 91 94 92 95 if (!(md->attribute & EFI_MEMORY_RUNTIME)) 93 96 continue; 94 - if (md->virt_addr == 0) { 97 + if (md->virt_addr == 0 && md->phys_addr != 0) { 95 98 /* no virtual mapping has been installed by the stub */ 96 99 break; 97 100 }
+1 -2
drivers/firmware/efi/runtime-map.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * linux/drivers/efi/runtime-map.c 3 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 7 #include <linux/string.h>
+24 -24
drivers/firmware/efi/runtime-wrappers.c
··· 85 85 pr_err("Failed to queue work to efi_rts_wq.\n"); \ 86 86 \ 87 87 exit: \ 88 - efi_rts_work.efi_rts_id = NONE; \ 88 + efi_rts_work.efi_rts_id = EFI_NONE; \ 89 89 efi_rts_work.status; \ 90 90 }) 91 91 ··· 175 175 arg5 = efi_rts_work.arg5; 176 176 177 177 switch (efi_rts_work.efi_rts_id) { 178 - case GET_TIME: 178 + case EFI_GET_TIME: 179 179 status = efi_call_virt(get_time, (efi_time_t *)arg1, 180 180 (efi_time_cap_t *)arg2); 181 181 break; 182 - case SET_TIME: 182 + case EFI_SET_TIME: 183 183 status = efi_call_virt(set_time, (efi_time_t *)arg1); 184 184 break; 185 - case GET_WAKEUP_TIME: 185 + case EFI_GET_WAKEUP_TIME: 186 186 status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1, 187 187 (efi_bool_t *)arg2, (efi_time_t *)arg3); 188 188 break; 189 - case SET_WAKEUP_TIME: 189 + case EFI_SET_WAKEUP_TIME: 190 190 status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1, 191 191 (efi_time_t *)arg2); 192 192 break; 193 - case GET_VARIABLE: 193 + case EFI_GET_VARIABLE: 194 194 status = efi_call_virt(get_variable, (efi_char16_t *)arg1, 195 195 (efi_guid_t *)arg2, (u32 *)arg3, 196 196 (unsigned long *)arg4, (void *)arg5); 197 197 break; 198 - case GET_NEXT_VARIABLE: 198 + case EFI_GET_NEXT_VARIABLE: 199 199 status = efi_call_virt(get_next_variable, (unsigned long *)arg1, 200 200 (efi_char16_t *)arg2, 201 201 (efi_guid_t *)arg3); 202 202 break; 203 - case SET_VARIABLE: 203 + case EFI_SET_VARIABLE: 204 204 status = efi_call_virt(set_variable, (efi_char16_t *)arg1, 205 205 (efi_guid_t *)arg2, *(u32 *)arg3, 206 206 *(unsigned long *)arg4, (void *)arg5); 207 207 break; 208 - case QUERY_VARIABLE_INFO: 208 + case EFI_QUERY_VARIABLE_INFO: 209 209 status = efi_call_virt(query_variable_info, *(u32 *)arg1, 210 210 (u64 *)arg2, (u64 *)arg3, (u64 *)arg4); 211 211 break; 212 - case GET_NEXT_HIGH_MONO_COUNT: 212 + case EFI_GET_NEXT_HIGH_MONO_COUNT: 213 213 status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1); 214 214 break; 215 - case UPDATE_CAPSULE: 215 + case EFI_UPDATE_CAPSULE: 216 216 status = efi_call_virt(update_capsule, 217 217 (efi_capsule_header_t **)arg1, 218 218 *(unsigned long *)arg2, 219 219 *(unsigned long *)arg3); 220 220 break; 221 - case QUERY_CAPSULE_CAPS: 221 + case EFI_QUERY_CAPSULE_CAPS: 222 222 status = efi_call_virt(query_capsule_caps, 223 223 (efi_capsule_header_t **)arg1, 224 224 *(unsigned long *)arg2, (u64 *)arg3, ··· 242 242 243 243 if (down_interruptible(&efi_runtime_lock)) 244 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 246 up(&efi_runtime_lock); 247 247 return status; 248 248 } ··· 253 253 254 254 if (down_interruptible(&efi_runtime_lock)) 255 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 257 up(&efi_runtime_lock); 258 258 return status; 259 259 } ··· 266 266 267 267 if (down_interruptible(&efi_runtime_lock)) 268 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 270 NULL); 271 271 up(&efi_runtime_lock); 272 272 return status; ··· 278 278 279 279 if (down_interruptible(&efi_runtime_lock)) 280 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 282 NULL); 283 283 up(&efi_runtime_lock); 284 284 return status; ··· 294 294 295 295 if (down_interruptible(&efi_runtime_lock)) 296 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 298 data); 299 299 up(&efi_runtime_lock); 300 300 return status; ··· 308 308 309 309 if (down_interruptible(&efi_runtime_lock)) 310 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 312 NULL, NULL); 313 313 up(&efi_runtime_lock); 314 314 return status; ··· 324 324 325 325 if (down_interruptible(&efi_runtime_lock)) 326 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 328 data); 329 329 up(&efi_runtime_lock); 330 330 return status; ··· 359 359 360 360 if (down_interruptible(&efi_runtime_lock)) 361 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 363 remaining_space, max_variable_size, NULL); 364 364 up(&efi_runtime_lock); 365 365 return status; ··· 391 391 392 392 if (down_interruptible(&efi_runtime_lock)) 393 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 395 NULL, NULL); 396 396 up(&efi_runtime_lock); 397 397 return status; ··· 407 407 "could not get exclusive access to the firmware\n"); 408 408 return; 409 409 } 410 - efi_rts_work.efi_rts_id = RESET_SYSTEM; 410 + efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM; 411 411 __efi_call_virt(reset_system, reset_type, status, data_size, data); 412 412 up(&efi_runtime_lock); 413 413 } ··· 423 423 424 424 if (down_interruptible(&efi_runtime_lock)) 425 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 427 NULL, NULL); 428 428 up(&efi_runtime_lock); 429 429 return status; ··· 441 441 442 442 if (down_interruptible(&efi_runtime_lock)) 443 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 445 max_size, reset_type, NULL); 446 446 up(&efi_runtime_lock); 447 447 return status;
+1
drivers/firmware/efi/test/efi_test.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * EFI Test Driver for Runtime Services 3 4 *
+1 -1
drivers/firmware/efi/test/efi_test.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 2 /* 3 3 * EFI Test driver Header 4 4 *
+1 -4
drivers/firmware/efi/tpm.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * Copyright (C) 2017 Google, Inc. 3 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 7 #include <linux/efi.h>
+1 -14
drivers/firmware/efi/vars.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 1 2 /* 2 3 * Originally from efivars.c 3 4 * 4 5 * Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com> 5 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 9 #include <linux/capability.h>
+27 -14
include/linux/efi.h
··· 48 48 typedef u64 efi_physical_addr_t; 49 49 typedef void *efi_handle_t; 50 50 51 - typedef 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 + */ 64 + typedef guid_t efi_guid_t __aligned(__alignof__(u32)); 52 65 53 66 #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ 54 67 GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) ··· 1712 1699 * fault happened while executing an efi runtime service. 1713 1700 */ 1714 1701 enum efi_rts_ids { 1715 - NONE, 1716 - GET_TIME, 1717 - SET_TIME, 1718 - GET_WAKEUP_TIME, 1719 - SET_WAKEUP_TIME, 1720 - GET_VARIABLE, 1721 - GET_NEXT_VARIABLE, 1722 - SET_VARIABLE, 1723 - QUERY_VARIABLE_INFO, 1724 - GET_NEXT_HIGH_MONO_COUNT, 1725 - RESET_SYSTEM, 1726 - UPDATE_CAPSULE, 1727 - QUERY_CAPSULE_CAPS, 1702 + EFI_NONE, 1703 + EFI_GET_TIME, 1704 + EFI_SET_TIME, 1705 + EFI_GET_WAKEUP_TIME, 1706 + EFI_SET_WAKEUP_TIME, 1707 + EFI_GET_VARIABLE, 1708 + EFI_GET_NEXT_VARIABLE, 1709 + EFI_SET_VARIABLE, 1710 + EFI_QUERY_VARIABLE_INFO, 1711 + EFI_GET_NEXT_HIGH_MONO_COUNT, 1712 + EFI_RESET_SYSTEM, 1713 + EFI_UPDATE_CAPSULE, 1714 + EFI_QUERY_CAPSULE_CAPS, 1728 1715 }; 1729 1716 1730 1717 /*