diff options
| -rw-r--r-- | arch/x86/include/asm/efi.h | 1 | ||||
| -rw-r--r-- | arch/x86/kernel/reboot.c | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/setup.c | 28 | ||||
| -rw-r--r-- | arch/x86/platform/efi/efi.c | 57 | ||||
| -rw-r--r-- | drivers/acpi/osl.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/dmi_scan.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efivars.c | 4 | ||||
| -rw-r--r-- | drivers/firmware/iscsi_ibft_find.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/radeon/radeon_device.c | 3 | ||||
| -rw-r--r-- | drivers/platform/x86/ibm_rtl.c | 2 | ||||
| -rw-r--r-- | drivers/scsi/isci/init.c | 2 | ||||
| -rw-r--r-- | include/linux/efi.h | 24 | ||||
| -rw-r--r-- | init/main.c | 4 |
13 files changed, 79 insertions, 54 deletions
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h index 6e8fdf5ad113..28677c55113f 100644 --- a/arch/x86/include/asm/efi.h +++ b/arch/x86/include/asm/efi.h | |||
| @@ -94,6 +94,7 @@ extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size, | |||
| 94 | #endif /* CONFIG_X86_32 */ | 94 | #endif /* CONFIG_X86_32 */ |
| 95 | 95 | ||
| 96 | extern int add_efi_memmap; | 96 | extern int add_efi_memmap; |
| 97 | extern unsigned long x86_efi_facility; | ||
| 97 | extern void efi_set_executable(efi_memory_desc_t *md, bool executable); | 98 | extern void efi_set_executable(efi_memory_desc_t *md, bool executable); |
| 98 | extern int efi_memblock_x86_reserve_range(void); | 99 | extern int efi_memblock_x86_reserve_range(void); |
| 99 | extern void efi_call_phys_prelog(void); | 100 | extern void efi_call_phys_prelog(void); |
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index 4e8ba39eaf0f..76fa1e9a2b39 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c | |||
| @@ -584,7 +584,7 @@ static void native_machine_emergency_restart(void) | |||
| 584 | break; | 584 | break; |
| 585 | 585 | ||
| 586 | case BOOT_EFI: | 586 | case BOOT_EFI: |
| 587 | if (efi_enabled) | 587 | if (efi_enabled(EFI_RUNTIME_SERVICES)) |
| 588 | efi.reset_system(reboot_mode ? | 588 | efi.reset_system(reboot_mode ? |
| 589 | EFI_RESET_WARM : | 589 | EFI_RESET_WARM : |
| 590 | EFI_RESET_COLD, | 590 | EFI_RESET_COLD, |
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 00f6c1472b85..8b24289cc10c 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
| @@ -807,15 +807,15 @@ void __init setup_arch(char **cmdline_p) | |||
| 807 | #ifdef CONFIG_EFI | 807 | #ifdef CONFIG_EFI |
| 808 | if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, | 808 | if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, |
| 809 | "EL32", 4)) { | 809 | "EL32", 4)) { |
| 810 | efi_enabled = 1; | 810 | set_bit(EFI_BOOT, &x86_efi_facility); |
| 811 | efi_64bit = false; | ||
| 812 | } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, | 811 | } else if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, |
| 813 | "EL64", 4)) { | 812 | "EL64", 4)) { |
| 814 | efi_enabled = 1; | 813 | set_bit(EFI_BOOT, &x86_efi_facility); |
| 815 | efi_64bit = true; | 814 | set_bit(EFI_64BIT, &x86_efi_facility); |
| 816 | } | 815 | } |
| 817 | if (efi_enabled && efi_memblock_x86_reserve_range()) | 816 | |
| 818 | efi_enabled = 0; | 817 | if (efi_enabled(EFI_BOOT)) |
| 818 | efi_memblock_x86_reserve_range(); | ||
| 819 | #endif | 819 | #endif |
| 820 | 820 | ||
| 821 | x86_init.oem.arch_setup(); | 821 | x86_init.oem.arch_setup(); |
| @@ -888,7 +888,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 888 | 888 | ||
| 889 | finish_e820_parsing(); | 889 | finish_e820_parsing(); |
| 890 | 890 | ||
| 891 | if (efi_enabled) | 891 | if (efi_enabled(EFI_BOOT)) |
| 892 | efi_init(); | 892 | efi_init(); |
| 893 | 893 | ||
| 894 | dmi_scan_machine(); | 894 | dmi_scan_machine(); |
| @@ -971,7 +971,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 971 | * The EFI specification says that boot service code won't be called | 971 | * The EFI specification says that boot service code won't be called |
| 972 | * after ExitBootServices(). This is, in fact, a lie. | 972 | * after ExitBootServices(). This is, in fact, a lie. |
| 973 | */ | 973 | */ |
| 974 | if (efi_enabled) | 974 | if (efi_enabled(EFI_MEMMAP)) |
| 975 | efi_reserve_boot_services(); | 975 | efi_reserve_boot_services(); |
| 976 | 976 | ||
| 977 | /* preallocate 4k for mptable mpc */ | 977 | /* preallocate 4k for mptable mpc */ |
| @@ -1114,7 +1114,7 @@ void __init setup_arch(char **cmdline_p) | |||
| 1114 | 1114 | ||
| 1115 | #ifdef CONFIG_VT | 1115 | #ifdef CONFIG_VT |
| 1116 | #if defined(CONFIG_VGA_CONSOLE) | 1116 | #if defined(CONFIG_VGA_CONSOLE) |
| 1117 | if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) | 1117 | if (!efi_enabled(EFI_BOOT) || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) |
| 1118 | conswitchp = &vga_con; | 1118 | conswitchp = &vga_con; |
| 1119 | #elif defined(CONFIG_DUMMY_CONSOLE) | 1119 | #elif defined(CONFIG_DUMMY_CONSOLE) |
| 1120 | conswitchp = &dummy_con; | 1120 | conswitchp = &dummy_con; |
| @@ -1131,14 +1131,14 @@ void __init setup_arch(char **cmdline_p) | |||
| 1131 | register_refined_jiffies(CLOCK_TICK_RATE); | 1131 | register_refined_jiffies(CLOCK_TICK_RATE); |
| 1132 | 1132 | ||
| 1133 | #ifdef CONFIG_EFI | 1133 | #ifdef CONFIG_EFI |
| 1134 | /* Once setup is done above, disable efi_enabled on mismatched | 1134 | /* Once setup is done above, unmap the EFI memory map on |
| 1135 | * firmware/kernel archtectures since there is no support for | 1135 | * mismatched firmware/kernel archtectures since there is no |
| 1136 | * runtime services. | 1136 | * support for runtime services. |
| 1137 | */ | 1137 | */ |
| 1138 | if (efi_enabled && IS_ENABLED(CONFIG_X86_64) != efi_64bit) { | 1138 | if (efi_enabled(EFI_BOOT) && |
| 1139 | IS_ENABLED(CONFIG_X86_64) != efi_enabled(EFI_64BIT)) { | ||
| 1139 | pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n"); | 1140 | pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n"); |
| 1140 | efi_unmap_memmap(); | 1141 | efi_unmap_memmap(); |
| 1141 | efi_enabled = 0; | ||
| 1142 | } | 1142 | } |
| 1143 | #endif | 1143 | #endif |
| 1144 | } | 1144 | } |
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index ad4439145f85..5426e482db6e 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
| @@ -51,9 +51,6 @@ | |||
| 51 | 51 | ||
| 52 | #define EFI_DEBUG 1 | 52 | #define EFI_DEBUG 1 |
| 53 | 53 | ||
| 54 | int efi_enabled; | ||
| 55 | EXPORT_SYMBOL(efi_enabled); | ||
| 56 | |||
| 57 | struct efi __read_mostly efi = { | 54 | struct efi __read_mostly efi = { |
| 58 | .mps = EFI_INVALID_TABLE_ADDR, | 55 | .mps = EFI_INVALID_TABLE_ADDR, |
| 59 | .acpi = EFI_INVALID_TABLE_ADDR, | 56 | .acpi = EFI_INVALID_TABLE_ADDR, |
| @@ -69,19 +66,28 @@ EXPORT_SYMBOL(efi); | |||
| 69 | 66 | ||
| 70 | struct efi_memory_map memmap; | 67 | struct efi_memory_map memmap; |
| 71 | 68 | ||
| 72 | bool efi_64bit; | ||
| 73 | |||
| 74 | static struct efi efi_phys __initdata; | 69 | static struct efi efi_phys __initdata; |
| 75 | static efi_system_table_t efi_systab __initdata; | 70 | static efi_system_table_t efi_systab __initdata; |
| 76 | 71 | ||
| 77 | static inline bool efi_is_native(void) | 72 | static inline bool efi_is_native(void) |
| 78 | { | 73 | { |
| 79 | return IS_ENABLED(CONFIG_X86_64) == efi_64bit; | 74 | return IS_ENABLED(CONFIG_X86_64) == efi_enabled(EFI_64BIT); |
| 75 | } | ||
| 76 | |||
| 77 | unsigned long x86_efi_facility; | ||
| 78 | |||
| 79 | /* | ||
| 80 | * Returns 1 if 'facility' is enabled, 0 otherwise. | ||
| 81 | */ | ||
| 82 | int efi_enabled(int facility) | ||
| 83 | { | ||
| 84 | return test_bit(facility, &x86_efi_facility) != 0; | ||
| 80 | } | 85 | } |
| 86 | EXPORT_SYMBOL(efi_enabled); | ||
| 81 | 87 | ||
| 82 | static int __init setup_noefi(char *arg) | 88 | static int __init setup_noefi(char *arg) |
| 83 | { | 89 | { |
| 84 | efi_enabled = 0; | 90 | clear_bit(EFI_BOOT, &x86_efi_facility); |
| 85 | return 0; | 91 | return 0; |
| 86 | } | 92 | } |
| 87 | early_param("noefi", setup_noefi); | 93 | early_param("noefi", setup_noefi); |
| @@ -426,6 +432,7 @@ void __init efi_reserve_boot_services(void) | |||
| 426 | 432 | ||
| 427 | void __init efi_unmap_memmap(void) | 433 | void __init efi_unmap_memmap(void) |
| 428 | { | 434 | { |
| 435 | clear_bit(EFI_MEMMAP, &x86_efi_facility); | ||
| 429 | if (memmap.map) { | 436 | if (memmap.map) { |
| 430 | early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); | 437 | early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); |
| 431 | memmap.map = NULL; | 438 | memmap.map = NULL; |
| @@ -460,7 +467,7 @@ void __init efi_free_boot_services(void) | |||
| 460 | 467 | ||
| 461 | static int __init efi_systab_init(void *phys) | 468 | static int __init efi_systab_init(void *phys) |
| 462 | { | 469 | { |
| 463 | if (efi_64bit) { | 470 | if (efi_enabled(EFI_64BIT)) { |
| 464 | efi_system_table_64_t *systab64; | 471 | efi_system_table_64_t *systab64; |
| 465 | u64 tmp = 0; | 472 | u64 tmp = 0; |
| 466 | 473 | ||
| @@ -552,7 +559,7 @@ static int __init efi_config_init(u64 tables, int nr_tables) | |||
| 552 | void *config_tables, *tablep; | 559 | void *config_tables, *tablep; |
| 553 | int i, sz; | 560 | int i, sz; |
| 554 | 561 | ||
| 555 | if (efi_64bit) | 562 | if (efi_enabled(EFI_64BIT)) |
| 556 | sz = sizeof(efi_config_table_64_t); | 563 | sz = sizeof(efi_config_table_64_t); |
| 557 | else | 564 | else |
| 558 | sz = sizeof(efi_config_table_32_t); | 565 | sz = sizeof(efi_config_table_32_t); |
| @@ -572,7 +579,7 @@ static int __init efi_config_init(u64 tables, int nr_tables) | |||
| 572 | efi_guid_t guid; | 579 | efi_guid_t guid; |
| 573 | unsigned long table; | 580 | unsigned long table; |
| 574 | 581 | ||
| 575 | if (efi_64bit) { | 582 | if (efi_enabled(EFI_64BIT)) { |
| 576 | u64 table64; | 583 | u64 table64; |
| 577 | guid = ((efi_config_table_64_t *)tablep)->guid; | 584 | guid = ((efi_config_table_64_t *)tablep)->guid; |
| 578 | table64 = ((efi_config_table_64_t *)tablep)->table; | 585 | table64 = ((efi_config_table_64_t *)tablep)->table; |
| @@ -684,7 +691,6 @@ void __init efi_init(void) | |||
| 684 | if (boot_params.efi_info.efi_systab_hi || | 691 | if (boot_params.efi_info.efi_systab_hi || |
| 685 | boot_params.efi_info.efi_memmap_hi) { | 692 | boot_params.efi_info.efi_memmap_hi) { |
| 686 | pr_info("Table located above 4GB, disabling EFI.\n"); | 693 | pr_info("Table located above 4GB, disabling EFI.\n"); |
| 687 | efi_enabled = 0; | ||
| 688 | return; | 694 | return; |
| 689 | } | 695 | } |
| 690 | efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab; | 696 | efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab; |
| @@ -694,10 +700,10 @@ void __init efi_init(void) | |||
| 694 | ((__u64)boot_params.efi_info.efi_systab_hi<<32)); | 700 | ((__u64)boot_params.efi_info.efi_systab_hi<<32)); |
| 695 | #endif | 701 | #endif |
| 696 | 702 | ||
| 697 | if (efi_systab_init(efi_phys.systab)) { | 703 | if (efi_systab_init(efi_phys.systab)) |
| 698 | efi_enabled = 0; | ||
| 699 | return; | 704 | return; |
| 700 | } | 705 | |
| 706 | set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility); | ||
| 701 | 707 | ||
| 702 | /* | 708 | /* |
| 703 | * Show what we know for posterity | 709 | * Show what we know for posterity |
| @@ -715,10 +721,10 @@ void __init efi_init(void) | |||
| 715 | efi.systab->hdr.revision >> 16, | 721 | efi.systab->hdr.revision >> 16, |
| 716 | efi.systab->hdr.revision & 0xffff, vendor); | 722 | efi.systab->hdr.revision & 0xffff, vendor); |
| 717 | 723 | ||
| 718 | if (efi_config_init(efi.systab->tables, efi.systab->nr_tables)) { | 724 | if (efi_config_init(efi.systab->tables, efi.systab->nr_tables)) |
| 719 | efi_enabled = 0; | ||
| 720 | return; | 725 | return; |
| 721 | } | 726 | |
| 727 | set_bit(EFI_CONFIG_TABLES, &x86_efi_facility); | ||
| 722 | 728 | ||
| 723 | /* | 729 | /* |
| 724 | * Note: We currently don't support runtime services on an EFI | 730 | * Note: We currently don't support runtime services on an EFI |
| @@ -727,15 +733,17 @@ void __init efi_init(void) | |||
| 727 | 733 | ||
| 728 | if (!efi_is_native()) | 734 | if (!efi_is_native()) |
| 729 | pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n"); | 735 | pr_info("No EFI runtime due to 32/64-bit mismatch with kernel\n"); |
| 730 | else if (efi_runtime_init()) { | 736 | else { |
| 731 | efi_enabled = 0; | 737 | if (efi_runtime_init()) |
| 732 | return; | 738 | return; |
| 739 | set_bit(EFI_RUNTIME_SERVICES, &x86_efi_facility); | ||
| 733 | } | 740 | } |
| 734 | 741 | ||
| 735 | if (efi_memmap_init()) { | 742 | if (efi_memmap_init()) |
| 736 | efi_enabled = 0; | ||
| 737 | return; | 743 | return; |
| 738 | } | 744 | |
| 745 | set_bit(EFI_MEMMAP, &x86_efi_facility); | ||
| 746 | |||
| 739 | #ifdef CONFIG_X86_32 | 747 | #ifdef CONFIG_X86_32 |
| 740 | if (efi_is_native()) { | 748 | if (efi_is_native()) { |
| 741 | x86_platform.get_wallclock = efi_get_time; | 749 | x86_platform.get_wallclock = efi_get_time; |
| @@ -969,6 +977,9 @@ u32 efi_mem_type(unsigned long phys_addr) | |||
| 969 | efi_memory_desc_t *md; | 977 | efi_memory_desc_t *md; |
| 970 | void *p; | 978 | void *p; |
| 971 | 979 | ||
| 980 | if (!efi_enabled(EFI_MEMMAP)) | ||
| 981 | return 0; | ||
| 982 | |||
| 972 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { | 983 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { |
| 973 | md = p; | 984 | md = p; |
| 974 | if ((md->phys_addr <= phys_addr) && | 985 | if ((md->phys_addr <= phys_addr) && |
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index 3ff267861541..bd22f8667eed 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
| @@ -250,7 +250,7 @@ acpi_physical_address __init acpi_os_get_root_pointer(void) | |||
| 250 | return acpi_rsdp; | 250 | return acpi_rsdp; |
| 251 | #endif | 251 | #endif |
| 252 | 252 | ||
| 253 | if (efi_enabled) { | 253 | if (efi_enabled(EFI_CONFIG_TABLES)) { |
| 254 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) | 254 | if (efi.acpi20 != EFI_INVALID_TABLE_ADDR) |
| 255 | return efi.acpi20; | 255 | return efi.acpi20; |
| 256 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) | 256 | else if (efi.acpi != EFI_INVALID_TABLE_ADDR) |
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index fd3ae6290d71..982f1f5f5742 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
| @@ -471,7 +471,7 @@ void __init dmi_scan_machine(void) | |||
| 471 | char __iomem *p, *q; | 471 | char __iomem *p, *q; |
| 472 | int rc; | 472 | int rc; |
| 473 | 473 | ||
| 474 | if (efi_enabled) { | 474 | if (efi_enabled(EFI_CONFIG_TABLES)) { |
| 475 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) | 475 | if (efi.smbios == EFI_INVALID_TABLE_ADDR) |
| 476 | goto error; | 476 | goto error; |
| 477 | 477 | ||
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 7b1c37497c9a..1065119dff92 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
| @@ -1782,7 +1782,7 @@ efivars_init(void) | |||
| 1782 | printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION, | 1782 | printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION, |
| 1783 | EFIVARS_DATE); | 1783 | EFIVARS_DATE); |
| 1784 | 1784 | ||
| 1785 | if (!efi_enabled) | 1785 | if (!efi_enabled(EFI_RUNTIME_SERVICES)) |
| 1786 | return 0; | 1786 | return 0; |
| 1787 | 1787 | ||
| 1788 | /* For now we'll register the efi directory at /sys/firmware/efi */ | 1788 | /* For now we'll register the efi directory at /sys/firmware/efi */ |
| @@ -1822,7 +1822,7 @@ err_put: | |||
| 1822 | static void __exit | 1822 | static void __exit |
| 1823 | efivars_exit(void) | 1823 | efivars_exit(void) |
| 1824 | { | 1824 | { |
| 1825 | if (efi_enabled) { | 1825 | if (efi_enabled(EFI_RUNTIME_SERVICES)) { |
| 1826 | unregister_efivars(&__efivars); | 1826 | unregister_efivars(&__efivars); |
| 1827 | kobject_put(efi_kobj); | 1827 | kobject_put(efi_kobj); |
| 1828 | } | 1828 | } |
diff --git a/drivers/firmware/iscsi_ibft_find.c b/drivers/firmware/iscsi_ibft_find.c index 4da4eb9ae926..2224f1dc074b 100644 --- a/drivers/firmware/iscsi_ibft_find.c +++ b/drivers/firmware/iscsi_ibft_find.c | |||
| @@ -99,7 +99,7 @@ unsigned long __init find_ibft_region(unsigned long *sizep) | |||
| 99 | /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will | 99 | /* iBFT 1.03 section 1.4.3.1 mandates that UEFI machines will |
| 100 | * only use ACPI for this */ | 100 | * only use ACPI for this */ |
| 101 | 101 | ||
| 102 | if (!efi_enabled) | 102 | if (!efi_enabled(EFI_BOOT)) |
| 103 | find_ibft_in_mem(); | 103 | find_ibft_in_mem(); |
| 104 | 104 | ||
| 105 | if (ibft_addr) { | 105 | if (ibft_addr) { |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index edfc54e41842..0d6562bb0c93 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
| @@ -429,7 +429,8 @@ bool radeon_card_posted(struct radeon_device *rdev) | |||
| 429 | { | 429 | { |
| 430 | uint32_t reg; | 430 | uint32_t reg; |
| 431 | 431 | ||
| 432 | if (efi_enabled && rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) | 432 | if (efi_enabled(EFI_BOOT) && |
| 433 | rdev->pdev->subsystem_vendor == PCI_VENDOR_ID_APPLE) | ||
| 433 | return false; | 434 | return false; |
| 434 | 435 | ||
| 435 | /* first check CRTCs */ | 436 | /* first check CRTCs */ |
diff --git a/drivers/platform/x86/ibm_rtl.c b/drivers/platform/x86/ibm_rtl.c index 7481146a5b47..97c2be195efc 100644 --- a/drivers/platform/x86/ibm_rtl.c +++ b/drivers/platform/x86/ibm_rtl.c | |||
| @@ -244,7 +244,7 @@ static int __init ibm_rtl_init(void) { | |||
| 244 | if (force) | 244 | if (force) |
| 245 | pr_warn("module loaded by force\n"); | 245 | pr_warn("module loaded by force\n"); |
| 246 | /* first ensure that we are running on IBM HW */ | 246 | /* first ensure that we are running on IBM HW */ |
| 247 | else if (efi_enabled || !dmi_check_system(ibm_rtl_dmi_table)) | 247 | else if (efi_enabled(EFI_BOOT) || !dmi_check_system(ibm_rtl_dmi_table)) |
| 248 | return -ENODEV; | 248 | return -ENODEV; |
| 249 | 249 | ||
| 250 | /* Get the address for the Extended BIOS Data Area */ | 250 | /* Get the address for the Extended BIOS Data Area */ |
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index d73fdcfeb45a..2839baa82a5a 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c | |||
| @@ -633,7 +633,7 @@ static int isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
| 633 | return -ENOMEM; | 633 | return -ENOMEM; |
| 634 | pci_set_drvdata(pdev, pci_info); | 634 | pci_set_drvdata(pdev, pci_info); |
| 635 | 635 | ||
| 636 | if (efi_enabled) | 636 | if (efi_enabled(EFI_RUNTIME_SERVICES)) |
| 637 | orom = isci_get_efi_var(pdev); | 637 | orom = isci_get_efi_var(pdev); |
| 638 | 638 | ||
| 639 | if (!orom) | 639 | if (!orom) |
diff --git a/include/linux/efi.h b/include/linux/efi.h index 8b84916dc671..7a9498ab3c2d 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h | |||
| @@ -618,18 +618,30 @@ extern int __init efi_setup_pcdp_console(char *); | |||
| 618 | #endif | 618 | #endif |
| 619 | 619 | ||
| 620 | /* | 620 | /* |
| 621 | * We play games with efi_enabled so that the compiler will, if possible, remove | 621 | * We play games with efi_enabled so that the compiler will, if |
| 622 | * EFI-related code altogether. | 622 | * possible, remove EFI-related code altogether. |
| 623 | */ | 623 | */ |
| 624 | #define EFI_BOOT 0 /* Were we booted from EFI? */ | ||
| 625 | #define EFI_SYSTEM_TABLES 1 /* Can we use EFI system tables? */ | ||
| 626 | #define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */ | ||
| 627 | #define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */ | ||
| 628 | #define EFI_MEMMAP 4 /* Can we use EFI memory map? */ | ||
| 629 | #define EFI_64BIT 5 /* Is the firmware 64-bit? */ | ||
| 630 | |||
| 624 | #ifdef CONFIG_EFI | 631 | #ifdef CONFIG_EFI |
| 625 | # ifdef CONFIG_X86 | 632 | # ifdef CONFIG_X86 |
| 626 | extern int efi_enabled; | 633 | extern int efi_enabled(int facility); |
| 627 | extern bool efi_64bit; | ||
| 628 | # else | 634 | # else |
| 629 | # define efi_enabled 1 | 635 | static inline int efi_enabled(int facility) |
| 636 | { | ||
| 637 | return 1; | ||
| 638 | } | ||
| 630 | # endif | 639 | # endif |
| 631 | #else | 640 | #else |
| 632 | # define efi_enabled 0 | 641 | static inline int efi_enabled(int facility) |
| 642 | { | ||
| 643 | return 0; | ||
| 644 | } | ||
| 633 | #endif | 645 | #endif |
| 634 | 646 | ||
| 635 | /* | 647 | /* |
diff --git a/init/main.c b/init/main.c index 85d69dffe864..cd30179c86bd 100644 --- a/init/main.c +++ b/init/main.c | |||
| @@ -604,7 +604,7 @@ asmlinkage void __init start_kernel(void) | |||
| 604 | pidmap_init(); | 604 | pidmap_init(); |
| 605 | anon_vma_init(); | 605 | anon_vma_init(); |
| 606 | #ifdef CONFIG_X86 | 606 | #ifdef CONFIG_X86 |
| 607 | if (efi_enabled) | 607 | if (efi_enabled(EFI_RUNTIME_SERVICES)) |
| 608 | efi_enter_virtual_mode(); | 608 | efi_enter_virtual_mode(); |
| 609 | #endif | 609 | #endif |
| 610 | thread_info_cache_init(); | 610 | thread_info_cache_init(); |
| @@ -632,7 +632,7 @@ asmlinkage void __init start_kernel(void) | |||
| 632 | acpi_early_init(); /* before LAPIC and SMP init */ | 632 | acpi_early_init(); /* before LAPIC and SMP init */ |
| 633 | sfi_init_late(); | 633 | sfi_init_late(); |
| 634 | 634 | ||
| 635 | if (efi_enabled) { | 635 | if (efi_enabled(EFI_RUNTIME_SERVICES)) { |
| 636 | efi_late_init(); | 636 | efi_late_init(); |
| 637 | efi_free_boot_services(); | 637 | efi_free_boot_services(); |
| 638 | } | 638 | } |
