Commit c8f5ed6e authored by Linus Torvalds's avatar Linus Torvalds

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
parents 3717f613 5c418dc7
...@@ -1078,9 +1078,15 @@ ...@@ -1078,9 +1078,15 @@
specified address. The serial port must already be specified address. The serial port must already be
setup and configured. Options are not yet supported. setup and configured. Options are not yet supported.
efifb,[options]
Start an early, unaccelerated console on the EFI
memory mapped framebuffer (if available). On cache
coherent non-x86 systems that use system memory for
the framebuffer, pass the 'ram' option so that it is
mapped with the correct attributes.
earlyprintk= [X86,SH,ARM,M68k,S390] earlyprintk= [X86,SH,ARM,M68k,S390]
earlyprintk=vga earlyprintk=vga
earlyprintk=efi
earlyprintk=sclp earlyprintk=sclp
earlyprintk=xen earlyprintk=xen
earlyprintk=serial[,ttySn[,baudrate]] earlyprintk=serial[,ttySn[,baudrate]]
......
...@@ -895,6 +895,9 @@ config HAVE_ARCH_PREL32_RELOCATIONS ...@@ -895,6 +895,9 @@ config HAVE_ARCH_PREL32_RELOCATIONS
architectures, and don't require runtime relocation on relocatable architectures, and don't require runtime relocation on relocatable
kernels. kernels.
config ARCH_USE_MEMREMAP_PROT
bool
source "kernel/gcov/Kconfig" source "kernel/gcov/Kconfig"
source "scripts/gcc-plugins/Kconfig" source "scripts/gcc-plugins/Kconfig"
......
...@@ -1510,6 +1510,7 @@ config AMD_MEM_ENCRYPT ...@@ -1510,6 +1510,7 @@ config AMD_MEM_ENCRYPT
bool "AMD Secure Memory Encryption (SME) support" bool "AMD Secure Memory Encryption (SME) support"
depends on X86_64 && CPU_SUP_AMD depends on X86_64 && CPU_SUP_AMD
select DYNAMIC_PHYSICAL_MASK select DYNAMIC_PHYSICAL_MASK
select ARCH_USE_MEMREMAP_PROT
---help--- ---help---
Say yes to enable support for the encryption of system memory. Say yes to enable support for the encryption of system memory.
This requires an AMD processor that supports Secure Memory This requires an AMD processor that supports Secure Memory
...@@ -1529,10 +1530,6 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT ...@@ -1529,10 +1530,6 @@ config AMD_MEM_ENCRYPT_ACTIVE_BY_DEFAULT
If set to N, then the encryption of system memory can be If set to N, then the encryption of system memory can be
activated with the mem_encrypt=on command line option. activated with the mem_encrypt=on command line option.
config ARCH_USE_MEMREMAP_PROT
def_bool y
depends on AMD_MEM_ENCRYPT
# Common NUMA Features # Common NUMA Features
config NUMA config NUMA
bool "Numa Memory Allocation and Scheduler Support" bool "Numa Memory Allocation and Scheduler Support"
......
...@@ -40,16 +40,6 @@ config EARLY_PRINTK_DBGP ...@@ -40,16 +40,6 @@ config EARLY_PRINTK_DBGP
with klogd/syslogd or the X server. You should normally say N here, with klogd/syslogd or the X server. You should normally say N here,
unless you want to debug such a crash. You need usb debug device. unless you want to debug such a crash. You need usb debug device.
config EARLY_PRINTK_EFI
bool "Early printk via the EFI framebuffer"
depends on EFI && EARLY_PRINTK
select FONT_SUPPORT
---help---
Write kernel log output directly into the EFI framebuffer.
This is useful for kernel debugging when your machine crashes very
early before the console code is initialized.
config EARLY_PRINTK_USB_XDBC config EARLY_PRINTK_USB_XDBC
bool "Early printk via the xHCI debug port" bool "Early printk via the xHCI debug port"
depends on EARLY_PRINTK && PCI depends on EARLY_PRINTK && PCI
......
...@@ -170,7 +170,6 @@ static inline bool efi_runtime_supported(void) ...@@ -170,7 +170,6 @@ static inline bool efi_runtime_supported(void)
return false; return false;
} }
extern struct console early_efi_console;
extern void parse_efi_setup(u64 phys_addr, u32 data_len); extern void parse_efi_setup(u64 phys_addr, u32 data_len);
extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt); extern void efifb_setup_from_dmi(struct screen_info *si, const char *opt);
......
...@@ -388,10 +388,6 @@ static int __init setup_early_printk(char *buf) ...@@ -388,10 +388,6 @@ static int __init setup_early_printk(char *buf)
if (!strncmp(buf, "xen", 3)) if (!strncmp(buf, "xen", 3))
early_console_register(&xenboot_console, keep); early_console_register(&xenboot_console, keep);
#endif #endif
#ifdef CONFIG_EARLY_PRINTK_EFI
if (!strncmp(buf, "efi", 3))
early_console_register(&early_efi_console, keep);
#endif
#ifdef CONFIG_EARLY_PRINTK_USB_XDBC #ifdef CONFIG_EARLY_PRINTK_USB_XDBC
if (!strncmp(buf, "xdbc", 4)) if (!strncmp(buf, "xdbc", 4))
early_xdbc_parse_parameter(buf + 4); early_xdbc_parse_parameter(buf + 4);
......
...@@ -705,7 +705,7 @@ bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size) ...@@ -705,7 +705,7 @@ bool phys_mem_access_encrypted(unsigned long phys_addr, unsigned long size)
return arch_memremap_can_ram_remap(phys_addr, size, 0); return arch_memremap_can_ram_remap(phys_addr, size, 0);
} }
#ifdef CONFIG_ARCH_USE_MEMREMAP_PROT #ifdef CONFIG_AMD_MEM_ENCRYPT
/* Remap memory with encryption */ /* Remap memory with encryption */
void __init *early_memremap_encrypted(resource_size_t phys_addr, void __init *early_memremap_encrypted(resource_size_t phys_addr,
unsigned long size) unsigned long size)
...@@ -747,7 +747,7 @@ void __init *early_memremap_decrypted_wp(resource_size_t phys_addr, ...@@ -747,7 +747,7 @@ void __init *early_memremap_decrypted_wp(resource_size_t phys_addr,
return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP); return early_memremap_prot(phys_addr, size, __PAGE_KERNEL_NOENC_WP);
} }
#endif /* CONFIG_ARCH_USE_MEMREMAP_PROT */ #endif /* CONFIG_AMD_MEM_ENCRYPT */
static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss; static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
......
...@@ -3,5 +3,4 @@ OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y ...@@ -3,5 +3,4 @@ OBJECT_FILES_NON_STANDARD_efi_thunk_$(BITS).o := y
OBJECT_FILES_NON_STANDARD_efi_stub_$(BITS).o := y OBJECT_FILES_NON_STANDARD_efi_stub_$(BITS).o := y
obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o obj-$(CONFIG_EFI) += quirks.o efi.o efi_$(BITS).o efi_stub_$(BITS).o
obj-$(CONFIG_EARLY_PRINTK_EFI) += early_printk.o
obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o obj-$(CONFIG_EFI_MIXED) += efi_thunk_$(BITS).o
...@@ -304,7 +304,7 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size) ...@@ -304,7 +304,7 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
* - Not within any part of the kernel * - Not within any part of the kernel
* - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc) * - Not the BIOS reserved area (E820_TYPE_RESERVED, E820_TYPE_NVS, etc)
*/ */
static bool can_free_region(u64 start, u64 size) static __init bool can_free_region(u64 start, u64 size)
{ {
if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end)) if (start + size > __pa_symbol(_text) && start <= __pa_symbol(_end))
return false; return false;
...@@ -717,7 +717,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr) ...@@ -717,7 +717,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr)
* "efi_mm" cannot be used to check if the page fault had occurred * "efi_mm" cannot be used to check if the page fault had occurred
* in the firmware context because efi=old_map doesn't use efi_pgd. * in the firmware context because efi=old_map doesn't use efi_pgd.
*/ */
if (efi_rts_work.efi_rts_id == NONE) if (efi_rts_work.efi_rts_id == EFI_NONE)
return; return;
/* /*
...@@ -742,7 +742,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr) ...@@ -742,7 +742,7 @@ void efi_recover_from_page_fault(unsigned long phys_addr)
* because this case occurs *very* rarely and hence could be improved * because this case occurs *very* rarely and hence could be improved
* on a need by basis. * on a need by basis.
*/ */
if (efi_rts_work.efi_rts_id == RESET_SYSTEM) { if (efi_rts_work.efi_rts_id == EFI_RESET_SYSTEM) {
pr_info("efi_reset_system() buggy! Reboot through BIOS\n"); pr_info("efi_reset_system() buggy! Reboot through BIOS\n");
machine_real_restart(MRR_BIOS); machine_real_restart(MRR_BIOS);
return; return;
......
...@@ -198,3 +198,9 @@ config EFI_DEV_PATH_PARSER ...@@ -198,3 +198,9 @@ config EFI_DEV_PATH_PARSER
bool bool
depends on ACPI depends on ACPI
default n default n
config EFI_EARLYCON
def_bool y
depends on SERIAL_EARLYCON && !ARM && !IA64
select FONT_SUPPORT
select ARCH_USE_MEMREMAP_PROT
...@@ -30,5 +30,6 @@ arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o ...@@ -30,5 +30,6 @@ arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o
obj-$(CONFIG_ARM) += $(arm-obj-y) obj-$(CONFIG_ARM) += $(arm-obj-y)
obj-$(CONFIG_ARM64) += $(arm-obj-y) obj-$(CONFIG_ARM64) += $(arm-obj-y)
obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o obj-$(CONFIG_EFI_CAPSULE_LOADER) += capsule-loader.o
obj-$(CONFIG_EFI_EARLYCON) += earlycon.o
obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o obj-$(CONFIG_UEFI_CPER_ARM) += cper-arm.o
obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o obj-$(CONFIG_UEFI_CPER_X86) += cper-x86.o
// SPDX-License-Identifier: GPL-2.0
/* /*
* apple-properties.c - EFI device properties on Macs * apple-properties.c - EFI device properties on Macs
* Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
* *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2) as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*
* Note, all properties are considered as u8 arrays. * Note, all properties are considered as u8 arrays.
* To get a value of any of them the caller must use device_property_read_u8_array(). * To get a value of any of them the caller must use device_property_read_u8_array().
*/ */
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Extensible Firmware Interface * Extensible Firmware Interface
* *
* Based on Extensible Firmware Interface Specification version 2.4 * Based on Extensible Firmware Interface Specification version 2.4
* *
* Copyright (C) 2013 - 2015 Linaro Ltd. * Copyright (C) 2013 - 2015 Linaro Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
#define pr_fmt(fmt) "efi: " fmt #define pr_fmt(fmt) "efi: " fmt
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Extensible Firmware Interface * Extensible Firmware Interface
* *
* Based on Extensible Firmware Interface Specification version 2.4 * Based on Extensible Firmware Interface Specification version 2.4
* *
* Copyright (C) 2013, 2014 Linaro Ltd. * Copyright (C) 2013, 2014 Linaro Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
#include <linux/dmi.h> #include <linux/dmi.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* EFI capsule loader driver. * EFI capsule loader driver.
* *
* Copyright 2015 Intel Corporation * Copyright 2015 Intel Corporation
*
* This file is part of the Linux kernel, and is made available under
* the terms of the GNU General Public License version 2.
*/ */
#define pr_fmt(fmt) "efi: " fmt #define pr_fmt(fmt) "efi: " fmt
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* EFI capsule support. * EFI capsule support.
* *
* Copyright 2013 Intel Corporation; author Matt Fleming * Copyright 2013 Intel Corporation; author Matt Fleming
*
* This file is part of the Linux kernel, and is made available under
* the terms of the GNU General Public License version 2.
*/ */
#define pr_fmt(fmt) "efi: " fmt #define pr_fmt(fmt) "efi: " fmt
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* UEFI Common Platform Error Record (CPER) support * UEFI Common Platform Error Record (CPER) support
* *
* Copyright (C) 2017, The Linux Foundation. All rights reserved. * Copyright (C) 2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* UEFI Common Platform Error Record (CPER) support * UEFI Common Platform Error Record (CPER) support
* *
...@@ -9,19 +10,6 @@ ...@@ -9,19 +10,6 @@
* *
* For more information about CPER, please refer to Appendix N of UEFI * For more information about CPER, please refer to Appendix N of UEFI
* Specification version 2.4. * Specification version 2.4.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version
* 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* dev-path-parser.c - EFI Device Path parser * dev-path-parser.c - EFI Device Path parser
* Copyright (C) 2016 Lukas Wunner <lukas@wunner.de> * Copyright (C) 2016 Lukas Wunner <lukas@wunner.de>
...@@ -5,14 +6,6 @@ ...@@ -5,14 +6,6 @@
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2) as * it under the terms of the GNU General Public License (version 2) as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include <linux/acpi.h> #include <linux/acpi.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2013 Intel Corporation; author Matt Fleming * Copyright (C) 2013 Intel Corporation; author Matt Fleming
*
* This file is part of the Linux kernel, and is made available under
* the terms of the GNU General Public License version 2.
*/ */
#include <linux/console.h> #include <linux/console.h>
...@@ -10,104 +8,68 @@ ...@@ -10,104 +8,68 @@
#include <linux/font.h> #include <linux/font.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <asm/setup.h> #include <linux/serial_core.h>
#include <linux/screen_info.h>
#include <asm/early_ioremap.h>
static const struct font_desc *font; static const struct font_desc *font;
static u32 efi_x, efi_y; static u32 efi_x, efi_y;
static void *efi_fb; static u64 fb_base;
static bool early_efi_keep; static pgprot_t fb_prot;
/*
* efi earlyprintk need use early_ioremap to map the framebuffer.
* But early_ioremap is not usable for earlyprintk=efi,keep, ioremap should
* be used instead. ioremap will be available after paging_init() which is
* earlier than initcall callbacks. Thus adding this early initcall function
* early_efi_map_fb to map the whole efi framebuffer.
*/
static __init int early_efi_map_fb(void)
{
u64 base, size;
if (!early_efi_keep) static __ref void *efi_earlycon_map(unsigned long start, unsigned long len)
return 0;
base = boot_params.screen_info.lfb_base;
if (boot_params.screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
base |= (u64)boot_params.screen_info.ext_lfb_base << 32;
size = boot_params.screen_info.lfb_size;
efi_fb = ioremap(base, size);
return efi_fb ? 0 : -ENOMEM;
}
early_initcall(early_efi_map_fb);
/*
* early_efi_map maps efi framebuffer region [start, start + len -1]
* In case earlyprintk=efi,keep we have the whole framebuffer mapped already
* so just return the offset efi_fb + start.
*/
static __ref void *early_efi_map(unsigned long start, unsigned long len)
{ {
u64 base; return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot));
base = boot_params.screen_info.lfb_base;
if (boot_params.screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
base |= (u64)boot_params.screen_info.ext_lfb_base << 32;
if (efi_fb)
return (efi_fb + start);
else
return early_ioremap(base + start, len);
} }
static __ref void early_efi_unmap(void *addr, unsigned long len) static __ref void efi_earlycon_unmap(void *addr, unsigned long len)
{ {
if (!efi_fb) early_memunmap(addr, len);
early_iounmap(addr, len);
} }
static void early_efi_clear_scanline(unsigned int y) static void efi_earlycon_clear_scanline(unsigned int y)
{ {
unsigned long *dst; unsigned long *dst;
u16 len; u16 len;
len = boot_params.screen_info.lfb_linelength; len = screen_info.lfb_linelength;
dst = early_efi_map(y*len, len); dst = efi_earlycon_map(y*len, len);
if (!dst) if (!dst)
return; return;
memset(dst, 0, len); memset(dst, 0, len);
early_efi_unmap(dst, len); efi_earlycon_unmap(dst, len);
} }
static void early_efi_scroll_up(void) static void efi_earlycon_scroll_up(void)
{ {
unsigned long *dst, *src; unsigned long *dst, *src;
u16 len; u16 len;
u32 i, height; u32 i, height;
len = boot_params.screen_info.lfb_linelength; len = screen_info.lfb_linelength;
height = boot_params.screen_info.lfb_height; height = screen_info.lfb_height;
for (i = 0; i < height - font->height; i++) { for (i = 0; i < height - font->height; i++) {
dst = early_efi_map(i*len, len); dst = efi_earlycon_map(i*len, len);
if (!dst) if (!dst)
return; return;
src = early_efi_map((i + font->height) * len, len); src = efi_earlycon_map((i + font->height) * len, len);
if (!src) { if (!src) {
early_efi_unmap(dst, len); efi_earlycon_unmap(dst, len);
return; return;
} }
memmove(dst, src, len); memmove(dst, src, len);
early_efi_unmap(src, len); efi_earlycon_unmap(src, len);
early_efi_unmap(dst, len); efi_earlycon_unmap(dst, len);
} }
} }
static void early_efi_write_char(u32 *dst, unsigned char c, unsigned int h) static void efi_earlycon_write_char(u32 *dst, unsigned char c, unsigned int h)
{ {
const u32 color_black = 0x00000000; const u32 color_black = 0x00000000;
const u32 color_white = 0x00ffffff; const u32 color_white = 0x00ffffff;
...@@ -128,14 +90,14 @@ static void early_efi_write_char(u32 *dst, unsigned char c, unsigned int h) ...@@ -128,14 +90,14 @@ static void early_efi_write_char(u32 *dst, unsigned char c, unsigned int h)
} }
static void static void
early_efi_write(struct console *con, const char *str, unsigned int num) efi_earlycon_write(struct console *con, const char *str, unsigned int num)
{ {
struct screen_info *si; struct screen_info *si;
unsigned int len; unsigned int len;
const char *s; const char *s;
void *dst; void *dst;
si = &boot_params.screen_info; si = &screen_info;
len = si->lfb_linelength; len = si->lfb_linelength;
while (num) { while (num) {
...@@ -155,7 +117,7 @@ early_efi_write(struct console *con, const char *str, unsigned int num) ...@@ -155,7 +117,7 @@ early_efi_write(struct console *con, const char *str, unsigned int num)
for (h = 0; h < font->height; h++) { for (h = 0; h < font->height; h++) {
unsigned int n, x; unsigned int n, x;
dst = early_efi_map((efi_y + h) * len, len); dst = efi_earlycon_map((efi_y + h) * len, len);
if (!dst) if (!dst)
return; return;
...@@ -164,12 +126,12 @@ early_efi_write(struct console *con, const char *str, unsigned int num) ...@@ -164,12 +126,12 @@ early_efi_write(struct console *con, const char *str, unsigned int num)
x = efi_x; x = efi_x;
while (n-- > 0) { while (n-- > 0) {
early_efi_write_char(dst + x*4, *s, h); efi_earlycon_write_char(dst + x*4, *s, h);
x += font->width; x += font->width;
s++; s++;
} }
early_efi_unmap(dst, len); efi_earlycon_unmap(dst, len);
} }
num -= count; num -= count;
...@@ -192,27 +154,40 @@ early_efi_write(struct console *con, const char *str, unsigned int num) ...@@ -192,27 +154,40 @@ early_efi_write(struct console *con, const char *str, unsigned int num)
u32 i; u32 i;
efi_y -= font->height; efi_y -= font->height;
early_efi_scroll_up(); efi_earlycon_scroll_up();
for (i = 0; i < font->height; i++) for (i = 0; i < font->height; i++)
early_efi_clear_scanline(efi_y + i); efi_earlycon_clear_scanline(efi_y + i);
} }
} }
} }
static __init int early_efi_setup(struct console *con, char *options) static int __init efi_earlycon_setup(struct earlycon_device *device,
const char *opt)
{ {
struct screen_info *si; struct screen_info *si;
u16 xres, yres; u16 xres, yres;
u32 i; u32 i;
si = &boot_params.screen_info; if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI)
return -ENODEV;
fb_base = screen_info.lfb_base;
if (screen_info.capabilities & VIDEO_CAPABILITY_64BIT_BASE)
fb_base |= (u64)screen_info.ext_lfb_base << 32;
if (opt && !strcmp(opt, "ram"))
fb_prot = PAGE_KERNEL;
else
fb_prot = pgprot_writecombine(PAGE_KERNEL);
si = &screen_info;
xres = si->lfb_width; xres = si->lfb_width;
yres = si->lfb_height; yres = si->lfb_height;
/* /*
* early_efi_write_char() implicitly assumes a framebuffer with * efi_earlycon_write_char() implicitly assumes a framebuffer with
* 32-bits per pixel. * 32 bits per pixel.
*/ */
if (si->lfb_depth != 32) if (si->lfb_depth != 32)
return -ENODEV; return -ENODEV;
...@@ -223,18 +198,9 @@ static __init int early_efi_setup(struct console *con, char *options) ...@@ -223,18 +198,9 @@ static __init int early_efi_setup(struct console *con, char *options)
efi_y = rounddown(yres, font->height) - font->height; efi_y = rounddown(yres, font->height) - font->height;
for (i = 0; i < (yres - efi_y) / font->height; i++) for (i = 0; i < (yres - efi_y) / font->height; i++)
early_efi_scroll_up(); efi_earlycon_scroll_up();
/* early_console_register will unset CON_BOOT in case ,keep */ device->con->write = efi_earlycon_write;
if (!(con->flags & CON_BOOT))
early_efi_keep = true;
return 0; return 0;
} }
EARLYCON_DECLARE(efifb, efi_earlycon_setup);
struct console early_efi_console = {
.name = "earlyefi",
.write = early_efi_write,
.setup = early_efi_setup,
.flags = CON_PRINTBUFFER,
.index = -1,
};
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright 2012 Intel Corporation * Copyright 2012 Intel Corporation
* Author: Josh Triplett <josh@joshtriplett.org> * Author: Josh Triplett <josh@joshtriplett.org>
...@@ -5,10 +6,6 @@ ...@@ -5,10 +6,6 @@
* Based on the bgrt driver: * Based on the bgrt driver:
* Copyright 2012 Red Hat, Inc <mjg@redhat.com> * Copyright 2012 Red Hat, Inc <mjg@redhat.com>
* Author: Matthew Garrett * Author: Matthew Garrett
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
......
// SPDX-License-Identifier: GPL-2.0+
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pstore.h> #include <linux/pstore.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* efibc: control EFI bootloaders which obey LoaderEntryOneShot var * efibc: control EFI bootloaders which obey LoaderEntryOneShot var
* Copyright (c) 2013-2016, Intel Corporation. * Copyright (c) 2013-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/ */
#define pr_fmt(fmt) "efibc: " fmt #define pr_fmt(fmt) "efibc: " fmt
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Originally from efivars.c, * Originally from efivars.c,
* *
...@@ -6,63 +7,6 @@ ...@@ -6,63 +7,6 @@
* *
* This code takes all variables accessible from EFI runtime and * This code takes all variables accessible from EFI runtime and
* exports them via sysfs * exports them via sysfs
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Changelog:
*
* 17 May 2004 - Matt Domsch <Matt_Domsch@dell.com>
* remove check for efi_enabled in exit
* add MODULE_VERSION
*
* 26 Apr 2004 - Matt Domsch <Matt_Domsch@dell.com>
* minor bug fixes
*
* 21 Apr 2004 - Matt Tolentino <matthew.e.tolentino@intel.com)
* converted driver to export variable information via sysfs
* and moved to drivers/firmware directory
* bumped revision number to v0.07 to reflect conversion & move
*
* 10 Dec 2002 - Matt Domsch <Matt_Domsch@dell.com>
* fix locking per Peter Chubb's findings
*
* 25 Mar 2002 - Matt Domsch <Matt_Domsch@dell.com>
* move uuid_unparse() to include/asm-ia64/efi.h:efi_guid_to_str()
*
* 12 Feb 2002 - Matt Domsch <Matt_Domsch@dell.com>
* use list_for_each_safe when deleting vars.
* remove ifdef CONFIG_SMP around include <linux/smp.h>
* v0.04 release to linux-ia64@linuxia64.org
*
* 20 April 2001 - Matt Domsch <Matt_Domsch@dell.com>
* Moved vars from /proc/efi to /proc/efi/vars, and made
* efi.c own the /proc/efi directory.
* v0.03 release to linux-ia64@linuxia64.org
*
* 26 March 2001 - Matt Domsch <Matt_Domsch@dell.com>
* At the request of Stephane, moved ownership of /proc/efi
* to efi.c, and now efivars lives under /proc/efi/vars.
*
* 12 March 2001 - Matt Domsch <Matt_Domsch@dell.com>
* Feedback received from Stephane Eranian incorporated.
* efivar_write() checks copy_from_user() return value.
* efivar_read/write() returns proper errno.
* v0.02 release to linux-ia64@linuxia64.org
*
* 26 February 2001 - Matt Domsch <Matt_Domsch@dell.com>
* v0.01 release to linux-ia64@linuxia64.org
*/ */
#include <linux/efi.h> #include <linux/efi.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* esrt.c * esrt.c
* *
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fake_mem.c * fake_mem.c
* *
...@@ -8,21 +9,6 @@ ...@@ -8,21 +9,6 @@
* By specifying this parameter, you can add arbitrary attribute to * By specifying this parameter, you can add arbitrary attribute to
* specific memory range by updating original (firmware provided) EFI * specific memory range by updating original (firmware provided) EFI
* memmap. * memmap.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, see <http://www.gnu.org/licenses/>.
*
* The full GNU General Public License is included in this distribution in
* the file called "COPYING".
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
......
...@@ -52,7 +52,7 @@ lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \ ...@@ -52,7 +52,7 @@ lib-$(CONFIG_EFI_ARMSTUB) += arm-stub.o fdt.o string.o random.o \
lib-$(CONFIG_ARM) += arm32-stub.o lib-$(CONFIG_ARM) += arm32-stub.o
lib-$(CONFIG_ARM64) += arm64-stub.o lib-$(CONFIG_ARM64) += arm64-stub.o
CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET) CFLAGS_arm64-stub.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
# #
# arm64 puts the stub in the kernel proper, which will unnecessarily retain all # arm64 puts the stub in the kernel proper, which will unnecessarily retain all
...@@ -89,7 +89,7 @@ quiet_cmd_stubcopy = STUBCPY $@ ...@@ -89,7 +89,7 @@ quiet_cmd_stubcopy = STUBCPY $@
cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \ cmd_stubcopy = if $(STRIP) --strip-debug $(STUBCOPY_RM-y) -o $@ $<; \
then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \ then if $(OBJDUMP) -r $@ | grep $(STUBCOPY_RELOC-y); \
then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \ then (echo >&2 "$@: absolute symbol references not allowed in the EFI stub"; \
rm -f $@; /bin/false); \ rm -f $@; /bin/false); \
else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \ else $(OBJCOPY) $(STUBCOPY_FLAGS-y) $< $@; fi \
else /bin/false; fi else /bin/false; fi
......
...@@ -367,6 +367,11 @@ void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size, ...@@ -367,6 +367,11 @@ void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
paddr = in->phys_addr; paddr = in->phys_addr;
size = in->num_pages * EFI_PAGE_SIZE; size = in->num_pages * EFI_PAGE_SIZE;
if (novamap()) {
in->virt_addr = in->phys_addr;
continue;
}
/* /*
* Make the mapping compatible with 64k pages: this allows * Make the mapping compatible with 64k pages: this allows
* a 4k page size kernel to kexec a 64k page size kernel and * a 4k page size kernel to kexec a 64k page size kernel and
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2013 Linaro Ltd; <roy.franz@linaro.org> * Copyright (C) 2013 Linaro Ltd; <roy.franz@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
#include <linux/efi.h> #include <linux/efi.h>
#include <asm/efi.h> #include <asm/efi.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org> * Copyright (C) 2013, 2014 Linaro Ltd; <roy.franz@linaro.org>
* *
* This file implements the EFI boot stub for the arm64 kernel. * This file implements the EFI boot stub for the arm64 kernel.
* Adapted from ARM version by Mark Salter <msalter@redhat.com> * Adapted from ARM version by Mark Salter <msalter@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
/* /*
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Helper functions used by the EFI stub on multiple * Helper functions used by the EFI stub on multiple
* architectures. This should be #included by the EFI stub * architectures. This should be #included by the EFI stub
* implementation files. * implementation files.
* *
* Copyright 2011 Intel Corporation; author Matt Fleming * Copyright 2011 Intel Corporation; author Matt Fleming
*
* This file is part of the Linux kernel, and is made available
* under the terms of the GNU General Public License version 2.
*
*/ */
#include <linux/efi.h> #include <linux/efi.h>
...@@ -34,6 +31,7 @@ static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE; ...@@ -34,6 +31,7 @@ static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE;
static int __section(.data) __nokaslr; static int __section(.data) __nokaslr;
static int __section(.data) __quiet; static int __section(.data) __quiet;
static int __section(.data) __novamap;
int __pure nokaslr(void) int __pure nokaslr(void)
{ {
...@@ -43,6 +41,10 @@ int __pure is_quiet(void) ...@@ -43,6 +41,10 @@ int __pure is_quiet(void)
{ {
return __quiet; return __quiet;
} }
int __pure novamap(void)
{
return __novamap;
}
#define EFI_MMAP_NR_SLACK_SLOTS 8 #define EFI_MMAP_NR_SLACK_SLOTS 8
...@@ -482,6 +484,11 @@ efi_status_t efi_parse_options(char const *cmdline) ...@@ -482,6 +484,11 @@ efi_status_t efi_parse_options(char const *cmdline)
__chunk_size = -1UL; __chunk_size = -1UL;
} }
if (!strncmp(str, "novamap", 7)) {
str += strlen("novamap");
__novamap = 1;
}
/* Group words together, delimited by "," */ /* Group words together, delimited by "," */
while (*str && *str != ' ' && *str != ',') while (*str && *str != ' ' && *str != ',')
str++; str++;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
extern int __pure nokaslr(void); extern int __pure nokaslr(void);
extern int __pure is_quiet(void); extern int __pure is_quiet(void);
extern int __pure novamap(void);
#define pr_efi(sys_table, msg) do { \ #define pr_efi(sys_table, msg) do { \
if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \ 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,4 +65,15 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg);
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg);
/* Helper macros for the usual case of using simple C variables: */
#ifndef fdt_setprop_inplace_var
#define fdt_setprop_inplace_var(fdt, node_offset, name, var) \
fdt_setprop_inplace((fdt), (node_offset), (name), &(var), sizeof(var))
#endif
#ifndef fdt_setprop_var
#define fdt_setprop_var(fdt, node_offset, name, var) \
fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var))
#endif
#endif #endif
// SPDX-License-Identifier: GPL-2.0
/* /*
* FDT related Helper functions used by the EFI stub on multiple * FDT related Helper functions used by the EFI stub on multiple
* architectures. This should be #included by the EFI stub * architectures. This should be #included by the EFI stub
* implementation files. * implementation files.
* *
* Copyright 2013 Linaro Limited; author Roy Franz * Copyright 2013 Linaro Limited; author Roy Franz
*
* This file is part of the Linux kernel, and is made available
* under the terms of the GNU General Public License version 2.
*
*/ */
#include <linux/efi.h> #include <linux/efi.h>
...@@ -26,10 +23,8 @@ static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt) ...@@ -26,10 +23,8 @@ static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt)
offset = fdt_path_offset(fdt, "/"); offset = fdt_path_offset(fdt, "/");
/* Set the #address-cells and #size-cells values for an empty tree */ /* Set the #address-cells and #size-cells values for an empty tree */
fdt_setprop_u32(fdt, offset, "#address-cells", fdt_setprop_u32(fdt, offset, "#address-cells", EFI_DT_ADDR_CELLS_DEFAULT);
EFI_DT_ADDR_CELLS_DEFAULT); fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
} }
static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, static 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,7 +37,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
u32 fdt_val32; u32 fdt_val32;
u64 fdt_val64; u64 fdt_val64;
/* Do some checks on provided FDT, if it exists*/ /* Do some checks on provided FDT, if it exists: */
if (orig_fdt) { if (orig_fdt) {
if (fdt_check_header(orig_fdt)) { if (fdt_check_header(orig_fdt)) {
pr_efi_err(sys_table, "Device Tree header not valid!\n"); 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,7 +45,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
} }
/* /*
* We don't get the size of the FDT if we get if from a * We don't get the size of the FDT if we get if from a
* configuration table. * configuration table:
*/ */
if (orig_fdt_size && fdt_totalsize(orig_fdt) > orig_fdt_size) { if (orig_fdt_size && fdt_totalsize(orig_fdt) > orig_fdt_size) {
pr_efi_err(sys_table, "Truncated device tree! foo!\n"); 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,8 +59,8 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
status = fdt_create_empty_tree(fdt, new_fdt_size); status = fdt_create_empty_tree(fdt, new_fdt_size);
if (status == 0) { if (status == 0) {
/* /*
* Any failure from the following function is non * Any failure from the following function is
* critical * non-critical:
*/ */
fdt_update_cell_size(sys_table, fdt); fdt_update_cell_size(sys_table, fdt);
} }
...@@ -86,12 +81,13 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ...@@ -86,12 +81,13 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
if (node < 0) { if (node < 0) {
node = fdt_add_subnode(fdt, 0, "chosen"); node = fdt_add_subnode(fdt, 0, "chosen");
if (node < 0) { if (node < 0) {
status = node; /* node is error code when negative */ /* 'node' is an error code when negative: */
status = node;
goto fdt_set_fail; goto fdt_set_fail;
} }
} }
if ((cmdline_ptr != NULL) && (strlen(cmdline_ptr) > 0)) { if (cmdline_ptr != NULL && strlen(cmdline_ptr) > 0) {
status = fdt_setprop(fdt, node, "bootargs", cmdline_ptr, status = fdt_setprop(fdt, node, "bootargs", cmdline_ptr,
strlen(cmdline_ptr) + 1); strlen(cmdline_ptr) + 1);
if (status) if (status)
...@@ -103,13 +99,12 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ...@@ -103,13 +99,12 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
u64 initrd_image_end; u64 initrd_image_end;
u64 initrd_image_start = cpu_to_fdt64(initrd_addr); u64 initrd_image_start = cpu_to_fdt64(initrd_addr);
status = fdt_setprop(fdt, node, "linux,initrd-start", status = fdt_setprop_var(fdt, node, "linux,initrd-start", initrd_image_start);
&initrd_image_start, sizeof(u64));
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
initrd_image_end = cpu_to_fdt64(initrd_addr + initrd_size); initrd_image_end = cpu_to_fdt64(initrd_addr + initrd_size);
status = fdt_setprop(fdt, node, "linux,initrd-end", status = fdt_setprop_var(fdt, node, "linux,initrd-end", initrd_image_end);
&initrd_image_end, sizeof(u64));
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
} }
...@@ -117,30 +112,28 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ...@@ -117,30 +112,28 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
/* Add FDT entries for EFI runtime services in chosen node. */ /* Add FDT entries for EFI runtime services in chosen node. */
node = fdt_subnode_offset(fdt, 0, "chosen"); node = fdt_subnode_offset(fdt, 0, "chosen");
fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table); fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table);
status = fdt_setprop(fdt, node, "linux,uefi-system-table",
&fdt_val64, sizeof(fdt_val64)); status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64);
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
fdt_val64 = U64_MAX; /* placeholder */ fdt_val64 = U64_MAX; /* placeholder */
status = fdt_setprop(fdt, node, "linux,uefi-mmap-start",
&fdt_val64, sizeof(fdt_val64)); status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-start", fdt_val64);
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
fdt_val32 = U32_MAX; /* placeholder */ fdt_val32 = U32_MAX; /* placeholder */
status = fdt_setprop(fdt, node, "linux,uefi-mmap-size",
&fdt_val32, sizeof(fdt_val32)); status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-size", fdt_val32);
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-size", status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-desc-size", fdt_val32);
&fdt_val32, sizeof(fdt_val32));
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
status = fdt_setprop(fdt, node, "linux,uefi-mmap-desc-ver", status = fdt_setprop_var(fdt, node, "linux,uefi-mmap-desc-ver", fdt_val32);
&fdt_val32, sizeof(fdt_val32));
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
...@@ -150,8 +143,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, ...@@ -150,8 +143,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64), efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64),
(u8 *)&fdt_val64); (u8 *)&fdt_val64);
if (efi_status == EFI_SUCCESS) { if (efi_status == EFI_SUCCESS) {
status = fdt_setprop(fdt, node, "kaslr-seed", status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64);
&fdt_val64, sizeof(fdt_val64));
if (status) if (status)
goto fdt_set_fail; goto fdt_set_fail;
} else if (efi_status != EFI_NOT_FOUND) { } 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,7 +151,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
} }
} }
/* shrink the FDT back to its minimum size */ /* Shrink the FDT back to its minimum size: */
fdt_pack(fdt); fdt_pack(fdt);
return EFI_SUCCESS; return EFI_SUCCESS;
...@@ -182,26 +174,26 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map) ...@@ -182,26 +174,26 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map)
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
fdt_val64 = cpu_to_fdt64((unsigned long)*map->map); fdt_val64 = cpu_to_fdt64((unsigned long)*map->map);
err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-start",
&fdt_val64, sizeof(fdt_val64)); err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-start", fdt_val64);
if (err) if (err)
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
fdt_val32 = cpu_to_fdt32(*map->map_size); fdt_val32 = cpu_to_fdt32(*map->map_size);
err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-size",
&fdt_val32, sizeof(fdt_val32)); err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-size", fdt_val32);
if (err) if (err)
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
fdt_val32 = cpu_to_fdt32(*map->desc_size); fdt_val32 = cpu_to_fdt32(*map->desc_size);
err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-size",
&fdt_val32, sizeof(fdt_val32)); err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-desc-size", fdt_val32);
if (err) if (err)
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
fdt_val32 = cpu_to_fdt32(*map->desc_ver); fdt_val32 = cpu_to_fdt32(*map->desc_ver);
err = fdt_setprop_inplace(fdt, node, "linux,uefi-mmap-desc-ver",
&fdt_val32, sizeof(fdt_val32)); err = fdt_setprop_inplace_var(fdt, node, "linux,uefi-mmap-desc-ver", fdt_val32);
if (err) if (err)
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
...@@ -209,13 +201,13 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map) ...@@ -209,13 +201,13 @@ static efi_status_t update_fdt_memmap(void *fdt, struct efi_boot_memmap *map)
} }
#ifndef EFI_FDT_ALIGN #ifndef EFI_FDT_ALIGN
#define EFI_FDT_ALIGN EFI_PAGE_SIZE # define EFI_FDT_ALIGN EFI_PAGE_SIZE
#endif #endif
struct exit_boot_struct { struct exit_boot_struct {
efi_memory_desc_t *runtime_map; efi_memory_desc_t *runtime_map;
int *runtime_entry_count; int *runtime_entry_count;
void *new_fdt_addr; void *new_fdt_addr;
}; };
static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, static 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,7 +227,7 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg,
} }
#ifndef MAX_FDT_SIZE #ifndef MAX_FDT_SIZE
#define MAX_FDT_SIZE SZ_2M # define MAX_FDT_SIZE SZ_2M
#endif #endif
/* /*
...@@ -266,16 +258,16 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, ...@@ -266,16 +258,16 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
unsigned long mmap_key; unsigned long mmap_key;
efi_memory_desc_t *memory_map, *runtime_map; efi_memory_desc_t *memory_map, *runtime_map;
efi_status_t status; efi_status_t status;
int runtime_entry_count = 0; int runtime_entry_count;
struct efi_boot_memmap map; struct efi_boot_memmap map;
struct exit_boot_struct priv; struct exit_boot_struct priv;
map.map = &runtime_map; map.map = &runtime_map;
map.map_size = &map_size; map.map_size = &map_size;
map.desc_size = &desc_size; map.desc_size = &desc_size;
map.desc_ver = &desc_ver; map.desc_ver = &desc_ver;
map.key_ptr = &mmap_key; map.key_ptr = &mmap_key;
map.buff_size = &buff_size; map.buff_size = &buff_size;
/* /*
* Get a copy of the current memory map that we will use to prepare * 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,15 +281,13 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
return status; return status;
} }
pr_efi(sys_table, pr_efi(sys_table, "Exiting boot services and installing virtual address map...\n");
"Exiting boot services and installing virtual address map...\n");
map.map = &memory_map; map.map = &memory_map;
status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN, status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN,
new_fdt_addr, max_addr); new_fdt_addr, max_addr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err(sys_table, pr_efi_err(sys_table, "Unable to allocate memory for new device tree.\n");
"Unable to allocate memory for new device tree.\n");
goto fail; goto fail;
} }
...@@ -318,15 +308,19 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, ...@@ -318,15 +308,19 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
goto fail_free_new_fdt; goto fail_free_new_fdt;
} }
priv.runtime_map = runtime_map; runtime_entry_count = 0;
priv.runtime_entry_count = &runtime_entry_count; priv.runtime_map = runtime_map;
priv.new_fdt_addr = (void *)*new_fdt_addr; priv.runtime_entry_count = &runtime_entry_count;
status = efi_exit_boot_services(sys_table, handle, &map, &priv, priv.new_fdt_addr = (void *)*new_fdt_addr;
exit_boot_func);
status = efi_exit_boot_services(sys_table, handle, &map, &priv, exit_boot_func);
if (status == EFI_SUCCESS) { if (status == EFI_SUCCESS) {
efi_set_virtual_address_map_t *svam; efi_set_virtual_address_map_t *svam;
if (novamap())
return EFI_SUCCESS;
/* Install the new virtual address map */ /* Install the new virtual address map */
svam = sys_table->runtime->set_virtual_address_map; svam = sys_table->runtime->set_virtual_address_map;
status = svam(runtime_entry_count * desc_size, desc_size, status = svam(runtime_entry_count * desc_size, desc_size,
...@@ -363,6 +357,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, ...@@ -363,6 +357,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
fail: fail:
sys_table->boottime->free_pool(runtime_map); sys_table->boottime->free_pool(runtime_map);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
......
// SPDX-License-Identifier: GPL-2.0
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
* *
* Copyright 2011 Intel Corporation; author Matt Fleming * Copyright 2011 Intel Corporation; author Matt Fleming
* *
* This file is part of the Linux kernel, and is made available under
* the terms of the GNU General Public License version 2.
*
* ----------------------------------------------------------------------- */ * ----------------------------------------------------------------------- */
#include <linux/efi.h> #include <linux/efi.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org> * Copyright (C) 2016 Linaro Ltd; <ard.biesheuvel@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
*/ */
#include <linux/efi.h> #include <linux/efi.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Secure boot handling. * Secure boot handling.
* *
...@@ -5,9 +6,6 @@ ...@@ -5,9 +6,6 @@
* Roy Franz <roy.franz@linaro.org * Roy Franz <roy.franz@linaro.org
* Copyright (C) 2013 Red Hat, Inc. * Copyright (C) 2013 Red Hat, Inc.
* Mark Salter <msalter@redhat.com> * Mark Salter <msalter@redhat.com>
*
* This file is part of the Linux kernel, and is made available under the
* terms of the GNU General Public License version 2.
*/ */
#include <linux/efi.h> #include <linux/efi.h>
#include <asm/efi.h> #include <asm/efi.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* TPM handling. * TPM handling.
* *
...@@ -5,9 +6,6 @@ ...@@ -5,9 +6,6 @@
* Copyright (C) 2017 Google, Inc. * Copyright (C) 2017 Google, Inc.
* Matthew Garrett <mjg59@google.com> * Matthew Garrett <mjg59@google.com>
* Thiebaud Weksteen <tweek@google.com> * Thiebaud Weksteen <tweek@google.com>
*
* This file is part of the Linux kernel, and is made available under the
* terms of the GNU General Public License version 2.
*/ */
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/tpm_eventlog.h> #include <linux/tpm_eventlog.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org> * Copyright (C) 2016 Linaro Ltd. <ard.biesheuvel@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) "efi: memattr: " fmt #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,7 +91,7 @@ static bool entry_is_valid(const efi_memory_desc_t *in, efi_memory_desc_t *out)
if (!(md->attribute & EFI_MEMORY_RUNTIME)) if (!(md->attribute & EFI_MEMORY_RUNTIME))
continue; continue;
if (md->virt_addr == 0) { if (md->virt_addr == 0 && md->phys_addr != 0) {
/* no virtual mapping has been installed by the stub */ /* no virtual mapping has been installed by the stub */
break; break;
} }
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* linux/drivers/efi/runtime-map.c * linux/drivers/efi/runtime-map.c
* Copyright (C) 2013 Red Hat, Inc., Dave Young <dyoung@redhat.com> * Copyright (C) 2013 Red Hat, Inc., Dave Young <dyoung@redhat.com>
*
* This file is released under the GPLv2.
*/ */
#include <linux/string.h> #include <linux/string.h>
......
...@@ -85,7 +85,7 @@ struct efi_runtime_work efi_rts_work; ...@@ -85,7 +85,7 @@ struct efi_runtime_work efi_rts_work;
pr_err("Failed to queue work to efi_rts_wq.\n"); \ pr_err("Failed to queue work to efi_rts_wq.\n"); \
\ \
exit: \ exit: \
efi_rts_work.efi_rts_id = NONE; \ efi_rts_work.efi_rts_id = EFI_NONE; \
efi_rts_work.status; \ efi_rts_work.status; \
}) })
...@@ -175,50 +175,50 @@ static void efi_call_rts(struct work_struct *work) ...@@ -175,50 +175,50 @@ static void efi_call_rts(struct work_struct *work)
arg5 = efi_rts_work.arg5; arg5 = efi_rts_work.arg5;
switch (efi_rts_work.efi_rts_id) { switch (efi_rts_work.efi_rts_id) {
case GET_TIME: case EFI_GET_TIME:
status = efi_call_virt(get_time, (efi_time_t *)arg1, status = efi_call_virt(get_time, (efi_time_t *)arg1,
(efi_time_cap_t *)arg2); (efi_time_cap_t *)arg2);
break; break;
case SET_TIME: case EFI_SET_TIME:
status = efi_call_virt(set_time, (efi_time_t *)arg1); status = efi_call_virt(set_time, (efi_time_t *)arg1);
break; break;
case GET_WAKEUP_TIME: case EFI_GET_WAKEUP_TIME:
status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1, status = efi_call_virt(get_wakeup_time, (efi_bool_t *)arg1,
(efi_bool_t *)arg2, (efi_time_t *)arg3); (efi_bool_t *)arg2, (efi_time_t *)arg3);
break; break;
case SET_WAKEUP_TIME: case EFI_SET_WAKEUP_TIME:
status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1, status = efi_call_virt(set_wakeup_time, *(efi_bool_t *)arg1,
(efi_time_t *)arg2); (efi_time_t *)arg2);
break; break;
case GET_VARIABLE: case EFI_GET_VARIABLE:
status = efi_call_virt(get_variable, (efi_char16_t *)arg1, status = efi_call_virt(get_variable, (efi_char16_t *)arg1,
(efi_guid_t *)arg2, (u32 *)arg3, (efi_guid_t *)arg2, (u32 *)arg3,
(unsigned long *)arg4, (void *)arg5); (unsigned long *)arg4, (void *)arg5);
break; break;
case GET_NEXT_VARIABLE: case EFI_GET_NEXT_VARIABLE:
status = efi_call_virt(get_next_variable, (unsigned long *)arg1, status = efi_call_virt(get_next_variable, (unsigned long *)arg1,
(efi_char16_t *)arg2, (efi_char16_t *)arg2,
(efi_guid_t *)arg3); (efi_guid_t *)arg3);
break; break;
case SET_VARIABLE: case EFI_SET_VARIABLE:
status = efi_call_virt(set_variable, (efi_char16_t *)arg1, status = efi_call_virt(set_variable, (efi_char16_t *)arg1,
(efi_guid_t *)arg2, *(u32 *)arg3, (efi_guid_t *)arg2, *(u32 *)arg3,
*(unsigned long *)arg4, (void *)arg5); *(unsigned long *)arg4, (void *)arg5);
break; break;
case QUERY_VARIABLE_INFO: case EFI_QUERY_VARIABLE_INFO:
status = efi_call_virt(query_variable_info, *(u32 *)arg1, status = efi_call_virt(query_variable_info, *(u32 *)arg1,
(u64 *)arg2, (u64 *)arg3, (u64 *)arg4); (u64 *)arg2, (u64 *)arg3, (u64 *)arg4);
break; break;
case GET_NEXT_HIGH_MONO_COUNT: case EFI_GET_NEXT_HIGH_MONO_COUNT:
status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1); status = efi_call_virt(get_next_high_mono_count, (u32 *)arg1);
break; break;
case UPDATE_CAPSULE: case EFI_UPDATE_CAPSULE:
status = efi_call_virt(update_capsule, status = efi_call_virt(update_capsule,
(efi_capsule_header_t **)arg1, (efi_capsule_header_t **)arg1,
*(unsigned long *)arg2, *(unsigned long *)arg2,
*(unsigned long *)arg3); *(unsigned long *)arg3);
break; break;
case QUERY_CAPSULE_CAPS: case EFI_QUERY_CAPSULE_CAPS:
status = efi_call_virt(query_capsule_caps, status = efi_call_virt(query_capsule_caps,
(efi_capsule_header_t **)arg1, (efi_capsule_header_t **)arg1,
*(unsigned long *)arg2, (u64 *)arg3, *(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,7 +242,7 @@ static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(GET_TIME, tm, tc, NULL, NULL, NULL); status = efi_queue_work(EFI_GET_TIME, tm, tc, NULL, NULL, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
} }
...@@ -253,7 +253,7 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm) ...@@ -253,7 +253,7 @@ static efi_status_t virt_efi_set_time(efi_time_t *tm)
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(SET_TIME, tm, NULL, NULL, NULL, NULL); status = efi_queue_work(EFI_SET_TIME, tm, NULL, NULL, NULL, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
} }
...@@ -266,7 +266,7 @@ static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled, ...@@ -266,7 +266,7 @@ static efi_status_t virt_efi_get_wakeup_time(efi_bool_t *enabled,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(GET_WAKEUP_TIME, enabled, pending, tm, NULL, status = efi_queue_work(EFI_GET_WAKEUP_TIME, enabled, pending, tm, NULL,
NULL); NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -278,7 +278,7 @@ static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm) ...@@ -278,7 +278,7 @@ static efi_status_t virt_efi_set_wakeup_time(efi_bool_t enabled, efi_time_t *tm)
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(SET_WAKEUP_TIME, &enabled, tm, NULL, NULL, status = efi_queue_work(EFI_SET_WAKEUP_TIME, &enabled, tm, NULL, NULL,
NULL); NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -294,7 +294,7 @@ static efi_status_t virt_efi_get_variable(efi_char16_t *name, ...@@ -294,7 +294,7 @@ static efi_status_t virt_efi_get_variable(efi_char16_t *name,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(GET_VARIABLE, name, vendor, attr, data_size, status = efi_queue_work(EFI_GET_VARIABLE, name, vendor, attr, data_size,
data); data);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -308,7 +308,7 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size, ...@@ -308,7 +308,7 @@ static efi_status_t virt_efi_get_next_variable(unsigned long *name_size,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(GET_NEXT_VARIABLE, name_size, name, vendor, status = efi_queue_work(EFI_GET_NEXT_VARIABLE, name_size, name, vendor,
NULL, NULL); NULL, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -324,7 +324,7 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name, ...@@ -324,7 +324,7 @@ static efi_status_t virt_efi_set_variable(efi_char16_t *name,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(SET_VARIABLE, name, vendor, &attr, &data_size, status = efi_queue_work(EFI_SET_VARIABLE, name, vendor, &attr, &data_size,
data); data);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -359,7 +359,7 @@ static efi_status_t virt_efi_query_variable_info(u32 attr, ...@@ -359,7 +359,7 @@ static efi_status_t virt_efi_query_variable_info(u32 attr,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(QUERY_VARIABLE_INFO, &attr, storage_space, status = efi_queue_work(EFI_QUERY_VARIABLE_INFO, &attr, storage_space,
remaining_space, max_variable_size, NULL); remaining_space, max_variable_size, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -391,7 +391,7 @@ static efi_status_t virt_efi_get_next_high_mono_count(u32 *count) ...@@ -391,7 +391,7 @@ static efi_status_t virt_efi_get_next_high_mono_count(u32 *count)
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL, status = efi_queue_work(EFI_GET_NEXT_HIGH_MONO_COUNT, count, NULL, NULL,
NULL, NULL); NULL, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -407,7 +407,7 @@ static void virt_efi_reset_system(int reset_type, ...@@ -407,7 +407,7 @@ static void virt_efi_reset_system(int reset_type,
"could not get exclusive access to the firmware\n"); "could not get exclusive access to the firmware\n");
return; return;
} }
efi_rts_work.efi_rts_id = RESET_SYSTEM; efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
__efi_call_virt(reset_system, reset_type, status, data_size, data); __efi_call_virt(reset_system, reset_type, status, data_size, data);
up(&efi_runtime_lock); up(&efi_runtime_lock);
} }
...@@ -423,7 +423,7 @@ static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules, ...@@ -423,7 +423,7 @@ static efi_status_t virt_efi_update_capsule(efi_capsule_header_t **capsules,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(UPDATE_CAPSULE, capsules, &count, &sg_list, status = efi_queue_work(EFI_UPDATE_CAPSULE, capsules, &count, &sg_list,
NULL, NULL); NULL, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
...@@ -441,7 +441,7 @@ static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules, ...@@ -441,7 +441,7 @@ static efi_status_t virt_efi_query_capsule_caps(efi_capsule_header_t **capsules,
if (down_interruptible(&efi_runtime_lock)) if (down_interruptible(&efi_runtime_lock))
return EFI_ABORTED; return EFI_ABORTED;
status = efi_queue_work(QUERY_CAPSULE_CAPS, capsules, &count, status = efi_queue_work(EFI_QUERY_CAPSULE_CAPS, capsules, &count,
max_size, reset_type, NULL); max_size, reset_type, NULL);
up(&efi_runtime_lock); up(&efi_runtime_lock);
return status; return status;
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* EFI Test Driver for Runtime Services * EFI Test Driver for Runtime Services
* *
......
/* SPDX-License-Identifier: GPL-2.0 */ /* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* EFI Test driver Header * EFI Test driver Header
* *
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2017 Google, Inc. * Copyright (C) 2017 Google, Inc.
* Thiebaud Weksteen <tweek@google.com> * Thiebaud Weksteen <tweek@google.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/efi.h> #include <linux/efi.h>
......
// SPDX-License-Identifier: GPL-2.0+
/* /*
* Originally from efivars.c * Originally from efivars.c
* *
* Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com> * Copyright (C) 2001,2003,2004 Dell <Matt_Domsch@dell.com>
* Copyright (C) 2004 Intel Corporation <matthew.e.tolentino@intel.com> * Copyright (C) 2004 Intel Corporation <matthew.e.tolentino@intel.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <linux/capability.h> #include <linux/capability.h>
......
...@@ -48,7 +48,20 @@ typedef u16 efi_char16_t; /* UNICODE character */ ...@@ -48,7 +48,20 @@ typedef u16 efi_char16_t; /* UNICODE character */
typedef u64 efi_physical_addr_t; typedef u64 efi_physical_addr_t;
typedef void *efi_handle_t; typedef void *efi_handle_t;
typedef guid_t efi_guid_t; /*
* The UEFI spec and EDK2 reference implementation both define EFI_GUID as
* struct { u32 a; u16; b; u16 c; u8 d[8]; }; and so the implied alignment
* is 32 bits not 8 bits like our guid_t. In some cases (i.e., on 32-bit ARM),
* this means that firmware services invoked by the kernel may assume that
* efi_guid_t* arguments are 32-bit aligned, and use memory accessors that
* do not tolerate misalignment. So let's set the minimum alignment to 32 bits.
*
* Note that the UEFI spec as well as some comments in the EDK2 code base
* suggest that EFI_GUID should be 64-bit aligned, but this appears to be
* a mistake, given that no code seems to exist that actually enforces that
* or relies on it.
*/
typedef guid_t efi_guid_t __aligned(__alignof__(u32));
#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ #define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) 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,19 +1712,19 @@ extern int efi_tpm_eventlog_init(void);
* fault happened while executing an efi runtime service. * fault happened while executing an efi runtime service.
*/ */
enum efi_rts_ids { enum efi_rts_ids {
NONE, EFI_NONE,
GET_TIME, EFI_GET_TIME,
SET_TIME, EFI_SET_TIME,
GET_WAKEUP_TIME, EFI_GET_WAKEUP_TIME,
SET_WAKEUP_TIME, EFI_SET_WAKEUP_TIME,
GET_VARIABLE, EFI_GET_VARIABLE,
GET_NEXT_VARIABLE, EFI_GET_NEXT_VARIABLE,
SET_VARIABLE, EFI_SET_VARIABLE,
QUERY_VARIABLE_INFO, EFI_QUERY_VARIABLE_INFO,
GET_NEXT_HIGH_MONO_COUNT, EFI_GET_NEXT_HIGH_MONO_COUNT,
RESET_SYSTEM, EFI_RESET_SYSTEM,
UPDATE_CAPSULE, EFI_UPDATE_CAPSULE,
QUERY_CAPSULE_CAPS, EFI_QUERY_CAPSULE_CAPS,
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment