From 6b31a2fa1e8f7bc6c2a474b4a12dad7a145cf83d Mon Sep 17 00:00:00 2001 From: Mark Rutland Date: Thu, 8 Mar 2018 08:00:09 +0000 Subject: efi/arm*: Only register page tables when they exist Currently the arm/arm64 runtime code registers the runtime servies pagetables with ptdump regardless of whether runtime services page tables have been created. As efi_mm.pgd is NULL in these cases, attempting to dump the efi page tables results in a NULL pointer dereference in the ptdump code: /sys/kernel/debug# cat efi_page_tables [ 479.522600] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 479.522715] Mem abort info: [ 479.522764] ESR = 0x96000006 [ 479.522850] Exception class = DABT (current EL), IL = 32 bits [ 479.522899] SET = 0, FnV = 0 [ 479.522937] EA = 0, S1PTW = 0 [ 479.528200] Data abort info: [ 479.528230] ISV = 0, ISS = 0x00000006 [ 479.528317] CM = 0, WnR = 0 [ 479.528317] user pgtable: 4k pages, 48-bit VAs, pgd = 0000000064ab0cb0 [ 479.528449] [0000000000000000] *pgd=00000000fbbe4003, *pud=00000000fb66e003, *pmd=0000000000000000 [ 479.528600] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 479.528664] Modules linked in: [ 479.528699] CPU: 0 PID: 2457 Comm: cat Not tainted 4.15.0-rc3-00065-g2ad2ee7ecb5c-dirty #7 [ 479.528799] Hardware name: FVP Base (DT) [ 479.528899] pstate: 00400009 (nzcv daif +PAN -UAO) [ 479.528941] pc : walk_pgd.isra.1+0x20/0x1d0 [ 479.529011] lr : ptdump_walk_pgd+0x30/0x50 [ 479.529105] sp : ffff00000bf4bc20 [ 479.529185] x29: ffff00000bf4bc20 x28: 0000ffff9d22e000 [ 479.529271] x27: 0000000000020000 x26: ffff80007b4c63c0 [ 479.529358] x25: 00000000014000c0 x24: ffff80007c098900 [ 479.529445] x23: ffff00000bf4beb8 x22: 0000000000000000 [ 479.529532] x21: ffff00000bf4bd70 x20: 0000000000000001 [ 479.529618] x19: ffff00000bf4bcb0 x18: 0000000000000000 [ 479.529760] x17: 000000000041a1c8 x16: ffff0000082139d8 [ 479.529800] x15: 0000ffff9d3c6030 x14: 0000ffff9d2527f4 [ 479.529924] x13: 00000000000003f3 x12: 0000000000000038 [ 479.530000] x11: 0000000000000003 x10: 0101010101010101 [ 479.530099] x9 : 0000000017e94050 x8 : 000000000000003f [ 479.530226] x7 : 0000000000000000 x6 : 0000000000000000 [ 479.530313] x5 : 0000000000000001 x4 : 0000000000000000 [ 479.530416] x3 : ffff000009069fd8 x2 : 0000000000000000 [ 479.530500] x1 : 0000000000000000 x0 : 0000000000000000 [ 479.530599] Process cat (pid: 2457, stack limit = 0x000000005d1b0e6f) [ 479.530660] Call trace: [ 479.530746] walk_pgd.isra.1+0x20/0x1d0 [ 479.530833] ptdump_walk_pgd+0x30/0x50 [ 479.530907] ptdump_show+0x10/0x20 [ 479.530920] seq_read+0xc8/0x470 [ 479.531023] full_proxy_read+0x60/0x90 [ 479.531100] __vfs_read+0x18/0x100 [ 479.531180] vfs_read+0x88/0x160 [ 479.531267] SyS_read+0x48/0xb0 [ 479.531299] el0_svc_naked+0x20/0x24 [ 479.531400] Code: 91400420 f90033a0 a90707a2 f9403fa0 (f9400000) [ 479.531499] ---[ end trace bfe8e28d8acb2b67 ]--- Segmentation fault Let's avoid this problem by only registering the tables after their successful creation, which is also less confusing when EFI runtime services are not in use. Reported-by: Will Deacon Signed-off-by: Mark Rutland Signed-off-by: Ard Biesheuvel Acked-by: Will Deacon Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/arm-runtime.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 1cc41c3d6315..86a1ad17a32e 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -54,6 +54,9 @@ static struct ptdump_info efi_ptdump_info = { static int __init ptdump_init(void) { + if (!efi_enabled(EFI_RUNTIME_SERVICES)) + return 0; + return ptdump_debugfs_register(&efi_ptdump_info, "efi_page_tables"); } device_initcall(ptdump_init); -- cgit v1.2.3 From 6e98503dba64e721ba839e75dca036266ec0140f Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 8 Mar 2018 08:00:10 +0000 Subject: efi/apple-properties: Remove redundant attribute initialization from unmarshal_key_value_pairs() There is no need to artificially supply a property length and fake data if property has type of boolean. Remove redundant piece of data and code. Reviewed-and-tested-by: Lukas Wunner Signed-off-by: Andy Shevchenko Signed-off-by: Ard Biesheuvel Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-3-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/apple-properties.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c index 9f6bcf173b0e..b9602e0d7b50 100644 --- a/drivers/firmware/efi/apple-properties.c +++ b/drivers/firmware/efi/apple-properties.c @@ -52,8 +52,6 @@ struct properties_header { struct dev_header dev_header[0]; }; -static u8 one __initdata = 1; - static void __init unmarshal_key_value_pairs(struct dev_header *dev_header, struct device *dev, void *ptr, struct property_entry entry[]) @@ -95,14 +93,9 @@ static void __init unmarshal_key_value_pairs(struct dev_header *dev_header, key_len - sizeof(key_len)); entry[i].name = key; - entry[i].is_array = true; entry[i].length = val_len - sizeof(val_len); + entry[i].is_array = !!entry[i].length; entry[i].pointer.raw_data = ptr + key_len + sizeof(val_len); - if (!entry[i].length) { - /* driver core doesn't accept empty properties */ - entry[i].length = 1; - entry[i].pointer.raw_data = &one; - } if (dump_properties) { dev_info(dev, "property: %s\n", entry[i].name); -- cgit v1.2.3 From 1832e64162ffbbbdf7230401298550f2b624351b Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 8 Mar 2018 08:00:11 +0000 Subject: efi/arm*: Stop printing addresses of virtual mappings With the recent %p -> %px changes, we now get something like this in the kernel boot log on ARM/arm64 EFI systems: Remapping and enabling EFI services. EFI remap 0x00000087fb830000 => (ptrval) EFI remap 0x00000087fbdb0000 => (ptrval) EFI remap 0x00000087fffc0000 => (ptrval) The physical addresses of the UEFI runtime regions will also be printed when booting with the efi=debug command line option, and the virtual addresses can be inspected via /sys/kernel/debug/efi_page_tables (if enabled). So let's just remove the lines above. Signed-off-by: Ard Biesheuvel Acked-by: Leif Lindholm Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-4-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/arm-runtime.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 86a1ad17a32e..13561aeb7396 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -83,10 +83,7 @@ static bool __init efi_virtmap_init(void) return false; ret = efi_create_mapping(&efi_mm, md); - if (!ret) { - pr_info(" EFI remap %pa => %p\n", - &phys, (void *)(unsigned long)md->virt_addr); - } else { + if (ret) { pr_warn(" EFI remap %pa: failed to create mapping (%d)\n", &phys, ret); return false; -- cgit v1.2.3 From 5b4e4c3aa220d07d166d3f21f158bc9c69e3c044 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 8 Mar 2018 08:00:18 +0000 Subject: efi: Reorder pr_notice() with add_device_randomness() call Currently, when we receive a random seed from the EFI stub, we call add_device_randomness() to incorporate it into the entropy pool, and issue a pr_notice() saying we are about to do that, e.g., [ 0.000000] efi: RNG=0x87ff92cf18 [ 0.000000] random: fast init done [ 0.000000] efi: seeding entropy pool Let's reorder those calls to make the output look less confusing: [ 0.000000] efi: seeding entropy pool [ 0.000000] efi: RNG=0x87ff92cf18 [ 0.000000] random: fast init done Signed-off-by: Ard Biesheuvel Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-11-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index cd42f66a7c85..92b9e79e5da9 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -542,9 +542,9 @@ int __init efi_config_parse_tables(void *config_tables, int count, int sz, seed = early_memremap(efi.rng_seed, sizeof(*seed) + size); if (seed != NULL) { + pr_notice("seeding entropy pool\n"); add_device_randomness(seed->bits, seed->size); early_memunmap(seed, sizeof(*seed) + size); - pr_notice("seeding entropy pool\n"); } else { pr_err("Could not map UEFI random seed!\n"); } -- cgit v1.2.3 From 44612d7e0c379001460b37a29721128715bdcb02 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 8 Mar 2018 08:00:19 +0000 Subject: efi/apple-properties: Use memremap() instead of ioremap() The memory we are accessing through virtual address has no IO side effects. Moreover, for IO memory we have to use special accessors, which we don't use. Due to above, convert the driver to use memremap() instead of ioremap(). Tested-by: Lukas Wunner Signed-off-by: Andy Shevchenko Signed-off-by: Ard Biesheuvel Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180308080020.22828-12-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/apple-properties.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/apple-properties.c b/drivers/firmware/efi/apple-properties.c index b9602e0d7b50..adaa9a3714b9 100644 --- a/drivers/firmware/efi/apple-properties.c +++ b/drivers/firmware/efi/apple-properties.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -189,7 +190,7 @@ static int __init map_properties(void) pa_data = boot_params.hdr.setup_data; while (pa_data) { - data = ioremap(pa_data, sizeof(*data)); + data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); if (!data) { pr_err("cannot map setup_data header\n"); return -ENOMEM; @@ -197,14 +198,14 @@ static int __init map_properties(void) if (data->type != SETUP_APPLE_PROPERTIES) { pa_data = data->next; - iounmap(data); + memunmap(data); continue; } data_len = data->len; - iounmap(data); + memunmap(data); - data = ioremap(pa_data, sizeof(*data) + data_len); + data = memremap(pa_data, sizeof(*data) + data_len, MEMREMAP_WB); if (!data) { pr_err("cannot map setup_data payload\n"); return -ENOMEM; @@ -229,7 +230,7 @@ static int __init map_properties(void) * to avoid breaking the chain of ->next pointers. */ data->len = 0; - iounmap(data); + memunmap(data); free_bootmem_late(pa_data + sizeof(*data), data_len); return ret; -- cgit v1.2.3 From 7e904a91bf6049071ef9d605a52f863ae774081d Mon Sep 17 00:00:00 2001 From: Sai Praneeth Date: Mon, 12 Mar 2018 08:44:56 +0000 Subject: efi: Use efi_mm in x86 as well as ARM Presently, only ARM uses mm_struct to manage EFI page tables and EFI runtime region mappings. As this is the preferred approach, let's make this data structure common across architectures. Specially, for x86, using this data structure improves code maintainability and readability. Tested-by: Bhupesh Sharma [ardb: don't #include the world to get a declaration of struct mm_struct] Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Ard Biesheuvel Reviewed-by: Matt Fleming Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Lee, Chun-Yi Cc: Linus Torvalds Cc: Michael S. Tsirkin Cc: Peter Zijlstra Cc: Ravi Shankar Cc: Ricardo Neri Cc: Thomas Gleixner Cc: Tony Luck Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180312084500.10764-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- arch/x86/include/asm/efi.h | 1 + arch/x86/platform/efi/efi_64.c | 3 +++ drivers/firmware/efi/arm-runtime.c | 9 --------- drivers/firmware/efi/efi.c | 9 +++++++++ include/linux/efi.h | 2 ++ 5 files changed, 15 insertions(+), 9 deletions(-) (limited to 'drivers/firmware') diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index a399c1ebf6f0..c62443fa7d0a 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -7,6 +7,7 @@ #include #include #include +#include /* * We map the EFI regions needed for runtime services non-contiguously, diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index 780460aa5ea5..29425b6c98a7 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -233,6 +233,9 @@ int __init efi_alloc_page_tables(void) return -ENOMEM; } + mm_init_cpumask(&efi_mm); + init_new_context(NULL, &efi_mm); + return 0; } diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 13561aeb7396..5889cbea60b8 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c @@ -31,15 +31,6 @@ extern u64 efi_system_table; -static struct mm_struct efi_mm = { - .mm_rb = RB_ROOT, - .mm_users = ATOMIC_INIT(2), - .mm_count = ATOMIC_INIT(1), - .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem), - .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), - .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), -}; - #ifdef CONFIG_ARM64_PTDUMP_DEBUGFS #include diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 92b9e79e5da9..232f4915223b 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -75,6 +75,15 @@ static unsigned long *efi_tables[] = { &efi.mem_attr_table, }; +struct mm_struct efi_mm = { + .mm_rb = RB_ROOT, + .mm_users = ATOMIC_INIT(2), + .mm_count = ATOMIC_INIT(1), + .mmap_sem = __RWSEM_INITIALIZER(efi_mm.mmap_sem), + .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), + .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), +}; + static bool disable_runtime; static int __init setup_noefi(char *arg) { diff --git a/include/linux/efi.h b/include/linux/efi.h index f5083aa72eae..f1b7d68ac460 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -966,6 +966,8 @@ extern struct efi { unsigned long flags; } efi; +extern struct mm_struct efi_mm; + static inline int efi_guidcmp (efi_guid_t left, efi_guid_t right) { -- cgit v1.2.3 From 136d5d57e35cc6985c57d23d0c823133e3508bed Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Mon, 12 Mar 2018 08:44:59 +0000 Subject: efi/esrt: Fix handling of early ESRT table mapping As reported by Tyler, efi_esrt_init() will return without releasing the ESRT table header mapping if it encounters a table with an unexpected version. Replacing the 'return' with 'goto err_memunmap' would fix this particular occurrence, but, as it turns out, the code is rather peculiar to begin with: - it never uses the header mapping after memcpy()'ing out its contents, - it maps and unmaps the entire table without ever looking at the contents. So let's refactor this code to unmap the table header right after the memcpy() so we can get rid of the error handling path altogether, and drop the second mapping entirely. Reported-by: Tyler Baicar Signed-off-by: Ard Biesheuvel Cc: Linus Torvalds Cc: Matt Fleming Cc: Peter Jones Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180312084500.10764-5-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/esrt.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c index c47e0c6ec00f..1ab80e06e7c5 100644 --- a/drivers/firmware/efi/esrt.c +++ b/drivers/firmware/efi/esrt.c @@ -279,6 +279,7 @@ void __init efi_esrt_init(void) } memcpy(&tmpesrt, va, sizeof(tmpesrt)); + early_memunmap(va, size); if (tmpesrt.fw_resource_version == 1) { entry_size = sizeof (*v1_entries); @@ -291,7 +292,7 @@ void __init efi_esrt_init(void) if (tmpesrt.fw_resource_count > 0 && max - size < entry_size) { pr_err("ESRT memory map entry can only hold the header. (max: %zu size: %zu)\n", max - size, entry_size); - goto err_memunmap; + return; } /* @@ -304,7 +305,7 @@ void __init efi_esrt_init(void) if (tmpesrt.fw_resource_count > 128) { pr_err("ESRT says fw_resource_count has very large value %d.\n", tmpesrt.fw_resource_count); - goto err_memunmap; + return; } /* @@ -315,18 +316,10 @@ void __init efi_esrt_init(void) if (max < size + entries_size) { pr_err("ESRT does not fit on single memory map entry (size: %zu max: %zu)\n", size, max); - goto err_memunmap; + return; } - /* remap it with our (plausible) new pages */ - early_memunmap(va, size); size += entries_size; - va = early_memremap(efi.esrt, size); - if (!va) { - pr_err("early_memremap(%p, %zu) failed.\n", (void *)efi.esrt, - size); - return; - } esrt_data = (phys_addr_t)efi.esrt; esrt_data_size = size; @@ -336,8 +329,6 @@ void __init efi_esrt_init(void) efi_mem_reserve(esrt_data, esrt_data_size); pr_debug("esrt-init: loaded.\n"); -err_memunmap: - early_memunmap(va, size); } static int __init register_entries(void) -- cgit v1.2.3 From 36b649760e94968e0495b73284aaf07eed0a328f Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Mon, 12 Mar 2018 08:45:00 +0000 Subject: efi: Use string literals for efi_char16_t variable initializers Now that we unambiguously build the entire kernel with -fshort-wchar, it is no longer necessary to open code efi_char16_t[] initializers as arrays of characters, and we can move to the L"xxx" notation instead. Signed-off-by: Ard Biesheuvel Cc: Arnd Bergmann Cc: Linus Torvalds Cc: Lukas Wunner Cc: Matt Fleming Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20180312084500.10764-6-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- arch/x86/boot/compressed/eboot.c | 3 ++- arch/x86/platform/efi/quirks.c | 8 +++++--- drivers/firmware/efi/libstub/Makefile | 2 +- drivers/firmware/efi/libstub/secureboot.c | 12 +++--------- drivers/firmware/efi/libstub/tpm.c | 7 ++----- 5 files changed, 13 insertions(+), 19 deletions(-) (limited to 'drivers/firmware') diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index f2251c1c9853..47d3efff6805 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -421,9 +421,10 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) } } +static const efi_char16_t apple[] = L"Apple"; + static void setup_quirks(struct boot_params *boot_params) { - static efi_char16_t const apple[] = { 'A', 'p', 'p', 'l', 'e', 0 }; efi_char16_t *fw_vendor = (efi_char16_t *)(unsigned long) efi_table_attr(efi_system_table, fw_vendor, sys_table); diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c index 1ef11c26f79b..36c1f8b9f7e0 100644 --- a/arch/x86/platform/efi/quirks.c +++ b/arch/x86/platform/efi/quirks.c @@ -75,7 +75,7 @@ struct quark_security_header { u32 rsvd[2]; }; -static efi_char16_t efi_dummy_name[6] = { 'D', 'U', 'M', 'M', 'Y', 0 }; +static const efi_char16_t efi_dummy_name[] = L"DUMMY"; static bool efi_no_storage_paranoia; @@ -105,7 +105,8 @@ early_param("efi_no_storage_paranoia", setup_storage_paranoia); */ void efi_delete_dummy_variable(void) { - efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID, + efi.set_variable((efi_char16_t *)efi_dummy_name, + &EFI_DUMMY_GUID, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, @@ -182,7 +183,8 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size, if (!dummy) return EFI_OUT_OF_RESOURCES; - status = efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID, + status = efi.set_variable((efi_char16_t *)efi_dummy_name, + &EFI_DUMMY_GUID, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, diff --git a/drivers/firmware/efi/libstub/Makefile b/drivers/firmware/efi/libstub/Makefile index 7b3ba40f0745..a34e9290a699 100644 --- a/drivers/firmware/efi/libstub/Makefile +++ b/drivers/firmware/efi/libstub/Makefile @@ -9,7 +9,7 @@ cflags-$(CONFIG_X86_32) := -march=i386 cflags-$(CONFIG_X86_64) := -mcmodel=small cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ -O2 \ -fPIC -fno-strict-aliasing -mno-red-zone \ - -mno-mmx -mno-sse + -mno-mmx -mno-sse -fshort-wchar cflags-$(CONFIG_ARM64) := $(subst -pg,,$(KBUILD_CFLAGS)) -fpie cflags-$(CONFIG_ARM) := $(subst -pg,,$(KBUILD_CFLAGS)) \ diff --git a/drivers/firmware/efi/libstub/secureboot.c b/drivers/firmware/efi/libstub/secureboot.c index 959777ec8a77..8f07eb414c00 100644 --- a/drivers/firmware/efi/libstub/secureboot.c +++ b/drivers/firmware/efi/libstub/secureboot.c @@ -16,18 +16,12 @@ /* BIOS variables */ static const efi_guid_t efi_variable_guid = EFI_GLOBAL_VARIABLE_GUID; -static const efi_char16_t efi_SecureBoot_name[] = { - 'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 -}; -static const efi_char16_t efi_SetupMode_name[] = { - 'S', 'e', 't', 'u', 'p', 'M', 'o', 'd', 'e', 0 -}; +static const efi_char16_t efi_SecureBoot_name[] = L"SecureBoot"; +static const efi_char16_t efi_SetupMode_name[] = L"SetupMode"; /* SHIM variables */ static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID; -static efi_char16_t const shim_MokSBState_name[] = { - 'M', 'o', 'k', 'S', 'B', 'S', 't', 'a', 't', 'e', 0 -}; +static const efi_char16_t shim_MokSBState_name[] = L"MokSBState"; #define get_efi_var(name, vendor, ...) \ efi_call_runtime(get_variable, \ diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index da661bf8cb96..2298560cea72 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -16,11 +16,8 @@ #include "efistub.h" #ifdef CONFIG_RESET_ATTACK_MITIGATION -static const efi_char16_t efi_MemoryOverWriteRequest_name[] = { - 'M', 'e', 'm', 'o', 'r', 'y', 'O', 'v', 'e', 'r', 'w', 'r', 'i', 't', - 'e', 'R', 'e', 'q', 'u', 'e', 's', 't', 'C', 'o', 'n', 't', 'r', 'o', - 'l', 0 -}; +static const efi_char16_t efi_MemoryOverWriteRequest_name[] = + L"MemoryOverwriteRequestControl"; #define MEMORY_ONLY_RESET_CONTROL_GUID \ EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29) -- cgit v1.2.3