From patchwork Mon Aug 12 15:04:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171087 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2952613ily; Mon, 12 Aug 2019 08:05:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqxg/PmDdz4OmNHL9hHb7qbWmC3mHk7I06mLVzzuYgA4ystqD3T25n7w8WaKkkpaBuZedVLM X-Received: by 2002:a17:902:1105:: with SMTP id d5mr30345419pla.197.1565622313917; Mon, 12 Aug 2019 08:05:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565622313; cv=none; d=google.com; s=arc-20160816; b=jW4iroEtqmZgGrLJp91n8I7pN0FCAdUl85b8g3caGKmaF8EFQg7UYf8seUcU9+hUKG +iSFED/BhJsd89gvX/VAZN8GLzJCqqjEb7f+RU8LHxEsw1zC2C8AradihefGlorqt4yt AgaWck5clEP6PsP8/SfyDov+OqQjMWu9PdQmXXU4aJupyvxlQ1K0Aa2iX7h3UKAclD3k nl6sIRJU4EPvB1PtjbqY3OQQ2TRMOaLpWzaOO7XnZsqAhb9UC143GqVfgyz6Pizk+2P5 VAl61PzZxi3TgMWNoLQjzE4+ORlWev5yA7myQL5Nb3Z20VTrnI3KI+tgNtC/uZLje0FN Gi/A== 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; bh=8IMb6ucekZITMI3FMSd2vkVdCA6v6V+Ngebbp2VClKs=; b=wg29pxSWx0ahF1izyjBKsj8Lejy05ELFUatVPAOGCSc+VYwFGBDYDyU6PzGxzY3+2/ dH1Gxbu1O5h3UZYx0fGt4cxeLXYwVgbst4zvxoL0ozxlROKynioPXBXn0Gh0TD6geJoA n3bkv7W9pFPGE3blckX5CbU5Tk84ZxBkvI++OWOfM2Qh038Th8xW+WWgL1Qkh85LVFi0 fJalS7p5SNSA7XmeH2eJrI3pbC/tTBTtSskBwO4gwCbuAKOnRb/8m3s0WkZqx7Mmzd+3 SyMsTJwY6TsnrdZwVjz33hYwA71HOgIGlIiBQFGD+Z3x/c19XwPvLCG/aVsd/Nabxmmq TT+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mYkFnIPS; 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 cj14si59946272plb.141.2019.08.12.08.05.13; Mon, 12 Aug 2019 08:05:13 -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=mYkFnIPS; 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 S1727585AbfHLPFM (ORCPT + 28 others); Mon, 12 Aug 2019 11:05:12 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:53959 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726954AbfHLPFK (ORCPT ); Mon, 12 Aug 2019 11:05:10 -0400 Received: by mail-wm1-f66.google.com with SMTP id 10so12497396wmp.3 for ; Mon, 12 Aug 2019 08:05:09 -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=8IMb6ucekZITMI3FMSd2vkVdCA6v6V+Ngebbp2VClKs=; b=mYkFnIPSEzOo3ELoos1JOjri2NaV+zXYbxrik8fkPrh+5rloTjwd/yVKYHjAa7pFLF wtktJZhupsHyFx3pDUdgJCjAwh2p9I6TMvQmya7vx9BrBdhGHagICquUhelfs60FQXNJ +Fmf80svglaVSoptoJFHOK/7/HQGbm06ig+PZL/IFbZPRMFZltu0iM3nG0FwkPInS1nf RE99EoSBVWs7/RDHUkK1hWxt0vUYdqsDFp6z6dSvIQwN8mU17cOI/uZOun2czuL3zl4P ijme2BGrI/TokPeVKfSslXWXAq1EO1A8iUqHlYQ4tfJsEhaWvECPEXrChIQq8+v16LoF zNAg== 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=8IMb6ucekZITMI3FMSd2vkVdCA6v6V+Ngebbp2VClKs=; b=IAiVgA9JyE++nyNxaYX9XRENq8A46KKC3BRxLwgA1dve2SOogBd2g4QBr0FEjAhPWu KAd9wt5AfvgfzhT+AEKLk4FVd54rEdKEK+tgEZXvW4z7Wg2zgVnD4m5lDcPU4FonXWW4 hg8FBaRWbH2+1wmh7CTWPA6eLBoJKHkIXAXQfVEznf5ICpaF2aH0B/SZkz5760kjGNnP EgFKyqAKSIeAbERun+zxj+/miHL503Hp2cGJDud66HdbBzEBv3abu+4vRreQMvzIrHCA cHwZCXPZuvkzN4cz+FTlohJxrAkkjeAU2rWzQ02bejnL0X88FfmiGxEu/oNUFGaOLYY8 Jyyw== X-Gm-Message-State: APjAAAWixGHmmQtC/VXbs1UHgMD3yQgS23pYzWf8Hokc33Usn4Mj4G3l 24EzI+Vo5pYBx9rLArIhOvVtwg== X-Received: by 2002:a1c:a008:: with SMTP id j8mr2838023wme.57.1565622308510; Mon, 12 Aug 2019 08:05:08 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:a407:da00:1c0e:f938:89a1:8e17]) by smtp.gmail.com with ESMTPSA id h97sm31027269wrh.74.2019.08.12.08.05.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Aug 2019 08:05:07 -0700 (PDT) From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, James Morse , Mario Limonciello , Narendra K , Xiaofei Tan Subject: [PATCH 1/5] efi: x86: move efi_is_table_address() into arch/x86 Date: Mon, 12 Aug 2019 18:04:48 +0300 Message-Id: <20190812150452.27983-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190812150452.27983-1-ard.biesheuvel@linaro.org> References: <20190812150452.27983-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function efi_is_table_address() and the associated array of table pointers is specific to x86. Since we will be adding some more x86 specific tables, let's move this code out of the generic code first. Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/efi.h | 5 +++++ arch/x86/mm/ioremap.c | 1 + arch/x86/platform/efi/efi.c | 33 +++++++++++++++++++++++++++++++++ drivers/firmware/efi/efi.c | 33 --------------------------------- include/linux/efi.h | 7 ------- 5 files changed, 39 insertions(+), 40 deletions(-) -- 2.17.1 diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 606a4b6a9812..43a82e59c59d 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h @@ -242,6 +242,7 @@ static inline bool efi_is_64bit(void) __efi_early()->runtime_services), __VA_ARGS__) extern bool efi_reboot_required(void); +extern bool efi_is_table_address(unsigned long phys_addr); #else static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} @@ -249,6 +250,10 @@ static inline bool efi_reboot_required(void) { return false; } +static inline bool efi_is_table_address(unsigned long phys_addr) +{ + return false; +} #endif /* CONFIG_EFI */ #endif /* _ASM_X86_EFI_H */ diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 63e99f15d7cf..a39dcdb5ae34 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index a7189a3b4d70..8d9be97a5607 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -64,6 +64,25 @@ static efi_config_table_type_t arch_tables[] __initdata = { {NULL_GUID, NULL, NULL}, }; +static const unsigned long * const efi_tables[] = { + &efi.mps, + &efi.acpi, + &efi.acpi20, + &efi.smbios, + &efi.smbios3, + &efi.sal_systab, + &efi.boot_info, + &efi.hcdp, + &efi.uga, + &efi.uv_systab, + &efi.fw_vendor, + &efi.runtime, + &efi.config_table, + &efi.esrt, + &efi.properties_table, + &efi.mem_attr_table, +}; + u64 efi_setup; /* efi setup_data physical address */ static int add_efi_memmap __initdata; @@ -1049,3 +1068,17 @@ static int __init arch_parse_efi_cmdline(char *str) return 0; } early_param("efi", arch_parse_efi_cmdline); + +bool efi_is_table_address(unsigned long phys_addr) +{ + unsigned int i; + + if (phys_addr == EFI_INVALID_TABLE_ADDR) + return false; + + for (i = 0; i < ARRAY_SIZE(efi_tables); i++) + if (*(efi_tables[i]) == phys_addr) + return true; + + return false; +} diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index ad3b1f4866b3..cbdbdbc8f9eb 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -57,25 +57,6 @@ struct efi __read_mostly efi = { }; EXPORT_SYMBOL(efi); -static unsigned long *efi_tables[] = { - &efi.mps, - &efi.acpi, - &efi.acpi20, - &efi.smbios, - &efi.smbios3, - &efi.sal_systab, - &efi.boot_info, - &efi.hcdp, - &efi.uga, - &efi.uv_systab, - &efi.fw_vendor, - &efi.runtime, - &efi.config_table, - &efi.esrt, - &efi.properties_table, - &efi.mem_attr_table, -}; - struct mm_struct efi_mm = { .mm_rb = RB_ROOT, .mm_users = ATOMIC_INIT(2), @@ -964,20 +945,6 @@ int efi_status_to_err(efi_status_t status) return err; } -bool efi_is_table_address(unsigned long phys_addr) -{ - unsigned int i; - - if (phys_addr == EFI_INVALID_TABLE_ADDR) - return false; - - for (i = 0; i < ARRAY_SIZE(efi_tables); i++) - if (*(efi_tables[i]) == phys_addr) - return true; - - return false; -} - static DEFINE_SPINLOCK(efi_mem_reserve_persistent_lock); static struct linux_efi_memreserve *efi_memreserve_root __ro_after_init; diff --git a/include/linux/efi.h b/include/linux/efi.h index f87fabea4a85..60a6242765d8 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1211,8 +1211,6 @@ static inline bool efi_enabled(int feature) return test_bit(feature, &efi.flags) != 0; } extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused); - -extern bool efi_is_table_address(unsigned long phys_addr); #else static inline bool efi_enabled(int feature) { @@ -1226,11 +1224,6 @@ efi_capsule_pending(int *reset_type) { return false; } - -static inline bool efi_is_table_address(unsigned long phys_addr) -{ - return false; -} #endif extern int efi_status_to_err(efi_status_t status);