diff options
Diffstat (limited to 'drivers/firmware/efi/arm-runtime.c')
-rw-r--r-- | drivers/firmware/efi/arm-runtime.c | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/drivers/firmware/efi/arm-runtime.c b/drivers/firmware/efi/arm-runtime.c index 6ae21e41a429..17ccf0a8787a 100644 --- a/drivers/firmware/efi/arm-runtime.c +++ b/drivers/firmware/efi/arm-runtime.c | |||
@@ -42,11 +42,13 @@ static struct mm_struct efi_mm = { | |||
42 | static bool __init efi_virtmap_init(void) | 42 | static bool __init efi_virtmap_init(void) |
43 | { | 43 | { |
44 | efi_memory_desc_t *md; | 44 | efi_memory_desc_t *md; |
45 | bool systab_found; | ||
45 | 46 | ||
46 | efi_mm.pgd = pgd_alloc(&efi_mm); | 47 | efi_mm.pgd = pgd_alloc(&efi_mm); |
47 | init_new_context(NULL, &efi_mm); | 48 | init_new_context(NULL, &efi_mm); |
48 | 49 | ||
49 | for_each_efi_memory_desc(&memmap, md) { | 50 | systab_found = false; |
51 | for_each_efi_memory_desc(md) { | ||
50 | phys_addr_t phys = md->phys_addr; | 52 | phys_addr_t phys = md->phys_addr; |
51 | int ret; | 53 | int ret; |
52 | 54 | ||
@@ -64,7 +66,25 @@ static bool __init efi_virtmap_init(void) | |||
64 | &phys, ret); | 66 | &phys, ret); |
65 | return false; | 67 | return false; |
66 | } | 68 | } |
69 | /* | ||
70 | * If this entry covers the address of the UEFI system table, | ||
71 | * calculate and record its virtual address. | ||
72 | */ | ||
73 | if (efi_system_table >= phys && | ||
74 | efi_system_table < phys + (md->num_pages * EFI_PAGE_SIZE)) { | ||
75 | efi.systab = (void *)(unsigned long)(efi_system_table - | ||
76 | phys + md->virt_addr); | ||
77 | systab_found = true; | ||
78 | } | ||
79 | } | ||
80 | if (!systab_found) { | ||
81 | pr_err("No virtual mapping found for the UEFI System Table\n"); | ||
82 | return false; | ||
67 | } | 83 | } |
84 | |||
85 | if (efi_memattr_apply_permissions(&efi_mm, efi_set_mapping_permissions)) | ||
86 | return false; | ||
87 | |||
68 | return true; | 88 | return true; |
69 | } | 89 | } |
70 | 90 | ||
@@ -89,26 +109,17 @@ static int __init arm_enable_runtime_services(void) | |||
89 | 109 | ||
90 | pr_info("Remapping and enabling EFI services.\n"); | 110 | pr_info("Remapping and enabling EFI services.\n"); |
91 | 111 | ||
92 | mapsize = memmap.map_end - memmap.map; | 112 | mapsize = efi.memmap.map_end - efi.memmap.map; |
93 | memmap.map = (__force void *)ioremap_cache(memmap.phys_map, | ||
94 | mapsize); | ||
95 | if (!memmap.map) { | ||
96 | pr_err("Failed to remap EFI memory map\n"); | ||
97 | return -ENOMEM; | ||
98 | } | ||
99 | memmap.map_end = memmap.map + mapsize; | ||
100 | efi.memmap = &memmap; | ||
101 | 113 | ||
102 | efi.systab = (__force void *)ioremap_cache(efi_system_table, | 114 | efi.memmap.map = memremap(efi.memmap.phys_map, mapsize, MEMREMAP_WB); |
103 | sizeof(efi_system_table_t)); | 115 | if (!efi.memmap.map) { |
104 | if (!efi.systab) { | 116 | pr_err("Failed to remap EFI memory map\n"); |
105 | pr_err("Failed to remap EFI System Table\n"); | ||
106 | return -ENOMEM; | 117 | return -ENOMEM; |
107 | } | 118 | } |
108 | set_bit(EFI_SYSTEM_TABLES, &efi.flags); | 119 | efi.memmap.map_end = efi.memmap.map + mapsize; |
109 | 120 | ||
110 | if (!efi_virtmap_init()) { | 121 | if (!efi_virtmap_init()) { |
111 | pr_err("No UEFI virtual mapping was installed -- runtime services will not be available\n"); | 122 | pr_err("UEFI virtual mapping missing or invalid -- runtime services will not be available\n"); |
112 | return -ENOMEM; | 123 | return -ENOMEM; |
113 | } | 124 | } |
114 | 125 | ||
@@ -116,8 +127,6 @@ static int __init arm_enable_runtime_services(void) | |||
116 | efi_native_runtime_setup(); | 127 | efi_native_runtime_setup(); |
117 | set_bit(EFI_RUNTIME_SERVICES, &efi.flags); | 128 | set_bit(EFI_RUNTIME_SERVICES, &efi.flags); |
118 | 129 | ||
119 | efi.runtime_version = efi.systab->hdr.revision; | ||
120 | |||
121 | return 0; | 130 | return 0; |
122 | } | 131 | } |
123 | early_initcall(arm_enable_runtime_services); | 132 | early_initcall(arm_enable_runtime_services); |