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); From patchwork Mon Aug 12 15:04:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171091 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2953096ily; Mon, 12 Aug 2019 08:05:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwejN8FGaTHxzlWfIUkIv6zBscVmJ7U7P50lus8PrIcT3Kkkx9WFumDDbxAl+q+dAQLXD1c X-Received: by 2002:a17:90a:bb8a:: with SMTP id v10mr24057539pjr.78.1565622332840; Mon, 12 Aug 2019 08:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565622332; cv=none; d=google.com; s=arc-20160816; b=ahsIGnOQD2TDlCrsDgjFQhefEahAYU1bDSDjHUa3rjgOJQyss0kRCxDxFlfMjNXIwa eRbW5Y+2zf5vT98gcVXhk3XX78UK9Y9MKI4r5Z6Hk0H396HZhXA/qzDmx3+ZiLq5EE8V 1QQ0eCu/FNYMC40P0vL8aqyQRvsH4G5gIc2hGXrumFhy7SwX8TpXz0Fl5n4hDTejQfrc +Rx2dboBp1bOQww5ZP8PIvhlsHDyjmmbAiJPyKyZTO3FyEXEkweLt7bxy45lPW63OIpD 8wr8uXA2ol7itVKDJerdA5Z0wLFu5NL73Tds3SR2Wu2RLgmyvGqeBXZSBFhpu4iyDat+ yBqg== 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=Z3sLGJ9Y6NSuUVoK4Ad/f3JwEEVat2vLXpskef4Wjpw=; b=0yLFY2dTas0d4vYn/GHhMdGmVatqWYps/lekEzSosWVfI9afyHyd93Dkd7tArqvqDm GFGscVbBhiSTePKzUqX7P8V6gCFIyEa9u4KgXoDBWszhBYMdwyLoATREhATar1P/XAO+ ow8umrjiKiV+3UldLtmRzosGN4RzzQ6cQtGK8LSuq3COHnYJcDmeZaU23SdreQSoAQJh FWTROHc3XzO4qYKhWwal4/4Ty1IC6lqTfXFtAzNIBZflRwqaQo2ecyMhvo/ZbinVggtJ 8xboHZ1oaDi48OrccdcC1OdaPvp9w6bTOhxAXUgcjyVWOgTEkUOTnNdnfWRncwSkvFN4 yQJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uUtpswhj; 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 b34si8454016plc.19.2019.08.12.08.05.32; Mon, 12 Aug 2019 08:05:32 -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=uUtpswhj; 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 S1727666AbfHLPFP (ORCPT + 28 others); Mon, 12 Aug 2019 11:05:15 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:52269 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727146AbfHLPFM (ORCPT ); Mon, 12 Aug 2019 11:05:12 -0400 Received: by mail-wm1-f67.google.com with SMTP id s3so12503722wms.2 for ; Mon, 12 Aug 2019 08:05:11 -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=Z3sLGJ9Y6NSuUVoK4Ad/f3JwEEVat2vLXpskef4Wjpw=; b=uUtpswhjcXonrclDX2pzC/OLlMB8CR4jdNsbVCyyJfbFyBbMWg+0Aew0YrDSAbgynn UBHZ5qxiR/FLZ0Ct92Vg9vySGyIMlp0Yt/g4bYii5IWID7ZLPf+RyFBRXZAedOHhY3f1 x8kbYQmk9C1++IuCm9gK2XiUkD/aqYVIN9apkB5giAeUyZKNaA/0ZJXRkq79Y5kkKhE4 1SGL8XBz3c2V4QL0D7Qs4FM7A3jQbeESD3X1qiLoi9x1D7WoWNGemRbTg5N+WEtmjXeP zpXj0JUd+0iUU29AgEne7VQpoPzhKcNXb81u+/xT9VS4QG/w5s0GItw7dh6fJS+Hrplh PIyQ== 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=Z3sLGJ9Y6NSuUVoK4Ad/f3JwEEVat2vLXpskef4Wjpw=; b=pKH9ltWlhDQBxpeIeftIlSmGTIGs7v12UAFPqUkW/sy25oW6PcstYGGaWhy+F4HF41 0T7OIYQyODZiRqx2h9qA/jkDTGa2YbiwioyEKmcJ8+uF3k5NPRRcX2WSVFOFRFLcjp7b z42FRmXlyD3qO9lE2aImSEcz7M3AI+fWOGHSfEdZbTsh/NmTufjl997PcnxpFZHz06eV /EsLKMW/hJXUD37rx90IOTGs6Nd9k7uh6TZLkvaslfBTK4y9FoNx5N2fQo/zgc+6rsKx Me9bHnXGHzYQKSG9U3qh4IWfXcndjpmvTeO4/fiQxsEHpZZVgq8BC/IMRUsX+S0ouS42 Ru1A== X-Gm-Message-State: APjAAAXe9YxU3aYb21xYRCBcjp22+8ZDcyCbskGSkVxHSyq3aUI9vaNd k8psHrqvLKBLcbxCnKOmLMoLKQ== X-Received: by 2002:a1c:4c06:: with SMTP id z6mr3789211wmf.47.1565622310553; Mon, 12 Aug 2019 08:05:10 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Aug 2019 08:05:09 -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 2/5] efi/x86: move UV_SYSTAB handling into arch/x86 Date: Mon, 12 Aug 2019 18:04:49 +0300 Message-Id: <20190812150452.27983-3-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 SGI UV UEFI machines are tightly coupled to the x86 architecture so there is no need to keep any awareness of its existence in the generic EFI layer, especially since we already have the infrastructure to handle arch-specific configuration tables, and were even already using it to some extent. Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/uv/uv.h | 4 +++- arch/x86/platform/efi/efi.c | 6 ++++-- arch/x86/platform/uv/bios_uv.c | 10 ++++++---- drivers/firmware/efi/efi.c | 1 - include/linux/efi.h | 1 - 5 files changed, 13 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/arch/x86/include/asm/uv/uv.h b/arch/x86/include/asm/uv/uv.h index e60c45fd3679..6bc6d89d8e2a 100644 --- a/arch/x86/include/asm/uv/uv.h +++ b/arch/x86/include/asm/uv/uv.h @@ -12,10 +12,12 @@ struct mm_struct; #ifdef CONFIG_X86_UV #include +extern unsigned long uv_systab_phys; + extern enum uv_system_type get_uv_system_type(void); static inline bool is_early_uv_system(void) { - return !((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || !efi.uv_systab); + return uv_systab_phys && uv_systab_phys != EFI_INVALID_TABLE_ADDR; } extern int is_uv_system(void); extern int is_uv_hubless(void); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 8d9be97a5607..9866a3584765 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -59,7 +59,7 @@ static efi_system_table_t efi_systab __initdata; static efi_config_table_type_t arch_tables[] __initdata = { #ifdef CONFIG_X86_UV - {UV_SYSTEM_TABLE_GUID, "UVsystab", &efi.uv_systab}, + {UV_SYSTEM_TABLE_GUID, "UVsystab", &uv_systab_phys}, #endif {NULL_GUID, NULL, NULL}, }; @@ -74,7 +74,9 @@ static const unsigned long * const efi_tables[] = { &efi.boot_info, &efi.hcdp, &efi.uga, - &efi.uv_systab, +#ifdef CONFIG_X86_UV + &uv_systab_phys, +#endif &efi.fw_vendor, &efi.runtime, &efi.config_table, diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c index 7c69652ffeea..c2ee31953372 100644 --- a/arch/x86/platform/uv/bios_uv.c +++ b/arch/x86/platform/uv/bios_uv.c @@ -14,6 +14,8 @@ #include #include +unsigned long uv_systab_phys __ro_after_init = EFI_INVALID_TABLE_ADDR; + struct uv_systab *uv_systab; static s64 __uv_bios_call(enum uv_bios_cmd which, u64 a1, u64 a2, u64 a3, @@ -185,13 +187,13 @@ EXPORT_SYMBOL_GPL(uv_bios_set_legacy_vga_target); void uv_bios_init(void) { uv_systab = NULL; - if ((efi.uv_systab == EFI_INVALID_TABLE_ADDR) || - !efi.uv_systab || efi_runtime_disabled()) { + if ((uv_systab_phys == EFI_INVALID_TABLE_ADDR) || + !uv_systab_phys || efi_runtime_disabled()) { pr_crit("UV: UVsystab: missing\n"); return; } - uv_systab = ioremap(efi.uv_systab, sizeof(struct uv_systab)); + uv_systab = ioremap(uv_systab_phys, sizeof(struct uv_systab)); if (!uv_systab || strncmp(uv_systab->signature, UV_SYSTAB_SIG, 4)) { pr_err("UV: UVsystab: bad signature!\n"); iounmap(uv_systab); @@ -203,7 +205,7 @@ void uv_bios_init(void) int size = uv_systab->size; iounmap(uv_systab); - uv_systab = ioremap(efi.uv_systab, size); + uv_systab = ioremap(uv_systab_phys, size); if (!uv_systab) { pr_err("UV: UVsystab: ioremap(%d) failed!\n", size); return; diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index cbdbdbc8f9eb..4dfd873373bd 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -43,7 +43,6 @@ struct efi __read_mostly efi = { .boot_info = EFI_INVALID_TABLE_ADDR, .hcdp = EFI_INVALID_TABLE_ADDR, .uga = EFI_INVALID_TABLE_ADDR, - .uv_systab = EFI_INVALID_TABLE_ADDR, .fw_vendor = EFI_INVALID_TABLE_ADDR, .runtime = EFI_INVALID_TABLE_ADDR, .config_table = EFI_INVALID_TABLE_ADDR, diff --git a/include/linux/efi.h b/include/linux/efi.h index 60a6242765d8..171bb1005a10 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -988,7 +988,6 @@ extern struct efi { unsigned long boot_info; /* boot info table */ unsigned long hcdp; /* HCDP table */ unsigned long uga; /* UGA table */ - unsigned long uv_systab; /* UV system table */ unsigned long fw_vendor; /* fw_vendor */ unsigned long runtime; /* runtime table */ unsigned long config_table; /* config tables */ From patchwork Mon Aug 12 15:04:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171088 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2952728ily; Mon, 12 Aug 2019 08:05:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxqNloIS9aMctTae5nebDYbGpWk9U45bn4qSKf6KBcSpwO5AppmXwciLPZbuo+hNZ9mTLy X-Received: by 2002:a17:90a:29c5:: with SMTP id h63mr22959896pjd.83.1565622318042; Mon, 12 Aug 2019 08:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565622318; cv=none; d=google.com; s=arc-20160816; b=x7pbpDBPiLhz6KEA/gyAnwZR58hEuXLRMHybNTLOBAz9edmGhbwA8lkw0rvw6j1BAR IiD2ep5C1L8eDFeKroqMyTmulGxv+hwxunGk5T/SUZh0uWIc8ZBw/3wUF7lJYJAZfYcz MLpyUo1Z6I9HvEySyJ7IQTHMFZM81eJ190neErgzQ3mE++gLbLQm3GyDw9CzdovV8Dvf xBjUKHPbMsT1Lk3zXqYz2m5wutzJHW5/bI7tFLgfw+lXmUActjWSNy/bgQOfaBQRH2St H2hmkPn5sbWzO1XlD4A4bD/n13Z0DQUAj1JndRM/eVqFkVHZGZ9OyrQpMD0/aWMlHZkr iSyg== 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=+lKE3M766VSXcFdd93gVKyp3DvIcJdKpewtir+tTjtY=; b=Tv2qaxiLuSsB5BFyinzcs6NgkgxHKUWWdV2nbZnFLkv6h4TmaXNI8xp4otTAWJRdaC svmzbEYe/H1FYGxbes2zVaHDde5885mKI1BNqWzVcoYw/SUyWbUOfyu9SiPWTNtjLFPy XXS1n0zQKVt/wvVJyx7TBrPwBC1O8ZLNrqimh1RBHDs2Ul3zmZnr/++QVVZGvtGWP0aO EhPYPO+IcRWFI9I5QmzoY7QIvaTItCW9Gx9SKKlreek6RYkdfjyeIgV0L8sT3TbMfg/b AybDXtYsHuqqLRo3coc4sPWU3FXOK+/wahHDXA9RUEYcyBsSRx8EfhmAElvXDJgRi2NG kKqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Rrv303O4; 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.17; Mon, 12 Aug 2019 08:05:18 -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=Rrv303O4; 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 S1727764AbfHLPFQ (ORCPT + 28 others); Mon, 12 Aug 2019 11:05:16 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35286 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbfHLPFP (ORCPT ); Mon, 12 Aug 2019 11:05:15 -0400 Received: by mail-wm1-f67.google.com with SMTP id l2so12089889wmg.0 for ; Mon, 12 Aug 2019 08:05:13 -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=+lKE3M766VSXcFdd93gVKyp3DvIcJdKpewtir+tTjtY=; b=Rrv303O43OyEKz36qcqnSKBIfjcfCb4HWfW9FX3qbTTUFSZeHD+ZEYxD7FWdJO01zz FKjj+3TTv8OMK34lkqrRP70oXLRXYegXR2wmS6GFWKdXJ8RhFF8xNpEgrd4ArJ66lAne Df3gipPgc8ZqMSg/hfMqlZSVy8Wpp4lrs6k8RECYjSvtmMAG9aEa1YWTgSp2LpukgMfd cvJLKlHTQgz3yMgZ6dZzdEekD+kYNDOxIWQMzkldeg4Hl4VZ3VvzTgRjlERwT3IoTcTS rLpOef9qj2iPFTtYP0zWJTxAkjxl50ehZ2ynJBH1NUnA5OrFcZRQqohI+FRQWsf50tP0 1LWQ== 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=+lKE3M766VSXcFdd93gVKyp3DvIcJdKpewtir+tTjtY=; b=etB/pedEB8hIF0vItCq5facz5yQF37+wTxNFxPBTDG6CAup6rXp9/QaIQDORvY+ub1 /QE20yrBSIaTQoTNNoKnXcd4M34FULIItqswiJQWXmRRtpm3/4yzSFMV/JouKbOlpcLQ 2eq4fYjfxNLvSAkqjNlwvxDJdJ7BW7eYPI6XdiYgl8lFFEy89P+kWg/Jy45FqS0tatfM 0/TpbUc/5pKSEqVEx6NhVoSd2Y1QuepqiRGr+HDjoZVyTWawEJFNJkx/ukNHu7zht5x3 fMeYv1TiHN0IcCyMOfILiT0Zy0xGlOt8vKG0Ddzj7OHELnF2hbNMPhYTiT8bBkJjA30v /4nw== X-Gm-Message-State: APjAAAWfdy1eAk2yRRikozNk1bb6b62cUsGsghnStN53bK7oQSWOi9Bt z0bmON3mpbH9c4ZsGZCzIEZa5A== X-Received: by 2002:a1c:f618:: with SMTP id w24mr22373421wmc.112.1565622312740; Mon, 12 Aug 2019 08:05:12 -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.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Aug 2019 08:05:12 -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 , Fenghua Yu , linux-ia64@vger.kernel.org Subject: [PATCH 3/5] efi: ia64: move SAL systab handling out of generic EFI code Date: Mon, 12 Aug 2019 18:04:50 +0300 Message-Id: <20190812150452.27983-4-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 SAL systab is an Itanium specific EFI configuration table, so move its handling into arch/ia64 where it belongs. Cc; Tony Luck Cc: Fenghua Yu Cc: linux-ia64@vger.kernel.org Signed-off-by: Ard Biesheuvel --- arch/ia64/include/asm/sal.h | 1 + arch/ia64/include/asm/sn/sn_sal.h | 2 +- arch/ia64/kernel/efi.c | 3 +++ arch/ia64/kernel/setup.c | 2 +- arch/x86/platform/efi/efi.c | 1 - drivers/firmware/efi/efi.c | 2 -- include/linux/efi.h | 1 - 7 files changed, 6 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/arch/ia64/include/asm/sal.h b/arch/ia64/include/asm/sal.h index 588f33156da6..08f5b6aaed73 100644 --- a/arch/ia64/include/asm/sal.h +++ b/arch/ia64/include/asm/sal.h @@ -43,6 +43,7 @@ #include #include +extern unsigned long sal_systab_phys; extern spinlock_t sal_lock; /* SAL spec _requires_ eight args for each call. */ diff --git a/arch/ia64/include/asm/sn/sn_sal.h b/arch/ia64/include/asm/sn/sn_sal.h index 1f5ff470a5a1..5142c444652d 100644 --- a/arch/ia64/include/asm/sn/sn_sal.h +++ b/arch/ia64/include/asm/sn/sn_sal.h @@ -167,7 +167,7 @@ static inline u32 sn_sal_rev(void) { - struct ia64_sal_systab *systab = __va(efi.sal_systab); + struct ia64_sal_systab *systab = __va(sal_systab_phys); return (u32)(systab->sal_b_rev_major << 8 | systab->sal_b_rev_minor); } diff --git a/arch/ia64/kernel/efi.c b/arch/ia64/kernel/efi.c index 3795d18276c4..0a34dcc435c6 100644 --- a/arch/ia64/kernel/efi.c +++ b/arch/ia64/kernel/efi.c @@ -47,8 +47,11 @@ static __initdata unsigned long palo_phys; +unsigned long sal_systab_phys = EFI_INVALID_TABLE_ADDR; + static __initdata efi_config_table_type_t arch_tables[] = { {PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID, "PALO", &palo_phys}, + {SAL_SYSTEM_TABLE_GUID, "SALsystab", &sal_systab_phys}, {NULL_GUID, NULL, 0}, }; diff --git a/arch/ia64/kernel/setup.c b/arch/ia64/kernel/setup.c index c9cfa760cd57..0e1b4eb149b4 100644 --- a/arch/ia64/kernel/setup.c +++ b/arch/ia64/kernel/setup.c @@ -572,7 +572,7 @@ setup_arch (char **cmdline_p) find_memory(); /* process SAL system table: */ - ia64_sal_init(__va(efi.sal_systab)); + ia64_sal_init(__va(sal_systab_phys)); #ifdef CONFIG_ITANIUM ia64_patch_rse((u64) __start___rse_patchlist, (u64) __end___rse_patchlist); diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 9866a3584765..6697c109c449 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -70,7 +70,6 @@ static const unsigned long * const efi_tables[] = { &efi.acpi20, &efi.smbios, &efi.smbios3, - &efi.sal_systab, &efi.boot_info, &efi.hcdp, &efi.uga, diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 4dfd873373bd..801925c5bcfb 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -39,7 +39,6 @@ struct efi __read_mostly efi = { .acpi20 = EFI_INVALID_TABLE_ADDR, .smbios = EFI_INVALID_TABLE_ADDR, .smbios3 = EFI_INVALID_TABLE_ADDR, - .sal_systab = EFI_INVALID_TABLE_ADDR, .boot_info = EFI_INVALID_TABLE_ADDR, .hcdp = EFI_INVALID_TABLE_ADDR, .uga = EFI_INVALID_TABLE_ADDR, @@ -456,7 +455,6 @@ static __initdata efi_config_table_type_t common_tables[] = { {ACPI_TABLE_GUID, "ACPI", &efi.acpi}, {HCDP_TABLE_GUID, "HCDP", &efi.hcdp}, {MPS_TABLE_GUID, "MPS", &efi.mps}, - {SAL_SYSTEM_TABLE_GUID, "SALsystab", &efi.sal_systab}, {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios}, {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3}, {UGA_IO_PROTOCOL_GUID, "UGA", &efi.uga}, diff --git a/include/linux/efi.h b/include/linux/efi.h index 171bb1005a10..f88318b85fb0 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -984,7 +984,6 @@ extern struct efi { unsigned long acpi20; /* ACPI table (ACPI 2.0) */ unsigned long smbios; /* SMBIOS table (32 bit entry point) */ unsigned long smbios3; /* SMBIOS table (64 bit entry point) */ - unsigned long sal_systab; /* SAL system table */ unsigned long boot_info; /* boot info table */ unsigned long hcdp; /* HCDP table */ unsigned long uga; /* UGA table */ From patchwork Mon Aug 12 15:04:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 171090 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2952936ily; Mon, 12 Aug 2019 08:05:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk1WT3R0lLaQSWRlPYgBd15gF3rgez8RXKEf1vyffKrOcztSmg8RJUN6oNYSmecXYDN2+a X-Received: by 2002:a65:4b89:: with SMTP id t9mr30088207pgq.55.1565622326271; Mon, 12 Aug 2019 08:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565622326; cv=none; d=google.com; s=arc-20160816; b=rxMCGdR5Dzrq/Zb/++W4HOUUbrdz/WNwRby1nh4280gNNsHGbLwkkLSNycodj2Ln4G XfZ02NEt7XHI3Uvp4x6c7ZTXZ9/xMv2wcXGgClGOaVTYjlYqzbImdBj4ZWswEB+Gw+L3 1VI+zdKTfelrav3CLKn3PHqBqZUDMI1EiKzC1HWeBxI0IE1/22Dk8VVWTLLoGXRx1rT3 NOQckJ+jcx2paP189NymSA7EHXHBn6F8D617kRBVLX4E81UWX81/f01rAy2EOQBezfBM ubTaB4JCxeTqja0eGWg+9Njt4JBSwDBusmCZuyZvMA80rezGCJyn0+rqSgSUwIjqORPN pJug== 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=ZTec1syIGwZQpjCOa7POHoiRLVfdieJdx9Ak1va9vi8=; b=PDTK0ziZ2AjK5PLln5S8JdtBOzYRaE0eUzNvc/4hHBwDGFEvBIlEkhF7SoTes6xz+/ GkCoKY1IhxEyAfiZsQsm3c5ojxpXIkGGeswa01xtDXJ3FE/rwuBWJZ/PAIEnpS4Yw7wB HFybEdWym5oVhYWbocY7dZpWVhfIqgpATrMsIOaTm35HXlB00n93Z9wDz/YBzQUxalft 5cAkdEXnh0K1Zn4WLiDC2wVV5+9G94aPlDBy8oKauHVb3bAKktu5qE34vl+x30+D9904 c2gXJUpkTOqLXfQFl9l+uEe6qfkd737m1o49f2e3i4V4SwpaDP0w+DJN9NIlWi2lctPF 5+FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lDWHBYhs; 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 w188si65475514pfb.175.2019.08.12.08.05.25; Mon, 12 Aug 2019 08:05:26 -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=lDWHBYhs; 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 S1728041AbfHLPFZ (ORCPT + 28 others); Mon, 12 Aug 2019 11:05:25 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:38302 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727770AbfHLPFU (ORCPT ); Mon, 12 Aug 2019 11:05:20 -0400 Received: by mail-wr1-f66.google.com with SMTP id g17so104853948wrr.5 for ; Mon, 12 Aug 2019 08:05:18 -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=ZTec1syIGwZQpjCOa7POHoiRLVfdieJdx9Ak1va9vi8=; b=lDWHBYhsJD4SluAUQH+k1cxC/HkQA6QyXUUC8mqE2tv4zchVBW+r/KGX8bWburrO3r y13sX7Jo6qY2YYvdm7+H4X7KDQdMYjuVXzNJYHahwDFDVmFssOLZKcfukyF/uDl/miCC aYA+LYXwQyMh8+KdcfbO9VKgLTQB6tLAdbB1dcCPQazP/KpKOr5PAVxiwXlFTV9eJBEG CMBlU4rYv+2s7CiaYtNpD7B9eb6HhNzC8lbuybFOeCekbHBtsKr75fPBHd9KmwqapPTO tfSRY2IlFWQFuj1a7zzUdg+uNb6zlX0U1+WEQajfECRSg4mbSq2dLCYuZ0tryZmd7QTv VOIg== 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=ZTec1syIGwZQpjCOa7POHoiRLVfdieJdx9Ak1va9vi8=; b=jVuAj0Oq6p2sB/ndglo+FQL3yqGXv/z/v0n1f2JfdmWsUdrrc3aLw+4xFDYVlHDI65 a3rakSZ19qIO8rWjoGlQmXsbLWVpzSm/BlfedLXKMOt5Scot9+n+NfyiG1hnByMluBXB nOisPpCFE7Chz6R1rLBr6n15kjBfWYemeNf+by++nWLKu+EhnRoX6cbDT20Cmr3tkAtK kY26i/abHlmkMJXmleh1Ph86FNj932Iijs5LUkcUNT9oFY3sjoHfkLfWOFcu/s48npAN Z/Wb6MwM0QU5VhiJeRx+8dDGcIPGj2ROg80UNLeTMnGEtu1j43ouyZSmnq3tmsDysWDR 8JdQ== X-Gm-Message-State: APjAAAUO7sOiCKlL7qlOaHROGerhUq0mYiRoJvWyHYSzur6rKqOsOd2V dq7nbE/xPWVDTrIMiWJTpXG3eNaQ0rDh+Q== X-Received: by 2002:a5d:4589:: with SMTP id p9mr31989747wrq.276.1565622317455; Mon, 12 Aug 2019 08:05:17 -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.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Aug 2019 08:05:16 -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 4/5] efi: Export Runtime Configuration Interface table to sysfs Date: Mon, 12 Aug 2019 18:04:51 +0300 Message-Id: <20190812150452.27983-5-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 From: Narendra K System firmware advertises the address of the 'Runtime Configuration Interface table version 2 (RCI2)' via an EFI Configuration Table entry. This code retrieves the RCI2 table from the address and exports it to sysfs as a binary attribute 'rci2' under /sys/firmware/efi/tables directory. The approach adopted is similar to the attribute 'DMI' under /sys/firmware/dmi/tables. RCI2 table contains BIOS HII in XML format and is used to populate BIOS setup page in Dell EMC OpenManage Server Administrator tool. The BIOS setup page contains BIOS tokens which can be configured. Signed-off-by: Narendra K Reviewed-by: Mario Limonciello Signed-off-by: Ard Biesheuvel --- Documentation/ABI/testing/sysfs-firmware-efi | 8 + arch/x86/platform/efi/efi.c | 3 + drivers/firmware/efi/Kconfig | 13 ++ drivers/firmware/efi/Makefile | 1 + drivers/firmware/efi/efi.c | 3 + drivers/firmware/efi/rci2-table.c | 147 +++++++++++++++++++ include/linux/efi.h | 5 + 7 files changed, 180 insertions(+) create mode 100644 drivers/firmware/efi/rci2-table.c -- 2.17.1 diff --git a/Documentation/ABI/testing/sysfs-firmware-efi b/Documentation/ABI/testing/sysfs-firmware-efi index e794eac32a90..5e4d0b27cdfe 100644 --- a/Documentation/ABI/testing/sysfs-firmware-efi +++ b/Documentation/ABI/testing/sysfs-firmware-efi @@ -28,3 +28,11 @@ Description: Displays the physical addresses of all EFI Configuration versions are always printed first, i.e. ACPI20 comes before ACPI. Users: dmidecode + +What: /sys/firmware/efi/tables/rci2 +Date: July 2019 +Contact: Narendra K , linux-bugs@dell.com +Description: Displays the content of the Runtime Configuration Interface + Table version 2 on Dell EMC PowerEdge systems in binary format +Users: It is used by Dell EMC OpenManage Server Administrator tool to + populate BIOS setup page. diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 6697c109c449..c202e1b07e29 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -82,6 +82,9 @@ static const unsigned long * const efi_tables[] = { &efi.esrt, &efi.properties_table, &efi.mem_attr_table, +#ifdef CONFIG_EFI_RCI2_TABLE + &rci2_table_phys, +#endif }; u64 efi_setup; /* efi setup_data physical address */ diff --git a/drivers/firmware/efi/Kconfig b/drivers/firmware/efi/Kconfig index d4ea929e8b34..178ee8106828 100644 --- a/drivers/firmware/efi/Kconfig +++ b/drivers/firmware/efi/Kconfig @@ -180,6 +180,19 @@ config RESET_ATTACK_MITIGATION have been evicted, since otherwise it will trigger even on clean reboots. +config EFI_RCI2_TABLE + bool "EFI Runtime Configuration Interface Table Version 2 Support" + help + Displays the content of the Runtime Configuration Interface + Table version 2 on Dell EMC PowerEdge systems as a binary + attribute 'rci2' under /sys/firmware/efi/tables directory. + + RCI2 table contains BIOS HII in XML format and is used to populate + BIOS setup page in Dell EMC OpenManage Server Administrator tool. + The BIOS setup page contains BIOS tokens which can be configured. + + Say Y here for Dell EMC PowerEdge systems. + endmenu config UEFI_CPER diff --git a/drivers/firmware/efi/Makefile b/drivers/firmware/efi/Makefile index d2d0d2030620..4ac2de4dfa72 100644 --- a/drivers/firmware/efi/Makefile +++ b/drivers/firmware/efi/Makefile @@ -25,6 +25,7 @@ obj-$(CONFIG_EFI_BOOTLOADER_CONTROL) += efibc.o obj-$(CONFIG_EFI_TEST) += test/ obj-$(CONFIG_EFI_DEV_PATH_PARSER) += dev-path-parser.o obj-$(CONFIG_APPLE_PROPERTIES) += apple-properties.o +obj-$(CONFIG_EFI_RCI2_TABLE) += rci2-table.o arm-obj-$(CONFIG_EFI) := arm-init.o arm-runtime.o obj-$(CONFIG_ARM) += $(arm-obj-y) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 801925c5bcfb..8f1ab04f6743 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -465,6 +465,9 @@ static __initdata efi_config_table_type_t common_tables[] = { {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log}, {LINUX_EFI_TPM_FINAL_LOG_GUID, "TPMFinalLog", &efi.tpm_final_log}, {LINUX_EFI_MEMRESERVE_TABLE_GUID, "MEMRESERVE", &efi.mem_reserve}, +#ifdef CONFIG_EFI_RCI2_TABLE + {DELLEMC_EFI_RCI2_TABLE_GUID, NULL, &rci2_table_phys}, +#endif {NULL_GUID, NULL, NULL}, }; diff --git a/drivers/firmware/efi/rci2-table.c b/drivers/firmware/efi/rci2-table.c new file mode 100644 index 000000000000..3e290f96620a --- /dev/null +++ b/drivers/firmware/efi/rci2-table.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Export Runtime Configuration Interface Table Version 2 (RCI2) + * to sysfs + * + * Copyright (C) 2019 Dell Inc + * by Narendra K + * + * System firmware advertises the address of the RCI2 Table via + * an EFI Configuration Table entry. This code retrieves the RCI2 + * table from the address and exports it to sysfs as a binary + * attribute 'rci2' under /sys/firmware/efi/tables directory. + */ + +#include +#include +#include +#include +#include +#include + +#define RCI_SIGNATURE "_RC_" + +struct rci2_table_global_hdr { + u16 type; + u16 resvd0; + u16 hdr_len; + u8 rci2_sig[4]; + u16 resvd1; + u32 resvd2; + u32 resvd3; + u8 major_rev; + u8 minor_rev; + u16 num_of_structs; + u32 rci2_len; + u16 rci2_chksum; +} __packed; + +static u8 *rci2_base; +static u32 rci2_table_len; +unsigned long rci2_table_phys __ro_after_init = EFI_INVALID_TABLE_ADDR; + +static ssize_t raw_table_read(struct file *file, struct kobject *kobj, + struct bin_attribute *attr, char *buf, + loff_t pos, size_t count) +{ + memcpy(buf, attr->private + pos, count); + return count; +} + +static BIN_ATTR(rci2, S_IRUSR, raw_table_read, NULL, 0); + +static u16 checksum(void) +{ + u8 len_is_odd = rci2_table_len % 2; + u32 chksum_len = rci2_table_len; + u16 *base = (u16 *)rci2_base; + u8 buf[2] = {0}; + u32 offset = 0; + u16 chksum = 0; + + if (len_is_odd) + chksum_len -= 1; + + while (offset < chksum_len) { + chksum += *base; + offset += 2; + base++; + } + + if (len_is_odd) { + buf[0] = *(u8 *)base; + chksum += *(u16 *)(buf); + } + + return chksum; +} + +int __init efi_rci2_sysfs_init(void) +{ + struct kobject *tables_kobj; + int ret = -ENOMEM; + + rci2_base = memremap(rci2_table_phys, + sizeof(struct rci2_table_global_hdr), + MEMREMAP_WB); + if (!rci2_base) { + pr_debug("RCI2 table init failed - could not map RCI2 table\n"); + goto err; + } + + if (strncmp(rci2_base + + offsetof(struct rci2_table_global_hdr, rci2_sig), + RCI_SIGNATURE, 4)) { + pr_debug("RCI2 table init failed - incorrect signature\n"); + ret = -ENODEV; + goto err_unmap; + } + + rci2_table_len = *(u32 *)(rci2_base + + offsetof(struct rci2_table_global_hdr, + rci2_len)); + + memunmap(rci2_base); + + if (!rci2_table_len) { + pr_debug("RCI2 table init failed - incorrect table length\n"); + goto err; + } + + rci2_base = memremap(rci2_table_phys, rci2_table_len, MEMREMAP_WB); + if (!rci2_base) { + pr_debug("RCI2 table - could not map RCI2 table\n"); + goto err; + } + + if (checksum() != 0) { + pr_debug("RCI2 table - incorrect checksum\n"); + ret = -ENODEV; + goto err_unmap; + } + + tables_kobj = kobject_create_and_add("tables", efi_kobj); + if (!tables_kobj) { + pr_debug("RCI2 table - tables_kobj creation failed\n"); + goto err_unmap; + } + + bin_attr_rci2.size = rci2_table_len; + bin_attr_rci2.private = rci2_base; + ret = sysfs_create_bin_file(tables_kobj, &bin_attr_rci2); + if (ret != 0) { + pr_debug("RCI2 table - rci2 sysfs bin file creation failed\n"); + kobject_del(tables_kobj); + kobject_put(tables_kobj); + goto err_unmap; + } + + return 0; + + err_unmap: + memunmap(rci2_base); + err: + pr_debug("RCI2 table - sysfs initialization failed\n"); + return ret; +} +late_initcall(efi_rci2_sysfs_init); diff --git a/include/linux/efi.h b/include/linux/efi.h index f88318b85fb0..bd3837022307 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -692,6 +692,9 @@ void efi_native_runtime_setup(void); #define LINUX_EFI_TPM_FINAL_LOG_GUID EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25) #define LINUX_EFI_MEMRESERVE_TABLE_GUID EFI_GUID(0x888eb0c6, 0x8ede, 0x4ff5, 0xa8, 0xf0, 0x9a, 0xee, 0x5c, 0xb9, 0x77, 0xc2) +/* OEM GUIDs */ +#define DELLEMC_EFI_RCI2_TABLE_GUID EFI_GUID(0x2d9f28a2, 0xa886, 0x456a, 0x97, 0xa8, 0xf1, 0x1e, 0xf2, 0x4f, 0xf4, 0x55) + typedef struct { efi_guid_t guid; u64 table; @@ -1713,6 +1716,8 @@ struct efi_tcg2_final_events_table { }; extern int efi_tpm_final_log_size; +extern unsigned long rci2_table_phys; + /* * efi_runtime_service() function identifiers. * "NONE" is used by efi_recover_from_page_fault() to check if the page