]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
efi: Add an EFI table address match function
authorTom Lendacky <thomas.lendacky@amd.com>
Mon, 17 Jul 2017 21:10:13 +0000 (16:10 -0500)
committerIngo Molnar <mingo@kernel.org>
Tue, 18 Jul 2017 09:38:01 +0000 (11:38 +0200)
Add a function that will determine if a supplied physical address matches
the address of an EFI table.

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Matt Fleming <matt@codeblueprint.co.uk>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Larry Woodman <lwoodman@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Toshimitsu Kani <toshi.kani@hpe.com>
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 <mingo@kernel.org>
drivers/firmware/efi/efi.c
include/linux/efi.h

index 045d6d311bde2defc5ebabaf229ff7f71a94f60f..69d4d130e055c28c50155934628a40808e248c00 100644 (file)
@@ -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)
index 8269bcb8ccf7961bd01f52e39fc4d34d370f25d3..8e24f099bd3ffc115804f63e94849c24b75333ab 100644 (file)
@@ -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);