efi: Use string literals for efi_char16_t variable initializers
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 12 Mar 2018 08:45:00 +0000 (08:45 +0000)
committerIngo Molnar <mingo@kernel.org>
Mon, 12 Mar 2018 09:05:02 +0000 (10:05 +0100)
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 <ard.biesheuvel@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Lukas Wunner <lukas@wunner.de>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20180312084500.10764-6-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/boot/compressed/eboot.c
arch/x86/platform/efi/quirks.c
drivers/firmware/efi/libstub/Makefile
drivers/firmware/efi/libstub/secureboot.c
drivers/firmware/efi/libstub/tpm.c

index f2251c1c98536663aa513196ce2528de2e12af7d..47d3efff6805b9787d4be1721cd8cb790818e10f 100644 (file)
@@ -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);
 
index 1ef11c26f79bb3c17ad4097148eabb36da56a16d..36c1f8b9f7e0c2df3dec1828e9f786f9d6c1ecfb 100644 (file)
@@ -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,
index 7b3ba40f0745bdd310e6507e358b81384867d455..a34e9290a6998cef4cdcd55e4b9cd9acc6593054 100644 (file)
@@ -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)) \
index 959777ec8a77bab62e49097cd93d711ccd311610..8f07eb414c00ea34c994ef8b72352aedf11cd547 100644 (file)
 
 /* 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, \
index da661bf8cb96e3b683b04574667ec9e7a350376b..2298560cea720e335ec9a140c83c18efccced48b 100644 (file)
 #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)