From patchwork Mon Mar 12 08:45:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 131374 Delivered-To: patch@linaro.org Received: by 10.46.84.17 with SMTP id i17csp477470ljb; Mon, 12 Mar 2018 01:45:49 -0700 (PDT) X-Google-Smtp-Source: AG47ELv4Zjpo4sK0QeNAnG9BK+9dbKSkyuO0CBQXgefhERPEwlzOBM/GaRWAbBNzfI8nVqVOIZYH X-Received: by 2002:a17:902:968c:: with SMTP id n12-v6mr7414516plp.371.1520844349106; Mon, 12 Mar 2018 01:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520844349; cv=none; d=google.com; s=arc-20160816; b=C3gtTkhZE7e6crKI4gr7Tq0jAZX2xU9Q0DyNuDJakaJyMz5Yjg11CDrUUEvnSddN0p v5IUm2Y1uNpAF0Slk+51loscU9FaxC+2RGeqiUsfJzEJrdSn7uaBlEgZ+5cgrYJIXXP4 5B7WKaoe6ELNYH+amWYNfwy90GiST/7qXJPjob8QfGd3XSV7bJrHV9ySwyKl8oo51rdi C7gOK63M2FUCUxsaDJXgQZ9U+9LqrztDt7FLweMwpaCd0WjK35p4kw1jRUm+Te++Pvyt 55TwecW7QDGwLPTQvHW6fIgEIipceS+puX113ZkmXGSCpFmSBTBjywgZFzWLa7EjuV5y 0O1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=DqSRY6qaHYNeHVfVmuk8ymM1hb+EfbmcJFX+ARqnYQk=; b=JyUXdp1WBBR9CyE9hqDEcaLbevO/u6vDCAoedmJQMSxZ1utyklyje3G6Bhgc8hsRUw g2Ug0BgRwAfr8G7avlslc26qUhPQzu8XPLzldxg9wu5Xn0YtYro1xFLO+KdtMFasgAyT QSLLBbWg17E5IXBn5uLVqCjwyAywPolOV4hZ27Wa0YIT6dkbG0yuA5EWNFSAdhgDR+/V jABhmt8o3rsgqotfEDovkN7EJj8AcmgXEB5NQmuKj+PfERTmkVSqlXPPj/roq6CwBtrg B2w3Fs/JEsyG6QbvCmic/s4sdZpoTZY67n7pcQq9xtCfW4nIB6vGuFpnJx/eogjchurX B5mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OYv/5GrN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p9-v6si5689312plr.622.2018.03.12.01.45.48; Mon, 12 Mar 2018 01:45:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OYv/5GrN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752555AbeCLIpq (ORCPT + 28 others); Mon, 12 Mar 2018 04:45:46 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52651 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752522AbeCLIpk (ORCPT ); Mon, 12 Mar 2018 04:45:40 -0400 Received: by mail-wm0-f67.google.com with SMTP id t3so14699531wmc.2 for ; Mon, 12 Mar 2018 01:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DqSRY6qaHYNeHVfVmuk8ymM1hb+EfbmcJFX+ARqnYQk=; b=OYv/5GrNV4yVFIO/XZyhnT7ICiVARn/EXVYhZ7XfsG7M8DRKV4KZdW4azBHobjXQQX yMpYfEWjaLkKm9isTYSKPFvJ1CpX8OLT1Y6Ri3SZE+Drp0bKTx/KKDFRkQx8oWcgtKqr uhEKuvwE9wkxK+V6kxEYtoqt/FWQAeccGGsU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DqSRY6qaHYNeHVfVmuk8ymM1hb+EfbmcJFX+ARqnYQk=; b=eUvupGrq1AUja0Q06w2X89ZqCGj/WzWPJXo6Jvpp7xAoFkpUAizGUxneMLps551VIB 4T4P2hHlxfPnVD6MEXEQnlPlEk611wCj3EA94s8cRXz5hcWv9CBOl94wayNYqHndafrU QnpkYCoFFQZJL954VnPGbKvryldVa+mFNiICC1/FH+WNHe9QfJSaLnNszjswsz2fLlfa lsMSYjmDlTgmeK66Ok30aQ1ZIuXPL+2Eid7nRQIiYOG3hyFUIfIrvyLJeYnUIWqvlgee UmIRKTDnrLVtG1IdfkuMtDAga+j9mpfwYoF3JD14+2mPSw09E9Is1lB3L+i65yVcWnZm tefg== X-Gm-Message-State: AElRT7HPq/L1QVhhfxyMraSLk/bPvZv4xC4YVTM+RiE3eEKHtpNyi/Qz YW1uQW3i6DZtNvfGtm89pRmbrQ== X-Received: by 10.28.52.9 with SMTP id b9mr5311681wma.134.1520844339072; Mon, 12 Mar 2018 01:45:39 -0700 (PDT) Received: from localhost.localdomain ([105.148.128.186]) by smtp.gmail.com with ESMTPSA id c1sm6544788wre.27.2018.03.12.01.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 01:45:37 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arnd Bergmann , Lukas Wunner Subject: [PATCH 5/5] efi: use string literals for efi_char16_t variable initializers Date: Mon, 12 Mar 2018 08:45:00 +0000 Message-Id: <20180312084500.10764-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180312084500.10764-1-ard.biesheuvel@linaro.org> References: <20180312084500.10764-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Cc: Arnd Bergmann Cc: Lukas Wunner Signed-off-by: Ard Biesheuvel --- 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(-) -- 2.15.1 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)