Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a19d66c5 authored by Tom Lendacky's avatar Tom Lendacky Committed by Ingo Molnar
Browse files

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: default avatarTom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
Reviewed-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
Reviewed-by: default avatarBorislav 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: default avatarIngo Molnar <mingo@kernel.org>
parent d68baa3f
Loading
Loading
Loading
Loading
+33 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,25 @@ struct efi __read_mostly efi = {
};
};
EXPORT_SYMBOL(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 bool disable_runtime;
static int __init setup_noefi(char *arg)
static int __init setup_noefi(char *arg)
{
{
@@ -855,6 +874,20 @@ int efi_status_to_err(efi_status_t status)
	return err;
	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
#ifdef CONFIG_KEXEC
static int update_efi_random_seed(struct notifier_block *nb,
static int update_efi_random_seed(struct notifier_block *nb,
				  unsigned long code, void *unused)
				  unsigned long code, void *unused)
+7 −0
Original line number Original line Diff line number Diff line
@@ -1091,6 +1091,8 @@ static inline bool efi_enabled(int feature)
	return test_bit(feature, &efi.flags) != 0;
	return test_bit(feature, &efi.flags) != 0;
}
}
extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);
extern void efi_reboot(enum reboot_mode reboot_mode, const char *__unused);

extern bool efi_is_table_address(unsigned long phys_addr);
#else
#else
static inline bool efi_enabled(int feature)
static inline bool efi_enabled(int feature)
{
{
@@ -1104,6 +1106,11 @@ efi_capsule_pending(int *reset_type)
{
{
	return false;
	return false;
}
}

static inline bool efi_is_table_address(unsigned long phys_addr)
{
	return false;
}
#endif
#endif


extern int efi_status_to_err(efi_status_t status);
extern int efi_status_to_err(efi_status_t status);