diff options
Diffstat (limited to 'arch/x86/platform/efi/efi.c')
-rw-r--r-- | arch/x86/platform/efi/efi.c | 315 |
1 files changed, 209 insertions, 106 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c index 395decedfa2b..43e7cf6c6111 100644 --- a/arch/x86/platform/efi/efi.c +++ b/arch/x86/platform/efi/efi.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include <asm/tlbflush.h> | 52 | #include <asm/tlbflush.h> |
53 | #include <asm/x86_init.h> | 53 | #include <asm/x86_init.h> |
54 | #include <asm/rtc.h> | 54 | #include <asm/rtc.h> |
55 | #include <asm/uv/uv.h> | ||
55 | 56 | ||
56 | #define EFI_DEBUG | 57 | #define EFI_DEBUG |
57 | 58 | ||
@@ -67,9 +68,7 @@ struct efi_memory_map memmap; | |||
67 | static struct efi efi_phys __initdata; | 68 | static struct efi efi_phys __initdata; |
68 | static efi_system_table_t efi_systab __initdata; | 69 | static efi_system_table_t efi_systab __initdata; |
69 | 70 | ||
70 | unsigned long x86_efi_facility; | 71 | static efi_config_table_type_t arch_tables[] __initdata = { |
71 | |||
72 | static __initdata efi_config_table_type_t arch_tables[] = { | ||
73 | #ifdef CONFIG_X86_UV | 72 | #ifdef CONFIG_X86_UV |
74 | {UV_SYSTEM_TABLE_GUID, "UVsystab", &efi.uv_systab}, | 73 | {UV_SYSTEM_TABLE_GUID, "UVsystab", &efi.uv_systab}, |
75 | #endif | 74 | #endif |
@@ -78,16 +77,7 @@ static __initdata efi_config_table_type_t arch_tables[] = { | |||
78 | 77 | ||
79 | u64 efi_setup; /* efi setup_data physical address */ | 78 | u64 efi_setup; /* efi setup_data physical address */ |
80 | 79 | ||
81 | /* | 80 | static bool disable_runtime __initdata = false; |
82 | * Returns 1 if 'facility' is enabled, 0 otherwise. | ||
83 | */ | ||
84 | int efi_enabled(int facility) | ||
85 | { | ||
86 | return test_bit(facility, &x86_efi_facility) != 0; | ||
87 | } | ||
88 | EXPORT_SYMBOL(efi_enabled); | ||
89 | |||
90 | static bool __initdata disable_runtime = false; | ||
91 | static int __init setup_noefi(char *arg) | 81 | static int __init setup_noefi(char *arg) |
92 | { | 82 | { |
93 | disable_runtime = true; | 83 | disable_runtime = true; |
@@ -274,9 +264,9 @@ static efi_status_t __init phys_efi_get_time(efi_time_t *tm, | |||
274 | int efi_set_rtc_mmss(const struct timespec *now) | 264 | int efi_set_rtc_mmss(const struct timespec *now) |
275 | { | 265 | { |
276 | unsigned long nowtime = now->tv_sec; | 266 | unsigned long nowtime = now->tv_sec; |
277 | efi_status_t status; | 267 | efi_status_t status; |
278 | efi_time_t eft; | 268 | efi_time_t eft; |
279 | efi_time_cap_t cap; | 269 | efi_time_cap_t cap; |
280 | struct rtc_time tm; | 270 | struct rtc_time tm; |
281 | 271 | ||
282 | status = efi.get_time(&eft, &cap); | 272 | status = efi.get_time(&eft, &cap); |
@@ -294,9 +284,8 @@ int efi_set_rtc_mmss(const struct timespec *now) | |||
294 | eft.second = tm.tm_sec; | 284 | eft.second = tm.tm_sec; |
295 | eft.nanosecond = 0; | 285 | eft.nanosecond = 0; |
296 | } else { | 286 | } else { |
297 | printk(KERN_ERR | 287 | pr_err("%s: Invalid EFI RTC value: write of %lx to EFI RTC failed\n", |
298 | "%s: Invalid EFI RTC value: write of %lx to EFI RTC failed\n", | 288 | __func__, nowtime); |
299 | __FUNCTION__, nowtime); | ||
300 | return -1; | 289 | return -1; |
301 | } | 290 | } |
302 | 291 | ||
@@ -412,8 +401,7 @@ static void __init print_efi_memmap(void) | |||
412 | p < memmap.map_end; | 401 | p < memmap.map_end; |
413 | p += memmap.desc_size, i++) { | 402 | p += memmap.desc_size, i++) { |
414 | md = p; | 403 | md = p; |
415 | pr_info("mem%02u: type=%u, attr=0x%llx, " | 404 | pr_info("mem%02u: type=%u, attr=0x%llx, range=[0x%016llx-0x%016llx) (%lluMB)\n", |
416 | "range=[0x%016llx-0x%016llx) (%lluMB)\n", | ||
417 | i, md->type, md->attribute, md->phys_addr, | 405 | i, md->type, md->attribute, md->phys_addr, |
418 | md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), | 406 | md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT), |
419 | (md->num_pages >> (20 - EFI_PAGE_SHIFT))); | 407 | (md->num_pages >> (20 - EFI_PAGE_SHIFT))); |
@@ -445,9 +433,8 @@ void __init efi_reserve_boot_services(void) | |||
445 | memblock_is_region_reserved(start, size)) { | 433 | memblock_is_region_reserved(start, size)) { |
446 | /* Could not reserve, skip it */ | 434 | /* Could not reserve, skip it */ |
447 | md->num_pages = 0; | 435 | md->num_pages = 0; |
448 | memblock_dbg("Could not reserve boot range " | 436 | memblock_dbg("Could not reserve boot range [0x%010llx-0x%010llx]\n", |
449 | "[0x%010llx-0x%010llx]\n", | 437 | start, start+size-1); |
450 | start, start+size-1); | ||
451 | } else | 438 | } else |
452 | memblock_reserve(start, size); | 439 | memblock_reserve(start, size); |
453 | } | 440 | } |
@@ -455,7 +442,7 @@ void __init efi_reserve_boot_services(void) | |||
455 | 442 | ||
456 | void __init efi_unmap_memmap(void) | 443 | void __init efi_unmap_memmap(void) |
457 | { | 444 | { |
458 | clear_bit(EFI_MEMMAP, &x86_efi_facility); | 445 | clear_bit(EFI_MEMMAP, &efi.flags); |
459 | if (memmap.map) { | 446 | if (memmap.map) { |
460 | early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); | 447 | early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size); |
461 | memmap.map = NULL; | 448 | memmap.map = NULL; |
@@ -580,11 +567,12 @@ static int __init efi_systab_init(void *phys) | |||
580 | return -EINVAL; | 567 | return -EINVAL; |
581 | } | 568 | } |
582 | if ((efi.systab->hdr.revision >> 16) == 0) | 569 | if ((efi.systab->hdr.revision >> 16) == 0) |
583 | pr_err("Warning: System table version " | 570 | pr_err("Warning: System table version %d.%02d, expected 1.00 or greater!\n", |
584 | "%d.%02d, expected 1.00 or greater!\n", | ||
585 | efi.systab->hdr.revision >> 16, | 571 | efi.systab->hdr.revision >> 16, |
586 | efi.systab->hdr.revision & 0xffff); | 572 | efi.systab->hdr.revision & 0xffff); |
587 | 573 | ||
574 | set_bit(EFI_SYSTEM_TABLES, &efi.flags); | ||
575 | |||
588 | return 0; | 576 | return 0; |
589 | } | 577 | } |
590 | 578 | ||
@@ -668,6 +656,8 @@ static int __init efi_runtime_init(void) | |||
668 | if (rv) | 656 | if (rv) |
669 | return rv; | 657 | return rv; |
670 | 658 | ||
659 | set_bit(EFI_RUNTIME_SERVICES, &efi.flags); | ||
660 | |||
671 | return 0; | 661 | return 0; |
672 | } | 662 | } |
673 | 663 | ||
@@ -685,6 +675,8 @@ static int __init efi_memmap_init(void) | |||
685 | if (add_efi_memmap) | 675 | if (add_efi_memmap) |
686 | do_add_efi_memmap(); | 676 | do_add_efi_memmap(); |
687 | 677 | ||
678 | set_bit(EFI_MEMMAP, &efi.flags); | ||
679 | |||
688 | return 0; | 680 | return 0; |
689 | } | 681 | } |
690 | 682 | ||
@@ -767,7 +759,7 @@ void __init efi_init(void) | |||
767 | if (efi_systab_init(efi_phys.systab)) | 759 | if (efi_systab_init(efi_phys.systab)) |
768 | return; | 760 | return; |
769 | 761 | ||
770 | set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility); | 762 | set_bit(EFI_SYSTEM_TABLES, &efi.flags); |
771 | 763 | ||
772 | efi.config_table = (unsigned long)efi.systab->tables; | 764 | efi.config_table = (unsigned long)efi.systab->tables; |
773 | efi.fw_vendor = (unsigned long)efi.systab->fw_vendor; | 765 | efi.fw_vendor = (unsigned long)efi.systab->fw_vendor; |
@@ -795,8 +787,6 @@ void __init efi_init(void) | |||
795 | if (efi_config_init(arch_tables)) | 787 | if (efi_config_init(arch_tables)) |
796 | return; | 788 | return; |
797 | 789 | ||
798 | set_bit(EFI_CONFIG_TABLES, &x86_efi_facility); | ||
799 | |||
800 | /* | 790 | /* |
801 | * Note: We currently don't support runtime services on an EFI | 791 | * Note: We currently don't support runtime services on an EFI |
802 | * that doesn't match the kernel 32/64-bit mode. | 792 | * that doesn't match the kernel 32/64-bit mode. |
@@ -807,12 +797,11 @@ void __init efi_init(void) | |||
807 | else { | 797 | else { |
808 | if (disable_runtime || efi_runtime_init()) | 798 | if (disable_runtime || efi_runtime_init()) |
809 | return; | 799 | return; |
810 | set_bit(EFI_RUNTIME_SERVICES, &x86_efi_facility); | ||
811 | } | 800 | } |
812 | if (efi_memmap_init()) | 801 | if (efi_memmap_init()) |
813 | return; | 802 | return; |
814 | 803 | ||
815 | set_bit(EFI_MEMMAP, &x86_efi_facility); | 804 | set_bit(EFI_MEMMAP, &efi.flags); |
816 | 805 | ||
817 | print_efi_memmap(); | 806 | print_efi_memmap(); |
818 | } | 807 | } |
@@ -952,8 +941,9 @@ static void __init get_systab_virt_addr(efi_memory_desc_t *md) | |||
952 | } | 941 | } |
953 | } | 942 | } |
954 | 943 | ||
955 | static int __init save_runtime_map(void) | 944 | static void __init save_runtime_map(void) |
956 | { | 945 | { |
946 | #ifdef CONFIG_KEXEC | ||
957 | efi_memory_desc_t *md; | 947 | efi_memory_desc_t *md; |
958 | void *tmp, *p, *q = NULL; | 948 | void *tmp, *p, *q = NULL; |
959 | int count = 0; | 949 | int count = 0; |
@@ -975,38 +965,44 @@ static int __init save_runtime_map(void) | |||
975 | } | 965 | } |
976 | 966 | ||
977 | efi_runtime_map_setup(q, count, memmap.desc_size); | 967 | efi_runtime_map_setup(q, count, memmap.desc_size); |
968 | return; | ||
978 | 969 | ||
979 | return 0; | ||
980 | out: | 970 | out: |
981 | kfree(q); | 971 | kfree(q); |
982 | return -ENOMEM; | 972 | pr_err("Error saving runtime map, efi runtime on kexec non-functional!!\n"); |
973 | #endif | ||
983 | } | 974 | } |
984 | 975 | ||
985 | /* | 976 | static void *realloc_pages(void *old_memmap, int old_shift) |
986 | * Map efi regions which were passed via setup_data. The virt_addr is a fixed | ||
987 | * addr which was used in first kernel of a kexec boot. | ||
988 | */ | ||
989 | static void __init efi_map_regions_fixed(void) | ||
990 | { | 977 | { |
991 | void *p; | 978 | void *ret; |
992 | efi_memory_desc_t *md; | ||
993 | 979 | ||
994 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { | 980 | ret = (void *)__get_free_pages(GFP_KERNEL, old_shift + 1); |
995 | md = p; | 981 | if (!ret) |
996 | efi_map_region_fixed(md); /* FIXME: add error handling */ | 982 | goto out; |
997 | get_systab_virt_addr(md); | ||
998 | } | ||
999 | 983 | ||
984 | /* | ||
985 | * A first-time allocation doesn't have anything to copy. | ||
986 | */ | ||
987 | if (!old_memmap) | ||
988 | return ret; | ||
989 | |||
990 | memcpy(ret, old_memmap, PAGE_SIZE << old_shift); | ||
991 | |||
992 | out: | ||
993 | free_pages((unsigned long)old_memmap, old_shift); | ||
994 | return ret; | ||
1000 | } | 995 | } |
1001 | 996 | ||
1002 | /* | 997 | /* |
1003 | * Map efi memory ranges for runtime serivce and update new_memmap with virtual | 998 | * Map the efi memory ranges of the runtime services and update new_mmap with |
1004 | * addresses. | 999 | * virtual addresses. |
1005 | */ | 1000 | */ |
1006 | static void * __init efi_map_regions(int *count) | 1001 | static void * __init efi_map_regions(int *count, int *pg_shift) |
1007 | { | 1002 | { |
1003 | void *p, *new_memmap = NULL; | ||
1004 | unsigned long left = 0; | ||
1008 | efi_memory_desc_t *md; | 1005 | efi_memory_desc_t *md; |
1009 | void *p, *tmp, *new_memmap = NULL; | ||
1010 | 1006 | ||
1011 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { | 1007 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { |
1012 | md = p; | 1008 | md = p; |
@@ -1021,20 +1017,80 @@ static void * __init efi_map_regions(int *count) | |||
1021 | efi_map_region(md); | 1017 | efi_map_region(md); |
1022 | get_systab_virt_addr(md); | 1018 | get_systab_virt_addr(md); |
1023 | 1019 | ||
1024 | tmp = krealloc(new_memmap, (*count + 1) * memmap.desc_size, | 1020 | if (left < memmap.desc_size) { |
1025 | GFP_KERNEL); | 1021 | new_memmap = realloc_pages(new_memmap, *pg_shift); |
1026 | if (!tmp) | 1022 | if (!new_memmap) |
1027 | goto out; | 1023 | return NULL; |
1028 | new_memmap = tmp; | 1024 | |
1025 | left += PAGE_SIZE << *pg_shift; | ||
1026 | (*pg_shift)++; | ||
1027 | } | ||
1028 | |||
1029 | memcpy(new_memmap + (*count * memmap.desc_size), md, | 1029 | memcpy(new_memmap + (*count * memmap.desc_size), md, |
1030 | memmap.desc_size); | 1030 | memmap.desc_size); |
1031 | |||
1032 | left -= memmap.desc_size; | ||
1031 | (*count)++; | 1033 | (*count)++; |
1032 | } | 1034 | } |
1033 | 1035 | ||
1034 | return new_memmap; | 1036 | return new_memmap; |
1035 | out: | 1037 | } |
1036 | kfree(new_memmap); | 1038 | |
1037 | return NULL; | 1039 | static void __init kexec_enter_virtual_mode(void) |
1040 | { | ||
1041 | #ifdef CONFIG_KEXEC | ||
1042 | efi_memory_desc_t *md; | ||
1043 | void *p; | ||
1044 | |||
1045 | efi.systab = NULL; | ||
1046 | |||
1047 | /* | ||
1048 | * We don't do virtual mode, since we don't do runtime services, on | ||
1049 | * non-native EFI | ||
1050 | */ | ||
1051 | if (!efi_is_native()) { | ||
1052 | efi_unmap_memmap(); | ||
1053 | return; | ||
1054 | } | ||
1055 | |||
1056 | /* | ||
1057 | * Map efi regions which were passed via setup_data. The virt_addr is a | ||
1058 | * fixed addr which was used in first kernel of a kexec boot. | ||
1059 | */ | ||
1060 | for (p = memmap.map; p < memmap.map_end; p += memmap.desc_size) { | ||
1061 | md = p; | ||
1062 | efi_map_region_fixed(md); /* FIXME: add error handling */ | ||
1063 | get_systab_virt_addr(md); | ||
1064 | } | ||
1065 | |||
1066 | save_runtime_map(); | ||
1067 | |||
1068 | BUG_ON(!efi.systab); | ||
1069 | |||
1070 | efi_sync_low_kernel_mappings(); | ||
1071 | |||
1072 | /* | ||
1073 | * Now that EFI is in virtual mode, update the function | ||
1074 | * pointers in the runtime service table to the new virtual addresses. | ||
1075 | * | ||
1076 | * Call EFI services through wrapper functions. | ||
1077 | */ | ||
1078 | efi.runtime_version = efi_systab.hdr.revision; | ||
1079 | |||
1080 | native_runtime_setup(); | ||
1081 | |||
1082 | efi.set_virtual_address_map = NULL; | ||
1083 | |||
1084 | if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX)) | ||
1085 | runtime_code_page_mkexec(); | ||
1086 | |||
1087 | /* clean DUMMY object */ | ||
1088 | efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID, | ||
1089 | EFI_VARIABLE_NON_VOLATILE | | ||
1090 | EFI_VARIABLE_BOOTSERVICE_ACCESS | | ||
1091 | EFI_VARIABLE_RUNTIME_ACCESS, | ||
1092 | 0, NULL); | ||
1093 | #endif | ||
1038 | } | 1094 | } |
1039 | 1095 | ||
1040 | /* | 1096 | /* |
@@ -1056,57 +1112,53 @@ out: | |||
1056 | * | 1112 | * |
1057 | * Specially for kexec boot, efi runtime maps in previous kernel should | 1113 | * Specially for kexec boot, efi runtime maps in previous kernel should |
1058 | * be passed in via setup_data. In that case runtime ranges will be mapped | 1114 | * be passed in via setup_data. In that case runtime ranges will be mapped |
1059 | * to the same virtual addresses as the first kernel. | 1115 | * to the same virtual addresses as the first kernel, see |
1116 | * kexec_enter_virtual_mode(). | ||
1060 | */ | 1117 | */ |
1061 | void __init efi_enter_virtual_mode(void) | 1118 | static void __init __efi_enter_virtual_mode(void) |
1062 | { | 1119 | { |
1063 | efi_status_t status; | 1120 | int count = 0, pg_shift = 0; |
1064 | void *new_memmap = NULL; | 1121 | void *new_memmap = NULL; |
1065 | int err, count = 0; | 1122 | efi_status_t status; |
1066 | 1123 | ||
1067 | efi.systab = NULL; | 1124 | efi.systab = NULL; |
1068 | 1125 | ||
1069 | if (efi_setup) { | 1126 | efi_merge_regions(); |
1070 | efi_map_regions_fixed(); | 1127 | new_memmap = efi_map_regions(&count, &pg_shift); |
1071 | } else { | 1128 | if (!new_memmap) { |
1072 | efi_merge_regions(); | 1129 | pr_err("Error reallocating memory, EFI runtime non-functional!\n"); |
1073 | new_memmap = efi_map_regions(&count); | 1130 | return; |
1074 | if (!new_memmap) { | ||
1075 | pr_err("Error reallocating memory, EFI runtime non-functional!\n"); | ||
1076 | return; | ||
1077 | } | ||
1078 | } | 1131 | } |
1079 | 1132 | ||
1080 | err = save_runtime_map(); | 1133 | save_runtime_map(); |
1081 | if (err) | ||
1082 | pr_err("Error saving runtime map, efi runtime on kexec non-functional!!\n"); | ||
1083 | 1134 | ||
1084 | BUG_ON(!efi.systab); | 1135 | BUG_ON(!efi.systab); |
1085 | 1136 | ||
1086 | efi_setup_page_tables(); | 1137 | if (efi_setup_page_tables(__pa(new_memmap), 1 << pg_shift)) |
1087 | efi_sync_low_kernel_mappings(); | 1138 | return; |
1088 | 1139 | ||
1089 | if (!efi_setup) { | 1140 | efi_sync_low_kernel_mappings(); |
1090 | if (efi_is_native()) { | 1141 | efi_dump_pagetable(); |
1091 | status = phys_efi_set_virtual_address_map( | 1142 | |
1092 | memmap.desc_size * count, | 1143 | if (efi_is_native()) { |
1093 | memmap.desc_size, | 1144 | status = phys_efi_set_virtual_address_map( |
1094 | memmap.desc_version, | 1145 | memmap.desc_size * count, |
1095 | (efi_memory_desc_t *)__pa(new_memmap)); | 1146 | memmap.desc_size, |
1096 | } else { | 1147 | memmap.desc_version, |
1097 | status = efi_thunk_set_virtual_address_map( | 1148 | (efi_memory_desc_t *)__pa(new_memmap)); |
1098 | efi_phys.set_virtual_address_map, | 1149 | } else { |
1099 | memmap.desc_size * count, | 1150 | status = efi_thunk_set_virtual_address_map( |
1100 | memmap.desc_size, | 1151 | efi_phys.set_virtual_address_map, |
1101 | memmap.desc_version, | 1152 | memmap.desc_size * count, |
1102 | (efi_memory_desc_t *)__pa(new_memmap)); | 1153 | memmap.desc_size, |
1103 | } | 1154 | memmap.desc_version, |
1155 | (efi_memory_desc_t *)__pa(new_memmap)); | ||
1156 | } | ||
1104 | 1157 | ||
1105 | if (status != EFI_SUCCESS) { | 1158 | if (status != EFI_SUCCESS) { |
1106 | pr_alert("Unable to switch EFI into virtual mode (status=%lx)!\n", | 1159 | pr_alert("Unable to switch EFI into virtual mode (status=%lx)!\n", |
1107 | status); | 1160 | status); |
1108 | panic("EFI call to SetVirtualAddressMap() failed!"); | 1161 | panic("EFI call to SetVirtualAddressMap() failed!"); |
1109 | } | ||
1110 | } | 1162 | } |
1111 | 1163 | ||
1112 | /* | 1164 | /* |
@@ -1126,7 +1178,33 @@ void __init efi_enter_virtual_mode(void) | |||
1126 | 1178 | ||
1127 | efi_runtime_mkexec(); | 1179 | efi_runtime_mkexec(); |
1128 | 1180 | ||
1129 | kfree(new_memmap); | 1181 | /* |
1182 | * We mapped the descriptor array into the EFI pagetable above but we're | ||
1183 | * not unmapping it here. Here's why: | ||
1184 | * | ||
1185 | * We're copying select PGDs from the kernel page table to the EFI page | ||
1186 | * table and when we do so and make changes to those PGDs like unmapping | ||
1187 | * stuff from them, those changes appear in the kernel page table and we | ||
1188 | * go boom. | ||
1189 | * | ||
1190 | * From setup_real_mode(): | ||
1191 | * | ||
1192 | * ... | ||
1193 | * trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd; | ||
1194 | * | ||
1195 | * In this particular case, our allocation is in PGD 0 of the EFI page | ||
1196 | * table but we've copied that PGD from PGD[272] of the EFI page table: | ||
1197 | * | ||
1198 | * pgd_index(__PAGE_OFFSET = 0xffff880000000000) = 272 | ||
1199 | * | ||
1200 | * where the direct memory mapping in kernel space is. | ||
1201 | * | ||
1202 | * new_memmap's VA comes from that direct mapping and thus clearing it, | ||
1203 | * it would get cleared in the kernel page table too. | ||
1204 | * | ||
1205 | * efi_cleanup_page_tables(__pa(new_memmap), 1 << pg_shift); | ||
1206 | */ | ||
1207 | free_pages((unsigned long)new_memmap, pg_shift); | ||
1130 | 1208 | ||
1131 | /* clean DUMMY object */ | 1209 | /* clean DUMMY object */ |
1132 | efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID, | 1210 | efi.set_variable(efi_dummy_name, &EFI_DUMMY_GUID, |
@@ -1136,6 +1214,14 @@ void __init efi_enter_virtual_mode(void) | |||
1136 | 0, NULL); | 1214 | 0, NULL); |
1137 | } | 1215 | } |
1138 | 1216 | ||
1217 | void __init efi_enter_virtual_mode(void) | ||
1218 | { | ||
1219 | if (efi_setup) | ||
1220 | kexec_enter_virtual_mode(); | ||
1221 | else | ||
1222 | __efi_enter_virtual_mode(); | ||
1223 | } | ||
1224 | |||
1139 | /* | 1225 | /* |
1140 | * Convenience functions to obtain memory types and attributes | 1226 | * Convenience functions to obtain memory types and attributes |
1141 | */ | 1227 | */ |
@@ -1173,9 +1259,8 @@ u64 efi_mem_attributes(unsigned long phys_addr) | |||
1173 | } | 1259 | } |
1174 | 1260 | ||
1175 | /* | 1261 | /* |
1176 | * Some firmware has serious problems when using more than 50% of the EFI | 1262 | * Some firmware implementations refuse to boot if there's insufficient space |
1177 | * variable store, i.e. it triggers bugs that can brick machines. Ensure that | 1263 | * in the variable store. Ensure that we never use more than a safe limit. |
1178 | * we never use more than this safe limit. | ||
1179 | * | 1264 | * |
1180 | * Return EFI_SUCCESS if it is safe to write 'size' bytes to the variable | 1265 | * Return EFI_SUCCESS if it is safe to write 'size' bytes to the variable |
1181 | * store. | 1266 | * store. |
@@ -1194,10 +1279,9 @@ efi_status_t efi_query_variable_store(u32 attributes, unsigned long size) | |||
1194 | return status; | 1279 | return status; |
1195 | 1280 | ||
1196 | /* | 1281 | /* |
1197 | * Some firmware implementations refuse to boot if there's insufficient | 1282 | * We account for that by refusing the write if permitting it would |
1198 | * space in the variable store. We account for that by refusing the | 1283 | * reduce the available space to under 5KB. This figure was provided by |
1199 | * write if permitting it would reduce the available space to under | 1284 | * Samsung, so should be safe. |
1200 | * 5KB. This figure was provided by Samsung, so should be safe. | ||
1201 | */ | 1285 | */ |
1202 | if ((remaining_size - size < EFI_MIN_RESERVE) && | 1286 | if ((remaining_size - size < EFI_MIN_RESERVE) && |
1203 | !efi_no_storage_paranoia) { | 1287 | !efi_no_storage_paranoia) { |
@@ -1260,8 +1344,27 @@ static int __init parse_efi_cmdline(char *str) | |||
1260 | str++; | 1344 | str++; |
1261 | 1345 | ||
1262 | if (!strncmp(str, "old_map", 7)) | 1346 | if (!strncmp(str, "old_map", 7)) |
1263 | set_bit(EFI_OLD_MEMMAP, &x86_efi_facility); | 1347 | set_bit(EFI_OLD_MEMMAP, &efi.flags); |
1264 | 1348 | ||
1265 | return 0; | 1349 | return 0; |
1266 | } | 1350 | } |
1267 | early_param("efi", parse_efi_cmdline); | 1351 | early_param("efi", parse_efi_cmdline); |
1352 | |||
1353 | void __init efi_apply_memmap_quirks(void) | ||
1354 | { | ||
1355 | /* | ||
1356 | * Once setup is done earlier, unmap the EFI memory map on mismatched | ||
1357 | * firmware/kernel architectures since there is no support for runtime | ||
1358 | * services. | ||
1359 | */ | ||
1360 | if (!efi_runtime_supported()) { | ||
1361 | pr_info("efi: Setup done, disabling due to 32/64-bit mismatch\n"); | ||
1362 | efi_unmap_memmap(); | ||
1363 | } | ||
1364 | |||
1365 | /* | ||
1366 | * UV doesn't support the new EFI pagetable mapping yet. | ||
1367 | */ | ||
1368 | if (is_uv_system()) | ||
1369 | set_bit(EFI_OLD_MEMMAP, &efi.flags); | ||
1370 | } | ||