From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752455AbdGRLBL (ORCPT ); Tue, 18 Jul 2017 07:01:11 -0400 Received: from terminus.zytor.com ([65.50.211.136]:42471 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752014AbdGRLBJ (ORCPT ); Tue, 18 Jul 2017 07:01:09 -0400 Date: Tue, 18 Jul 2017 03:53:03 -0700 From: tip-bot for Tom Lendacky Message-ID: Cc: luto@kernel.org, lwoodman@redhat.com, linux-kernel@vger.kernel.org, riel@redhat.com, tglx@linutronix.de, matt@codeblueprint.co.uk, brijesh.singh@amd.com, dvyukov@google.com, konrad.wilk@oracle.com, bp@suse.de, corbet@lwn.net, mingo@kernel.org, rkrcmar@redhat.com, bp@alien8.de, mst@redhat.com, dyoung@redhat.com, glider@google.com, peterz@infradead.org, pbonzini@redhat.com, toshi.kani@hpe.com, torvalds@linux-foundation.org, arnd@arndb.de, hpa@zytor.com, thomas.lendacky@amd.com, aryabinin@virtuozzo.com Reply-To: toshi.kani@hpe.com, pbonzini@redhat.com, mst@redhat.com, dyoung@redhat.com, peterz@infradead.org, glider@google.com, arnd@arndb.de, hpa@zytor.com, aryabinin@virtuozzo.com, thomas.lendacky@amd.com, torvalds@linux-foundation.org, brijesh.singh@amd.com, dvyukov@google.com, luto@kernel.org, lwoodman@redhat.com, riel@redhat.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, matt@codeblueprint.co.uk, rkrcmar@redhat.com, mingo@kernel.org, bp@alien8.de, konrad.wilk@oracle.com, bp@suse.de, corbet@lwn.net In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] efi: Add an EFI table address match function Git-Commit-ID: a19d66c56af1c52b8b463bf94d21116ae8c1aa5a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: a19d66c56af1c52b8b463bf94d21116ae8c1aa5a Gitweb: http://git.kernel.org/tip/a19d66c56af1c52b8b463bf94d21116ae8c1aa5a Author: Tom Lendacky AuthorDate: Mon, 17 Jul 2017 16:10:13 -0500 Committer: Ingo Molnar CommitDate: Tue, 18 Jul 2017 11:38:01 +0200 efi: Add an EFI table address match function Add a function that will determine if a supplied physical address matches the address of an EFI table. Signed-off-by: Tom Lendacky Reviewed-by: Thomas Gleixner Reviewed-by: Matt Fleming Reviewed-by: Borislav Petkov Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Andy Lutomirski Cc: Arnd Bergmann Cc: Borislav Petkov Cc: Brijesh Singh Cc: Dave Young Cc: Dmitry Vyukov Cc: Jonathan Corbet Cc: Konrad Rzeszutek Wilk Cc: Larry Woodman Cc: Linus Torvalds Cc: Michael S. Tsirkin Cc: Paolo Bonzini Cc: Peter Zijlstra Cc: Radim Krčmář Cc: Rik van Riel Cc: Toshimitsu Kani Cc: kasan-dev@googlegroups.com Cc: kvm@vger.kernel.org Cc: linux-arch@vger.kernel.org Cc: linux-doc@vger.kernel.org Cc: linux-efi@vger.kernel.org Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/e1e06441d80f44776df391e0e4cb485b345b7518.1500319216.git.thomas.lendacky@amd.com Signed-off-by: Ingo Molnar --- drivers/firmware/efi/efi.c | 33 +++++++++++++++++++++++++++++++++ include/linux/efi.h | 7 +++++++ 2 files changed, 40 insertions(+) diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 045d6d3..69d4d13 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -55,6 +55,25 @@ 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, +}; + static bool disable_runtime; static int __init setup_noefi(char *arg) { @@ -855,6 +874,20 @@ 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; +} + #ifdef CONFIG_KEXEC static int update_efi_random_seed(struct notifier_block *nb, unsigned long code, void *unused) diff --git a/include/linux/efi.h b/include/linux/efi.h index 8269bcb..8e24f09 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1091,6 +1091,8 @@ 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) { @@ -1104,6 +1106,11 @@ 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);