Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi/libstub: Rename efi_call_early/_runtime macros to be more intuitive

The macros efi_call_early and efi_call_runtime are used to call EFI
boot services and runtime services, respectively. However, the naming
is confusing, given that the early vs runtime distinction may suggest
that these are used for calling the same set of services either early
or late (== at runtime), while in reality, the sets of services they
can be used with are completely disjoint, and efi_call_runtime is also
only usable in 'early' code.

So do a global sweep to replace all occurrences with efi_bs_call or
efi_rt_call, respectively, where BS and RT match the idiom used by
the UEFI spec to refer to boot time or runtime services.

While at it, use 'func' as the macro parameter name for the function
pointers, which is less likely to collide and cause weird build errors.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Borislav Petkov <bp@alien8.de>
Cc: James Morse <james.morse@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191224151025.32482-24-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Ard Biesheuvel and committed by
Ingo Molnar
966291f6 99ea8b1d

+137 -163
+3 -3
arch/arm/include/asm/efi.h
··· 50 50 51 51 /* arch specific definitions used by the stub code */ 52 52 53 - #define efi_call_early(f, ...) efi_system_table()->boottime->f(__VA_ARGS__) 54 - #define efi_call_runtime(f, ...) efi_system_table()->runtime->f(__VA_ARGS__) 55 - #define efi_is_native() (true) 53 + #define efi_bs_call(func, ...) efi_system_table()->boottime->func(__VA_ARGS__) 54 + #define efi_rt_call(func, ...) efi_system_table()->runtime->func(__VA_ARGS__) 55 + #define efi_is_native() (true) 56 56 57 57 #define efi_table_attr(inst, attr) (inst->attr) 58 58
+3 -3
arch/arm64/include/asm/efi.h
··· 93 93 return (image_addr & ~(SZ_1G - 1UL)) + (1UL << (VA_BITS_MIN - 1)); 94 94 } 95 95 96 - #define efi_call_early(f, ...) efi_system_table()->boottime->f(__VA_ARGS__) 97 - #define efi_call_runtime(f, ...) efi_system_table()->runtime->f(__VA_ARGS__) 98 - #define efi_is_native() (true) 96 + #define efi_bs_call(func, ...) efi_system_table()->boottime->func(__VA_ARGS__) 97 + #define efi_rt_call(func, ...) efi_system_table()->runtime->func(__VA_ARGS__) 98 + #define efi_is_native() (true) 99 99 100 100 #define efi_table_attr(inst, attr) (inst->attr) 101 101
+35 -42
arch/x86/boot/compressed/eboot.c
··· 54 54 55 55 size = romsize + sizeof(*rom); 56 56 57 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, 58 - (void **)&rom); 57 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size, 58 + (void **)&rom); 59 59 if (status != EFI_SUCCESS) { 60 60 efi_printk("Failed to allocate memory for 'rom'\n"); 61 61 return status; ··· 95 95 return status; 96 96 97 97 free_struct: 98 - efi_call_early(free_pool, rom); 98 + efi_bs_call(free_pool, rom); 99 99 return status; 100 100 } 101 101 ··· 119 119 efi_handle_t h; 120 120 int i; 121 121 122 - status = efi_call_early(locate_handle, 123 - EFI_LOCATE_BY_PROTOCOL, 124 - &pci_proto, NULL, &size, pci_handle); 122 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 123 + &pci_proto, NULL, &size, pci_handle); 125 124 126 125 if (status == EFI_BUFFER_TOO_SMALL) { 127 - status = efi_call_early(allocate_pool, 128 - EFI_LOADER_DATA, 129 - size, (void **)&pci_handle); 126 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size, 127 + (void **)&pci_handle); 130 128 131 129 if (status != EFI_SUCCESS) { 132 130 efi_printk("Failed to allocate memory for 'pci_handle'\n"); 133 131 return; 134 132 } 135 133 136 - status = efi_call_early(locate_handle, 137 - EFI_LOCATE_BY_PROTOCOL, &pci_proto, 138 - NULL, &size, pci_handle); 134 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 135 + &pci_proto, NULL, &size, pci_handle); 139 136 } 140 137 141 138 if (status != EFI_SUCCESS) ··· 147 150 efi_pci_io_protocol_t *pci = NULL; 148 151 struct pci_setup_rom *rom; 149 152 150 - status = efi_call_early(handle_protocol, h, 151 - &pci_proto, (void **)&pci); 153 + status = efi_bs_call(handle_protocol, h, &pci_proto, 154 + (void **)&pci); 152 155 if (status != EFI_SUCCESS || !pci) 153 156 continue; 154 157 ··· 165 168 } 166 169 167 170 free_handle: 168 - efi_call_early(free_pool, pci_handle); 171 + efi_bs_call(free_pool, pci_handle); 169 172 } 170 173 171 174 static void retrieve_apple_device_properties(struct boot_params *boot_params) ··· 176 179 u32 size = 0; 177 180 apple_properties_protocol_t *p; 178 181 179 - status = efi_call_early(locate_protocol, &guid, NULL, (void **)&p); 182 + status = efi_bs_call(locate_protocol, &guid, NULL, (void **)&p); 180 183 if (status != EFI_SUCCESS) 181 184 return; 182 185 ··· 190 193 return; 191 194 192 195 do { 193 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 194 - size + sizeof(struct setup_data), 195 - (void **)&new); 196 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, 197 + size + sizeof(struct setup_data), 198 + (void **)&new); 196 199 if (status != EFI_SUCCESS) { 197 200 efi_printk("Failed to allocate memory for 'properties'\n"); 198 201 return; ··· 201 204 status = efi_call_proto(p, get_all, new->data, &size); 202 205 203 206 if (status == EFI_BUFFER_TOO_SMALL) 204 - efi_call_early(free_pool, new); 207 + efi_bs_call(free_pool, new); 205 208 } while (status == EFI_BUFFER_TOO_SMALL); 206 209 207 210 new->type = SETUP_APPLE_PROPERTIES; ··· 245 248 efi_handle_t handle; 246 249 int i; 247 250 248 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 249 - size, (void **)&uga_handle); 251 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size, 252 + (void **)&uga_handle); 250 253 if (status != EFI_SUCCESS) 251 254 return status; 252 255 253 - status = efi_call_early(locate_handle, 254 - EFI_LOCATE_BY_PROTOCOL, 255 - uga_proto, NULL, &size, uga_handle); 256 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 257 + uga_proto, NULL, &size, uga_handle); 256 258 if (status != EFI_SUCCESS) 257 259 goto free_handle; 258 260 ··· 264 268 u32 w, h, depth, refresh; 265 269 void *pciio; 266 270 267 - status = efi_call_early(handle_protocol, handle, 268 - uga_proto, (void **)&uga); 271 + status = efi_bs_call(handle_protocol, handle, uga_proto, 272 + (void **)&uga); 269 273 if (status != EFI_SUCCESS) 270 274 continue; 271 275 272 276 pciio = NULL; 273 - efi_call_early(handle_protocol, handle, &pciio_proto, &pciio); 277 + efi_bs_call(handle_protocol, handle, &pciio_proto, &pciio); 274 278 275 279 status = efi_call_proto(uga, get_mode, &w, &h, &depth, &refresh); 276 280 if (status == EFI_SUCCESS && (!first_uga || pciio)) { ··· 308 312 si->rsvd_pos = 24; 309 313 310 314 free_handle: 311 - efi_call_early(free_pool, uga_handle); 315 + efi_bs_call(free_pool, uga_handle); 312 316 313 317 return status; 314 318 } ··· 327 331 memset(si, 0, sizeof(*si)); 328 332 329 333 size = 0; 330 - status = efi_call_early(locate_handle, 331 - EFI_LOCATE_BY_PROTOCOL, 332 - &graphics_proto, NULL, &size, gop_handle); 334 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 335 + &graphics_proto, NULL, &size, gop_handle); 333 336 if (status == EFI_BUFFER_TOO_SMALL) 334 337 status = efi_setup_gop(si, &graphics_proto, size); 335 338 336 339 if (status != EFI_SUCCESS) { 337 340 size = 0; 338 - status = efi_call_early(locate_handle, 339 - EFI_LOCATE_BY_PROTOCOL, 340 - &uga_proto, NULL, &size, uga_handle); 341 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 342 + &uga_proto, NULL, &size, uga_handle); 341 343 if (status == EFI_BUFFER_TOO_SMALL) 342 344 setup_uga(si, &uga_proto, size); 343 345 } ··· 372 378 if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) 373 379 return EFI_INVALID_PARAMETER; 374 380 375 - status = efi_call_early(handle_protocol, handle, 376 - &proto, (void *)&image); 381 + status = efi_bs_call(handle_protocol, handle, &proto, (void *)&image); 377 382 if (status != EFI_SUCCESS) { 378 383 efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); 379 384 return status; ··· 587 594 sizeof(struct e820_entry) * nr_desc; 588 595 589 596 if (*e820ext) { 590 - efi_call_early(free_pool, *e820ext); 597 + efi_bs_call(free_pool, *e820ext); 591 598 *e820ext = NULL; 592 599 *e820ext_size = 0; 593 600 } 594 601 595 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 596 - size, (void **)e820ext); 602 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size, 603 + (void **)e820ext); 597 604 if (status == EFI_SUCCESS) 598 605 *e820ext_size = size; 599 606 ··· 755 762 756 763 setup_quirks(boot_params); 757 764 758 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 759 - sizeof(*gdt), (void **)&gdt); 765 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*gdt), 766 + (void **)&gdt); 760 767 if (status != EFI_SUCCESS) { 761 768 efi_printk("Failed to allocate memory for 'gdt' structure\n"); 762 769 goto fail;
+6 -6
arch/x86/include/asm/efi.h
··· 227 227 ? inst->func(inst, ##__VA_ARGS__) \ 228 228 : efi64_thunk(inst->mixed_mode.func, inst, ##__VA_ARGS__)) 229 229 230 - #define efi_call_early(f, ...) \ 230 + #define efi_bs_call(func, ...) \ 231 231 (efi_is_native() \ 232 - ? efi_system_table()->boottime->f(__VA_ARGS__) \ 232 + ? efi_system_table()->boottime->func(__VA_ARGS__) \ 233 233 : efi64_thunk(efi_table_attr(efi_system_table(), \ 234 - boottime)->mixed_mode.f, __VA_ARGS__)) 234 + boottime)->mixed_mode.func, __VA_ARGS__)) 235 235 236 - #define efi_call_runtime(f, ...) \ 236 + #define efi_rt_call(func, ...) \ 237 237 (efi_is_native() \ 238 - ? efi_system_table()->runtime->f(__VA_ARGS__) \ 238 + ? efi_system_table()->runtime->func(__VA_ARGS__) \ 239 239 : efi64_thunk(efi_table_attr(efi_system_table(), \ 240 - runtime)->mixed_mode.f, __VA_ARGS__)) 240 + runtime)->mixed_mode.func, __VA_ARGS__)) 241 241 242 242 extern bool efi_reboot_required(void); 243 243 extern bool efi_is_table_address(unsigned long phys_addr);
+6 -7
drivers/firmware/efi/libstub/arm-stub.c
··· 53 53 struct screen_info *si = NULL; 54 54 55 55 size = 0; 56 - status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, 57 - &gop_proto, NULL, &size, gop_handle); 56 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, 57 + &gop_proto, NULL, &size, gop_handle); 58 58 if (status == EFI_BUFFER_TOO_SMALL) { 59 59 si = alloc_screen_info(); 60 60 if (!si) ··· 70 70 efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; 71 71 efi_status_t status; 72 72 73 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv), 74 - (void **)&rsv); 73 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv), 74 + (void **)&rsv); 75 75 if (status != EFI_SUCCESS) { 76 76 pr_efi_err("Failed to allocate memreserve entry!\n"); 77 77 return; ··· 81 81 rsv->size = 0; 82 82 atomic_set(&rsv->count, 0); 83 83 84 - status = efi_call_early(install_configuration_table, 85 - &memreserve_table_guid, 86 - rsv); 84 + status = efi_bs_call(install_configuration_table, 85 + &memreserve_table_guid, rsv); 87 86 if (status != EFI_SUCCESS) 88 87 pr_efi_err("Failed to install memreserve config table!\n"); 89 88 }
+15 -15
drivers/firmware/efi/libstub/arm32-stub.c
··· 37 37 * its contents while we hand over to the kernel proper from the 38 38 * decompressor. 39 39 */ 40 - status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA, 41 - sizeof(*si), (void **)&si); 40 + status = efi_bs_call(allocate_pool, EFI_RUNTIME_SERVICES_DATA, 41 + sizeof(*si), (void **)&si); 42 42 43 43 if (status != EFI_SUCCESS) 44 44 return NULL; 45 45 46 - status = efi_call_early(install_configuration_table, 47 - &screen_info_guid, si); 46 + status = efi_bs_call(install_configuration_table, 47 + &screen_info_guid, si); 48 48 if (status == EFI_SUCCESS) 49 49 return si; 50 50 51 - efi_call_early(free_pool, si); 51 + efi_bs_call(free_pool, si); 52 52 return NULL; 53 53 } 54 54 ··· 57 57 if (!si) 58 58 return; 59 59 60 - efi_call_early(install_configuration_table, &screen_info_guid, NULL); 61 - efi_call_early(free_pool, si); 60 + efi_bs_call(install_configuration_table, &screen_info_guid, NULL); 61 + efi_bs_call(free_pool, si); 62 62 } 63 63 64 64 static efi_status_t reserve_kernel_base(unsigned long dram_base, ··· 91 91 */ 92 92 alloc_addr = dram_base + MAX_UNCOMP_KERNEL_SIZE; 93 93 nr_pages = MAX_UNCOMP_KERNEL_SIZE / EFI_PAGE_SIZE; 94 - status = efi_call_early(allocate_pages, EFI_ALLOCATE_MAX_ADDRESS, 95 - EFI_BOOT_SERVICES_DATA, nr_pages, &alloc_addr); 94 + status = efi_bs_call(allocate_pages, EFI_ALLOCATE_MAX_ADDRESS, 95 + EFI_BOOT_SERVICES_DATA, nr_pages, &alloc_addr); 96 96 if (status == EFI_SUCCESS) { 97 97 if (alloc_addr == dram_base) { 98 98 *reserve_addr = alloc_addr; ··· 156 156 start = max(start, (u64)dram_base); 157 157 end = min(end, (u64)dram_base + MAX_UNCOMP_KERNEL_SIZE); 158 158 159 - status = efi_call_early(allocate_pages, 160 - EFI_ALLOCATE_ADDRESS, 161 - EFI_LOADER_DATA, 162 - (end - start) / EFI_PAGE_SIZE, 163 - &start); 159 + status = efi_bs_call(allocate_pages, 160 + EFI_ALLOCATE_ADDRESS, 161 + EFI_LOADER_DATA, 162 + (end - start) / EFI_PAGE_SIZE, 163 + &start); 164 164 if (status != EFI_SUCCESS) { 165 165 pr_efi_err("reserve_kernel_base(): alloc failed.\n"); 166 166 goto out; ··· 185 185 186 186 status = EFI_SUCCESS; 187 187 out: 188 - efi_call_early(free_pool, memory_map); 188 + efi_bs_call(free_pool, memory_map); 189 189 return status; 190 190 } 191 191
+4 -4
drivers/firmware/efi/libstub/arm64-stub.c
··· 129 129 *image_addr = *reserve_addr = preferred_offset; 130 130 *reserve_size = round_up(kernel_memsize, EFI_ALLOC_ALIGN); 131 131 132 - status = efi_call_early(allocate_pages, EFI_ALLOCATE_ADDRESS, 133 - EFI_LOADER_DATA, 134 - *reserve_size / EFI_PAGE_SIZE, 135 - (efi_physical_addr_t *)reserve_addr); 132 + status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, 133 + EFI_LOADER_DATA, 134 + *reserve_size / EFI_PAGE_SIZE, 135 + (efi_physical_addr_t *)reserve_addr); 136 136 } 137 137 138 138 if (status != EFI_SUCCESS) {
+33 -37
drivers/firmware/efi/libstub/efi-stub-helper.c
··· 95 95 *map->map_size = *map->desc_size * 32; 96 96 *map->buff_size = *map->map_size; 97 97 again: 98 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 99 - *map->map_size, (void **)&m); 98 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, 99 + *map->map_size, (void **)&m); 100 100 if (status != EFI_SUCCESS) 101 101 goto fail; 102 102 103 103 *map->desc_size = 0; 104 104 key = 0; 105 - status = efi_call_early(get_memory_map, map->map_size, m, 106 - &key, map->desc_size, &desc_version); 105 + status = efi_bs_call(get_memory_map, map->map_size, m, 106 + &key, map->desc_size, &desc_version); 107 107 if (status == EFI_BUFFER_TOO_SMALL || 108 108 !mmap_has_headroom(*map->buff_size, *map->map_size, 109 109 *map->desc_size)) { 110 - efi_call_early(free_pool, m); 110 + efi_bs_call(free_pool, m); 111 111 /* 112 112 * Make sure there is some entries of headroom so that the 113 113 * buffer can be reused for a new map after allocations are ··· 121 121 } 122 122 123 123 if (status != EFI_SUCCESS) 124 - efi_call_early(free_pool, m); 124 + efi_bs_call(free_pool, m); 125 125 126 126 if (map->key_ptr && status == EFI_SUCCESS) 127 127 *map->key_ptr = key; ··· 163 163 } 164 164 } 165 165 166 - efi_call_early(free_pool, map.map); 166 + efi_bs_call(free_pool, map.map); 167 167 168 168 return membase; 169 169 } ··· 249 249 if (!max_addr) 250 250 status = EFI_NOT_FOUND; 251 251 else { 252 - status = efi_call_early(allocate_pages, 253 - EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, 254 - nr_pages, &max_addr); 252 + status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, 253 + EFI_LOADER_DATA, nr_pages, &max_addr); 255 254 if (status != EFI_SUCCESS) { 256 255 max = max_addr; 257 256 max_addr = 0; ··· 260 261 *addr = max_addr; 261 262 } 262 263 263 - efi_call_early(free_pool, map); 264 + efi_bs_call(free_pool, map); 264 265 fail: 265 266 return status; 266 267 } ··· 327 328 if ((start + size) > end) 328 329 continue; 329 330 330 - status = efi_call_early(allocate_pages, 331 - EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, 332 - nr_pages, &start); 331 + status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, 332 + EFI_LOADER_DATA, nr_pages, &start); 333 333 if (status == EFI_SUCCESS) { 334 334 *addr = start; 335 335 break; ··· 338 340 if (i == map_size / desc_size) 339 341 status = EFI_NOT_FOUND; 340 342 341 - efi_call_early(free_pool, map); 343 + efi_bs_call(free_pool, map); 342 344 fail: 343 345 return status; 344 346 } ··· 384 386 } 385 387 386 388 grow: 387 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 388 - info_sz, (void **)&info); 389 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, info_sz, 390 + (void **)&info); 389 391 if (status != EFI_SUCCESS) { 390 392 efi_printk("Failed to alloc mem for file info\n"); 391 393 return status; ··· 393 395 394 396 status = h->get_info(h, &info_guid, &info_sz, info); 395 397 if (status == EFI_BUFFER_TOO_SMALL) { 396 - efi_call_early(free_pool, info); 398 + efi_bs_call(free_pool, info); 397 399 goto grow; 398 400 } 399 401 400 402 *file_sz = info->file_size; 401 - efi_call_early(free_pool, info); 403 + efi_bs_call(free_pool, info); 402 404 403 405 if (status != EFI_SUCCESS) 404 406 efi_printk("Failed to get initrd info\n"); ··· 426 428 efi_status_t status; 427 429 efi_handle_t handle = image->device_handle; 428 430 429 - status = efi_call_early(handle_protocol, handle, 430 - &fs_proto, (void **)&io); 431 + status = efi_bs_call(handle_protocol, handle, &fs_proto, (void **)&io); 431 432 if (status != EFI_SUCCESS) { 432 433 efi_printk("Failed to handle fs_proto\n"); 433 434 return status; ··· 559 562 if (!nr_files) 560 563 return EFI_SUCCESS; 561 564 562 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 563 - nr_files * sizeof(*files), (void **)&files); 565 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, 566 + nr_files * sizeof(*files), (void **)&files); 564 567 if (status != EFI_SUCCESS) { 565 568 pr_efi_err("Failed to alloc mem for file handle list\n"); 566 569 goto fail; ··· 665 668 666 669 } 667 670 668 - efi_call_early(free_pool, files); 671 + efi_bs_call(free_pool, files); 669 672 670 673 *load_addr = file_addr; 671 674 *load_size = file_size_total; ··· 679 682 for (k = j; k < i; k++) 680 683 efi_file_close(files[k].handle); 681 684 free_files: 682 - efi_call_early(free_pool, files); 685 + efi_bs_call(free_pool, files); 683 686 fail: 684 687 *load_addr = 0; 685 688 *load_size = 0; ··· 725 728 * as possible while respecting the required alignment. 726 729 */ 727 730 nr_pages = round_up(alloc_size, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE; 728 - status = efi_call_early(allocate_pages, 729 - EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, 730 - nr_pages, &efi_addr); 731 + status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, 732 + EFI_LOADER_DATA, nr_pages, &efi_addr); 731 733 new_addr = efi_addr; 732 734 /* 733 735 * If preferred address allocation failed allocate as low as ··· 879 883 if (status != EFI_SUCCESS) 880 884 goto free_map; 881 885 882 - status = efi_call_early(exit_boot_services, handle, *map->key_ptr); 886 + status = efi_bs_call(exit_boot_services, handle, *map->key_ptr); 883 887 884 888 if (status == EFI_INVALID_PARAMETER) { 885 889 /* ··· 896 900 * to get_memory_map() is expected to succeed here. 897 901 */ 898 902 *map->map_size = *map->buff_size; 899 - status = efi_call_early(get_memory_map, 900 - map->map_size, 901 - *map->map, 902 - map->key_ptr, 903 - map->desc_size, 904 - map->desc_ver); 903 + status = efi_bs_call(get_memory_map, 904 + map->map_size, 905 + *map->map, 906 + map->key_ptr, 907 + map->desc_size, 908 + map->desc_ver); 905 909 906 910 /* exit_boot_services() was called, thus cannot free */ 907 911 if (status != EFI_SUCCESS) ··· 912 916 if (status != EFI_SUCCESS) 913 917 goto fail; 914 918 915 - status = efi_call_early(exit_boot_services, handle, *map->key_ptr); 919 + status = efi_bs_call(exit_boot_services, handle, *map->key_ptr); 916 920 } 917 921 918 922 /* exit_boot_services() was called, thus cannot free */ ··· 922 926 return EFI_SUCCESS; 923 927 924 928 free_map: 925 - efi_call_early(free_pool, *map->map); 929 + efi_bs_call(free_pool, *map->map); 926 930 fail: 927 931 return status; 928 932 }
+8
drivers/firmware/efi/libstub/efistub.h
··· 76 76 fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var)) 77 77 #endif 78 78 79 + #define get_efi_var(name, vendor, ...) \ 80 + efi_rt_call(get_variable, (efi_char16_t *)(name), \ 81 + (efi_guid_t *)(vendor), __VA_ARGS__) 82 + 83 + #define set_efi_var(name, vendor, ...) \ 84 + efi_rt_call(set_variable, (efi_char16_t *)(name), \ 85 + (efi_guid_t *)(vendor), __VA_ARGS__) 86 + 79 87 #endif
+7 -10
drivers/firmware/efi/libstub/gop.c
··· 110 110 void *dummy = NULL; 111 111 efi_physical_addr_t current_fb_base; 112 112 113 - status = efi_call_early(handle_protocol, h, 114 - proto, (void **)&gop); 113 + status = efi_bs_call(handle_protocol, h, proto, (void **)&gop); 115 114 if (status != EFI_SUCCESS) 116 115 continue; 117 116 118 - status = efi_call_early(handle_protocol, h, 119 - &conout_proto, &dummy); 117 + status = efi_bs_call(handle_protocol, h, &conout_proto, &dummy); 120 118 if (status == EFI_SUCCESS) 121 119 conout_found = true; 122 120 ··· 185 187 efi_status_t status; 186 188 void **gop_handle = NULL; 187 189 188 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 189 - size, (void **)&gop_handle); 190 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size, 191 + (void **)&gop_handle); 190 192 if (status != EFI_SUCCESS) 191 193 return status; 192 194 193 - status = efi_call_early(locate_handle, 194 - EFI_LOCATE_BY_PROTOCOL, 195 - proto, NULL, &size, gop_handle); 195 + status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, proto, NULL, 196 + &size, gop_handle); 196 197 if (status != EFI_SUCCESS) 197 198 goto free_handle; 198 199 199 200 status = setup_gop(si, proto, size, gop_handle); 200 201 201 202 free_handle: 202 - efi_call_early(free_pool, gop_handle); 203 + efi_bs_call(free_pool, gop_handle); 203 204 return status; 204 205 }
+10 -13
drivers/firmware/efi/libstub/random.c
··· 32 32 efi_status_t status; 33 33 efi_rng_protocol_t *rng = NULL; 34 34 35 - status = efi_call_early(locate_protocol, &rng_proto, NULL, 36 - (void **)&rng); 35 + status = efi_bs_call(locate_protocol, &rng_proto, NULL, (void **)&rng); 37 36 if (status != EFI_SUCCESS) 38 37 return status; 39 38 ··· 140 141 target = round_up(md->phys_addr, align) + target_slot * align; 141 142 pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; 142 143 143 - status = efi_call_early(allocate_pages, EFI_ALLOCATE_ADDRESS, 144 - EFI_LOADER_DATA, pages, &target); 144 + status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS, 145 + EFI_LOADER_DATA, pages, &target); 145 146 if (status == EFI_SUCCESS) 146 147 *addr = target; 147 148 break; 148 149 } 149 150 150 - efi_call_early(free_pool, memory_map); 151 + efi_bs_call(free_pool, memory_map); 151 152 152 153 return status; 153 154 } ··· 161 162 struct linux_efi_random_seed *seed = NULL; 162 163 efi_status_t status; 163 164 164 - status = efi_call_early(locate_protocol, &rng_proto, NULL, 165 - (void **)&rng); 165 + status = efi_bs_call(locate_protocol, &rng_proto, NULL, (void **)&rng); 166 166 if (status != EFI_SUCCESS) 167 167 return status; 168 168 169 - status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA, 170 - sizeof(*seed) + EFI_RANDOM_SEED_SIZE, 171 - (void **)&seed); 169 + status = efi_bs_call(allocate_pool, EFI_RUNTIME_SERVICES_DATA, 170 + sizeof(*seed) + EFI_RANDOM_SEED_SIZE, 171 + (void **)&seed); 172 172 if (status != EFI_SUCCESS) 173 173 return status; 174 174 ··· 186 188 goto err_freepool; 187 189 188 190 seed->size = EFI_RANDOM_SEED_SIZE; 189 - status = efi_call_early(install_configuration_table, &rng_table_guid, 190 - seed); 191 + status = efi_bs_call(install_configuration_table, &rng_table_guid, seed); 191 192 if (status != EFI_SUCCESS) 192 193 goto err_freepool; 193 194 194 195 return EFI_SUCCESS; 195 196 196 197 err_freepool: 197 - efi_call_early(free_pool, seed); 198 + efi_bs_call(free_pool, seed); 198 199 return status; 199 200 }
-5
drivers/firmware/efi/libstub/secureboot.c
··· 21 21 static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID; 22 22 static const efi_char16_t shim_MokSBState_name[] = L"MokSBState"; 23 23 24 - #define get_efi_var(name, vendor, ...) \ 25 - efi_call_runtime(get_variable, \ 26 - (efi_char16_t *)(name), (efi_guid_t *)(vendor), \ 27 - __VA_ARGS__); 28 - 29 24 /* 30 25 * Determine whether we're in secure boot mode. 31 26 *
+7 -18
drivers/firmware/efi/libstub/tpm.c
··· 20 20 #define MEMORY_ONLY_RESET_CONTROL_GUID \ 21 21 EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29) 22 22 23 - #define get_efi_var(name, vendor, ...) \ 24 - efi_call_runtime(get_variable, \ 25 - (efi_char16_t *)(name), (efi_guid_t *)(vendor), \ 26 - __VA_ARGS__) 27 - 28 - #define set_efi_var(name, vendor, ...) \ 29 - efi_call_runtime(set_variable, \ 30 - (efi_char16_t *)(name), (efi_guid_t *)(vendor), \ 31 - __VA_ARGS__) 32 - 33 23 /* 34 24 * Enable reboot attack mitigation. This requests that the firmware clear the 35 25 * RAM on next reboot before proceeding with boot, ensuring that any secrets ··· 62 72 efi_tcg2_protocol_t *tcg2_protocol = NULL; 63 73 int final_events_size = 0; 64 74 65 - status = efi_call_early(locate_protocol, &tcg2_guid, NULL, 66 - (void **)&tcg2_protocol); 75 + status = efi_bs_call(locate_protocol, &tcg2_guid, NULL, 76 + (void **)&tcg2_protocol); 67 77 if (status != EFI_SUCCESS) 68 78 return; 69 79 ··· 115 125 } 116 126 117 127 /* Allocate space for the logs and copy them. */ 118 - status = efi_call_early(allocate_pool, EFI_LOADER_DATA, 119 - sizeof(*log_tbl) + log_size, 120 - (void **) &log_tbl); 128 + status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, 129 + sizeof(*log_tbl) + log_size, (void **)&log_tbl); 121 130 122 131 if (status != EFI_SUCCESS) { 123 132 efi_printk("Unable to allocate memory for event log\n"); ··· 155 166 log_tbl->version = version; 156 167 memcpy(log_tbl->log, (void *) first_entry_addr, log_size); 157 168 158 - status = efi_call_early(install_configuration_table, 159 - &linux_eventlog_guid, log_tbl); 169 + status = efi_bs_call(install_configuration_table, 170 + &linux_eventlog_guid, log_tbl); 160 171 if (status != EFI_SUCCESS) 161 172 goto err_free; 162 173 return; 163 174 164 175 err_free: 165 - efi_call_early(free_pool, log_tbl); 176 + efi_bs_call(free_pool, log_tbl); 166 177 }