diff options
Diffstat (limited to 'arch/x86/platform/efi/efi.c')
-rw-r--r-- | arch/x86/platform/efi/efi.c | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 4d320b290ce0..bef999163dc9 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c @@ -49,9 +49,6 @@ #define EFI_DEBUG 1 #define PFX "EFI: " -int efi_enabled; -EXPORT_SYMBOL(efi_enabled); - struct efi __read_mostly efi = { .mps = EFI_INVALID_TABLE_ADDR, .acpi = EFI_INVALID_TABLE_ADDR, @@ -70,9 +67,25 @@ struct efi_memory_map memmap; static struct efi efi_phys __initdata; static efi_system_table_t efi_systab __initdata; +static inline bool efi_is_native(void) +{ + return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT); +} + +unsigned long x86_efi_facility; + +/* + * Returns 1 if 'facility' is enabled, 0 otherwise. + */ +int efi_enabled(int facility) +{ + return test_bit(facility, &x86_efi_facility) != 0; +} +EXPORT_SYMBOL(efi_enabled); + static int __init setup_noefi(char *arg) { - efi_enabled = 0; + clear_bit(EFI_BOOT, &x86_efi_facility); return 0; } early_param("noefi", setup_noefi); @@ -440,6 +453,9 @@ void __init efi_init(void) int i = 0; void *tmp; + if (!efi_is_native()) + return; + #ifdef CONFIG_X86_32 efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab; #else @@ -467,6 +483,8 @@ void __init efi_init(void) efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff); + set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility); + /* * Show what we know for posterity */ @@ -529,6 +547,8 @@ void __init efi_init(void) early_iounmap(config_tables, efi.systab->nr_tables * sizeof(efi_config_table_t)); + set_bit(EFI_CONFIG_TABLES, &x86_efi_facility); + /* * Check out the runtime services table. We need to map * the runtime services table so that we can grab the physical @@ -552,6 +572,8 @@ void __init efi_init(void) * virtual mode. */ efi.get_time = phys_efi_get_time; + + set_bit(EFI_RUNTIME_SERVICES, &x86_efi_facility); } else printk(KERN_ERR "Could not map the EFI runtime service " "table!\n"); @@ -571,6 +593,8 @@ void __init efi_init(void) if (add_efi_memmap) do_add_efi_memmap(); + set_bit(EFI_MEMMAP, &x86_efi_facility); + #ifdef CONFIG_X86_32 x86_platform.get_wallclock = efi_get_time; x86_platform.set_wallclock = efi_set_rtc_mmss; @@ -731,7 +755,7 @@ void __init efi_enter_virtual_mode(void) * * Call EFI services through wrapper functions. */ - efi.runtime_version = efi_systab.fw_revision; + efi.runtime_version = efi_systab.hdr.revision; efi.get_time = virt_efi_get_time; efi.set_time = virt_efi_set_time; efi.get_wakeup_time = virt_efi_get_wakeup_time; @@ -747,6 +771,7 @@ void __init efi_enter_virtual_mode(void) efi.query_capsule_caps = virt_efi_query_capsule_caps; if (__supported_pte_mask & _PAGE_NX) runtime_code_page_mkexec(); + clear_bit(EFI_MEMMAP, &x86_efi_facility); early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); memmap.map = NULL; kfree(new_memmap); @@ -760,6 +785,9 @@ u32 efi_mem_type(unsigned long phys_addr) efi_memory_desc_t *md; void *p; + if (!efi_enabled(EFI_MEMMAP)) + return 0; + for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { md = p; if ((md->phys_addr <= phys_addr) && |