efi: Make 'efi_enabled' a function to query EFI facilities

Originally 'efi_enabled' indicated whether a kernel was booted from
EFI firmware. Over time its semantics have changed, and it now
indicates whether or not we are booted on an EFI machine with
bit-native firmware, e.g. 64-bit kernel with 64-bit firmware.

The immediate motivation for this patch is the bug report at,

    https://bugs.launchpad.net/ubuntu-cdimage/+bug/1040557

which details how running a platform driver on an EFI machine that is
designed to run under BIOS can cause the machine to become
bricked. Also, the following report,

    https://bugzilla.kernel.org/show_bug.cgi?id=47121

details how running said driver can also cause Machine Check
Exceptions. Drivers need a new means of detecting whether they're
running on an EFI machine, as sadly the expression,

    if (!efi_enabled)

hasn't been a sufficient condition for quite some time.

Users actually want to query 'efi_enabled' for different reasons -
what they really want access to is the list of available EFI
facilities.

For instance, the x86 reboot code needs to know whether it can invoke
the ResetSystem() function provided by the EFI runtime services, while
the ACPI OSL code wants to know whether the EFI config tables were
mapped successfully. There are also checks in some of the platform
driver code to simply see if they're running on an EFI machine (which
would make it a bad idea to do BIOS-y things).

This patch is a prereq for the samsung-laptop fix patch.

Cc: David Airlie <[email protected]>
Cc: Corentin Chary <[email protected]>
Cc: Matthew Garrett <[email protected]>
Cc: Dave Jiang <[email protected]>
Cc: Olof Johansson <[email protected]>
Cc: Peter Jones <[email protected]>
Cc: Colin Ian King <[email protected]>
Cc: Steve Langasek <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Rafael J. Wysocki <[email protected]>
Cc: <[email protected]>
Signed-off-by: Matt Fleming <[email protected]>
Signed-off-by: H. Peter Anvin <[email protected]>
This commit is contained in:
Matt Fleming 2012-11-14 09:42:35 +00:00 • committed by H. Peter Anvin
commit 83e6818974
13 changed files with 79 additions and 54 deletions

View file

@ -604,7 +604,7 @@ asmlinkage void __init start_kernel(void)
pidmap_init();
anon_vma_init();
#ifdef CONFIG_X86
if (efi_enabled)
if (efi_enabled(EFI_RUNTIME_SERVICES))
efi_enter_virtual_mode();
#endif
thread_info_cache_init();
@ -632,7 +632,7 @@ asmlinkage void __init start_kernel(void)
acpi_early_init(); /* before LAPIC and SMP init */
sfi_init_late();
if (efi_enabled) {
if (efi_enabled(EFI_RUNTIME_SERVICES)) {
efi_late_init();
efi_free_boot_services();
}