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

efi/libstub: Remove 'sys_table_arg' from all function prototypes

We have a helper efi_system_table() that gives us the address of the
EFI system table in memory, so there is no longer point in passing
it around from each function to the next.

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-20-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Ard Biesheuvel and committed by
Ingo Molnar
cd33a5c1 8173ec79

+148 -192
+2 -2
arch/arm/include/asm/efi.h
··· 60 60 #define efi_call_proto(protocol, f, instance, ...) \ 61 61 instance->f(instance, ##__VA_ARGS__) 62 62 63 - struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg); 64 - void free_screen_info(efi_system_table_t *sys_table, struct screen_info *si); 63 + struct screen_info *alloc_screen_info(void); 64 + void free_screen_info(struct screen_info *si); 65 65 66 66 static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) 67 67 {
+1 -2
arch/arm64/include/asm/efi.h
··· 105 105 106 106 #define alloc_screen_info(x...) &screen_info 107 107 108 - static inline void free_screen_info(efi_system_table_t *sys_table_arg, 109 - struct screen_info *si) 108 + static inline void free_screen_info(struct screen_info *si) 110 109 { 111 110 } 112 111
+18 -22
arch/x86/boot/compressed/eboot.c
··· 340 340 EFI_LOCATE_BY_PROTOCOL, 341 341 &graphics_proto, NULL, &size, gop_handle); 342 342 if (status == EFI_BUFFER_TOO_SMALL) 343 - status = efi_setup_gop(NULL, si, &graphics_proto, size); 343 + status = efi_setup_gop(si, &graphics_proto, size); 344 344 345 345 if (status != EFI_SUCCESS) { 346 346 size = 0; ··· 390 390 return status; 391 391 } 392 392 393 - status = efi_low_alloc(sys_table, 0x4000, 1, 394 - (unsigned long *)&boot_params); 393 + status = efi_low_alloc(0x4000, 1, (unsigned long *)&boot_params); 395 394 if (status != EFI_SUCCESS) { 396 395 efi_printk("Failed to allocate lowmem for boot params\n"); 397 396 return status; ··· 415 416 hdr->type_of_loader = 0x21; 416 417 417 418 /* Convert unicode cmdline to ascii */ 418 - cmdline_ptr = efi_convert_cmdline(sys_table, image, &options_size); 419 + cmdline_ptr = efi_convert_cmdline(image, &options_size); 419 420 if (!cmdline_ptr) 420 421 goto fail; 421 422 ··· 433 434 if (status != EFI_SUCCESS) 434 435 goto fail2; 435 436 436 - status = handle_cmdline_files(sys_table, image, 437 + status = handle_cmdline_files(image, 437 438 (char *)(unsigned long)hdr->cmd_line_ptr, 438 439 "initrd=", hdr->initrd_addr_max, 439 440 &ramdisk_addr, &ramdisk_size); ··· 441 442 if (status != EFI_SUCCESS && 442 443 hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G) { 443 444 efi_printk("Trying to load files to higher address\n"); 444 - status = handle_cmdline_files(sys_table, image, 445 + status = handle_cmdline_files(image, 445 446 (char *)(unsigned long)hdr->cmd_line_ptr, 446 447 "initrd=", -1UL, 447 448 &ramdisk_addr, &ramdisk_size); ··· 460 461 /* not reached */ 461 462 462 463 fail2: 463 - efi_free(sys_table, options_size, hdr->cmd_line_ptr); 464 + efi_free(options_size, hdr->cmd_line_ptr); 464 465 fail: 465 - efi_free(sys_table, 0x4000, (unsigned long)boot_params); 466 + efi_free(0x4000, (unsigned long)boot_params); 466 467 467 468 return status; 468 469 } ··· 629 630 boot_map.key_ptr = NULL; 630 631 boot_map.buff_size = &buff_size; 631 632 632 - status = efi_get_memory_map(sys_table, &boot_map); 633 + status = efi_get_memory_map(&boot_map); 633 634 if (status != EFI_SUCCESS) 634 635 return status; 635 636 ··· 651 652 struct efi_info *efi; 652 653 }; 653 654 654 - static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, 655 - struct efi_boot_memmap *map, 655 + static efi_status_t exit_boot_func(struct efi_boot_memmap *map, 656 656 void *priv) 657 657 { 658 658 const char *signature; ··· 661 663 : EFI32_LOADER_SIGNATURE; 662 664 memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32)); 663 665 664 - p->efi->efi_systab = (unsigned long)sys_table_arg; 666 + p->efi->efi_systab = (unsigned long)efi_system_table(); 665 667 p->efi->efi_memdesc_size = *map->desc_size; 666 668 p->efi->efi_memdesc_version = *map->desc_ver; 667 669 p->efi->efi_memmap = (unsigned long)*map->map; 668 670 p->efi->efi_memmap_size = *map->map_size; 669 671 670 672 #ifdef CONFIG_X86_64 671 - p->efi->efi_systab_hi = (unsigned long)sys_table_arg >> 32; 673 + p->efi->efi_systab_hi = (unsigned long)efi_system_table() >> 32; 672 674 p->efi->efi_memmap_hi = (unsigned long)*map->map >> 32; 673 675 #endif 674 676 ··· 700 702 return status; 701 703 702 704 /* Might as well exit boot services now */ 703 - status = efi_exit_boot_services(sys_table, handle, &map, &priv, 704 - exit_boot_func); 705 + status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func); 705 706 if (status != EFI_SUCCESS) 706 707 return status; 707 708 ··· 752 755 * otherwise we ask the BIOS. 753 756 */ 754 757 if (boot_params->secure_boot == efi_secureboot_mode_unset) 755 - boot_params->secure_boot = efi_get_secureboot(sys_table); 758 + boot_params->secure_boot = efi_get_secureboot(); 756 759 757 760 /* Ask the firmware to clear memory on unclean shutdown */ 758 - efi_enable_reset_attack_mitigation(sys_table); 761 + efi_enable_reset_attack_mitigation(); 759 762 760 - efi_random_get_seed(sys_table); 763 + efi_random_get_seed(); 761 764 762 - efi_retrieve_tpm2_eventlog(sys_table); 765 + efi_retrieve_tpm2_eventlog(); 763 766 764 767 setup_graphics(boot_params); 765 768 ··· 775 778 } 776 779 777 780 gdt->size = 0x800; 778 - status = efi_low_alloc(sys_table, gdt->size, 8, 779 - (unsigned long *)&gdt->address); 781 + status = efi_low_alloc(gdt->size, 8, (unsigned long *)&gdt->address); 780 782 if (status != EFI_SUCCESS) { 781 783 efi_printk("Failed to allocate memory for 'gdt'\n"); 782 784 goto fail; ··· 787 791 */ 788 792 if (hdr->pref_address != hdr->code32_start) { 789 793 unsigned long bzimage_addr = hdr->code32_start; 790 - status = efi_relocate_kernel(sys_table, &bzimage_addr, 794 + status = efi_relocate_kernel(&bzimage_addr, 791 795 hdr->init_size, hdr->init_size, 792 796 hdr->pref_address, 793 797 hdr->kernel_alignment,
+26 -29
drivers/firmware/efi/libstub/arm-stub.c
··· 44 44 return sys_table; 45 45 } 46 46 47 - static struct screen_info *setup_graphics(efi_system_table_t *sys_table_arg) 47 + static struct screen_info *setup_graphics(void) 48 48 { 49 49 efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; 50 50 efi_status_t status; ··· 56 56 status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, 57 57 &gop_proto, NULL, &size, gop_handle); 58 58 if (status == EFI_BUFFER_TOO_SMALL) { 59 - si = alloc_screen_info(sys_table_arg); 59 + si = alloc_screen_info(); 60 60 if (!si) 61 61 return NULL; 62 - efi_setup_gop(sys_table_arg, si, &gop_proto, size); 62 + efi_setup_gop(si, &gop_proto, size); 63 63 } 64 64 return si; 65 65 } 66 66 67 - void install_memreserve_table(efi_system_table_t *sys_table_arg) 67 + void install_memreserve_table(void) 68 68 { 69 69 struct linux_efi_memreserve *rsv; 70 70 efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; ··· 95 95 * must be reserved. On failure it is required to free all 96 96 * all allocations it has made. 97 97 */ 98 - efi_status_t handle_kernel_image(efi_system_table_t *sys_table, 99 - unsigned long *image_addr, 98 + efi_status_t handle_kernel_image(unsigned long *image_addr, 100 99 unsigned long *image_size, 101 100 unsigned long *reserve_addr, 102 101 unsigned long *reserve_size, ··· 134 135 if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) 135 136 goto fail; 136 137 137 - status = check_platform_features(sys_table); 138 + status = check_platform_features(); 138 139 if (status != EFI_SUCCESS) 139 140 goto fail; 140 141 ··· 150 151 goto fail; 151 152 } 152 153 153 - dram_base = get_dram_base(sys_table); 154 + dram_base = get_dram_base(); 154 155 if (dram_base == EFI_ERROR) { 155 156 pr_efi_err("Failed to find DRAM base\n"); 156 157 goto fail; ··· 161 162 * protocol. We are going to copy the command line into the 162 163 * device tree, so this can be allocated anywhere. 163 164 */ 164 - cmdline_ptr = efi_convert_cmdline(sys_table, image, &cmdline_size); 165 + cmdline_ptr = efi_convert_cmdline(image, &cmdline_size); 165 166 if (!cmdline_ptr) { 166 167 pr_efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n"); 167 168 goto fail; ··· 177 178 178 179 pr_efi("Booting Linux Kernel...\n"); 179 180 180 - si = setup_graphics(sys_table); 181 + si = setup_graphics(); 181 182 182 - status = handle_kernel_image(sys_table, image_addr, &image_size, 183 + status = handle_kernel_image(image_addr, &image_size, 183 184 &reserve_addr, 184 185 &reserve_size, 185 186 dram_base, image); ··· 188 189 goto fail_free_cmdline; 189 190 } 190 191 191 - efi_retrieve_tpm2_eventlog(sys_table); 192 + efi_retrieve_tpm2_eventlog(); 192 193 193 194 /* Ask the firmware to clear memory on unclean shutdown */ 194 - efi_enable_reset_attack_mitigation(sys_table); 195 + efi_enable_reset_attack_mitigation(); 195 196 196 - secure_boot = efi_get_secureboot(sys_table); 197 + secure_boot = efi_get_secureboot(); 197 198 198 199 /* 199 200 * Unauthenticated device tree data is a security hazard, so ignore ··· 205 206 if (strstr(cmdline_ptr, "dtb=")) 206 207 pr_efi("Ignoring DTB from command line.\n"); 207 208 } else { 208 - status = handle_cmdline_files(sys_table, image, cmdline_ptr, 209 - "dtb=", 209 + status = handle_cmdline_files(image, cmdline_ptr, "dtb=", 210 210 ~0UL, &fdt_addr, &fdt_size); 211 211 212 212 if (status != EFI_SUCCESS) { ··· 218 220 pr_efi("Using DTB from command line\n"); 219 221 } else { 220 222 /* Look for a device tree configuration table entry. */ 221 - fdt_addr = (uintptr_t)get_fdt(sys_table, &fdt_size); 223 + fdt_addr = (uintptr_t)get_fdt(&fdt_size); 222 224 if (fdt_addr) 223 225 pr_efi("Using DTB from configuration table\n"); 224 226 } ··· 226 228 if (!fdt_addr) 227 229 pr_efi("Generating empty DTB\n"); 228 230 229 - status = handle_cmdline_files(sys_table, image, cmdline_ptr, "initrd=", 231 + status = handle_cmdline_files(image, cmdline_ptr, "initrd=", 230 232 efi_get_max_initrd_addr(dram_base, 231 233 *image_addr), 232 234 (unsigned long *)&initrd_addr, ··· 234 236 if (status != EFI_SUCCESS) 235 237 pr_efi_err("Failed initrd from command line!\n"); 236 238 237 - efi_random_get_seed(sys_table); 239 + efi_random_get_seed(); 238 240 239 241 /* hibernation expects the runtime regions to stay in the same place */ 240 242 if (!IS_ENABLED(CONFIG_HIBERNATION) && !nokaslr()) { ··· 249 251 EFI_RT_VIRTUAL_SIZE; 250 252 u32 rnd; 251 253 252 - status = efi_get_random_bytes(sys_table, sizeof(rnd), 253 - (u8 *)&rnd); 254 + status = efi_get_random_bytes(sizeof(rnd), (u8 *)&rnd); 254 255 if (status == EFI_SUCCESS) { 255 256 virtmap_base = EFI_RT_VIRTUAL_BASE + 256 257 (((headroom >> 21) * rnd) >> (32 - 21)); 257 258 } 258 259 } 259 260 260 - install_memreserve_table(sys_table); 261 + install_memreserve_table(); 261 262 262 263 new_fdt_addr = fdt_addr; 263 - status = allocate_new_fdt_and_exit_boot(sys_table, handle, 264 + status = allocate_new_fdt_and_exit_boot(handle, 264 265 &new_fdt_addr, efi_get_max_fdt_addr(dram_base), 265 266 initrd_addr, initrd_size, cmdline_ptr, 266 267 fdt_addr, fdt_size); ··· 274 277 275 278 pr_efi_err("Failed to update FDT and exit boot services\n"); 276 279 277 - efi_free(sys_table, initrd_size, initrd_addr); 278 - efi_free(sys_table, fdt_size, fdt_addr); 280 + efi_free(initrd_size, initrd_addr); 281 + efi_free(fdt_size, fdt_addr); 279 282 280 283 fail_free_image: 281 - efi_free(sys_table, image_size, *image_addr); 282 - efi_free(sys_table, reserve_size, reserve_addr); 284 + efi_free(image_size, *image_addr); 285 + efi_free(reserve_size, reserve_addr); 283 286 fail_free_cmdline: 284 - free_screen_info(sys_table, si); 285 - efi_free(sys_table, cmdline_size, (unsigned long)cmdline_ptr); 287 + free_screen_info(si); 288 + efi_free(cmdline_size, (unsigned long)cmdline_ptr); 286 289 fail: 287 290 return EFI_ERROR; 288 291 }
+11 -15
drivers/firmware/efi/libstub/arm32-stub.c
··· 7 7 8 8 #include "efistub.h" 9 9 10 - efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) 10 + efi_status_t check_platform_features(void) 11 11 { 12 12 int block; 13 13 ··· 26 26 27 27 static efi_guid_t screen_info_guid = LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID; 28 28 29 - struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg) 29 + struct screen_info *alloc_screen_info(void) 30 30 { 31 31 struct screen_info *si; 32 32 efi_status_t status; ··· 52 52 return NULL; 53 53 } 54 54 55 - void free_screen_info(efi_system_table_t *sys_table_arg, struct screen_info *si) 55 + void free_screen_info(struct screen_info *si) 56 56 { 57 57 if (!si) 58 58 return; ··· 61 61 efi_call_early(free_pool, si); 62 62 } 63 63 64 - static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg, 65 - unsigned long dram_base, 64 + static efi_status_t reserve_kernel_base(unsigned long dram_base, 66 65 unsigned long *reserve_addr, 67 66 unsigned long *reserve_size) 68 67 { ··· 118 119 * released to the OS after ExitBootServices(), the decompressor can 119 120 * safely overwrite them. 120 121 */ 121 - status = efi_get_memory_map(sys_table_arg, &map); 122 + status = efi_get_memory_map(&map); 122 123 if (status != EFI_SUCCESS) { 123 124 pr_efi_err("reserve_kernel_base(): Unable to retrieve memory map.\n"); 124 125 return status; ··· 189 190 return status; 190 191 } 191 192 192 - efi_status_t handle_kernel_image(efi_system_table_t *sys_table, 193 - unsigned long *image_addr, 193 + efi_status_t handle_kernel_image(unsigned long *image_addr, 194 194 unsigned long *image_size, 195 195 unsigned long *reserve_addr, 196 196 unsigned long *reserve_size, ··· 217 219 */ 218 220 kernel_base += TEXT_OFFSET - 5 * PAGE_SIZE; 219 221 220 - status = reserve_kernel_base(sys_table, kernel_base, reserve_addr, 221 - reserve_size); 222 + status = reserve_kernel_base(kernel_base, reserve_addr, reserve_size); 222 223 if (status != EFI_SUCCESS) { 223 224 pr_efi_err("Unable to allocate memory for uncompressed kernel.\n"); 224 225 return status; ··· 228 231 * memory window. 229 232 */ 230 233 *image_size = image->image_size; 231 - status = efi_relocate_kernel(sys_table, image_addr, *image_size, 232 - *image_size, 234 + status = efi_relocate_kernel(image_addr, *image_size, *image_size, 233 235 kernel_base + MAX_UNCOMP_KERNEL_SIZE, 0, 0); 234 236 if (status != EFI_SUCCESS) { 235 237 pr_efi_err("Failed to relocate kernel.\n"); 236 - efi_free(sys_table, *reserve_size, *reserve_addr); 238 + efi_free(*reserve_size, *reserve_addr); 237 239 *reserve_size = 0; 238 240 return status; 239 241 } ··· 244 248 */ 245 249 if (*image_addr + *image_size > dram_base + ZIMAGE_OFFSET_LIMIT) { 246 250 pr_efi_err("Failed to relocate kernel, no low memory available.\n"); 247 - efi_free(sys_table, *reserve_size, *reserve_addr); 251 + efi_free(*reserve_size, *reserve_addr); 248 252 *reserve_size = 0; 249 - efi_free(sys_table, *image_size, *image_addr); 253 + efi_free(*image_size, *image_addr); 250 254 *image_size = 0; 251 255 return EFI_LOAD_ERROR; 252 256 }
+5 -7
drivers/firmware/efi/libstub/arm64-stub.c
··· 21 21 22 22 #include "efistub.h" 23 23 24 - efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) 24 + efi_status_t check_platform_features(void) 25 25 { 26 26 u64 tg; 27 27 ··· 40 40 return EFI_SUCCESS; 41 41 } 42 42 43 - efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg, 44 - unsigned long *image_addr, 43 + efi_status_t handle_kernel_image(unsigned long *image_addr, 45 44 unsigned long *image_size, 46 45 unsigned long *reserve_addr, 47 46 unsigned long *reserve_size, ··· 55 56 56 57 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { 57 58 if (!nokaslr()) { 58 - status = efi_get_random_bytes(sys_table_arg, 59 - sizeof(phys_seed), 59 + status = efi_get_random_bytes(sizeof(phys_seed), 60 60 (u8 *)&phys_seed); 61 61 if (status == EFI_NOT_FOUND) { 62 62 pr_efi("EFI_RNG_PROTOCOL unavailable, no randomness supplied\n"); ··· 106 108 * locate the kernel at a randomized offset in physical memory. 107 109 */ 108 110 *reserve_size = kernel_memsize + offset; 109 - status = efi_random_alloc(sys_table_arg, *reserve_size, 111 + status = efi_random_alloc(*reserve_size, 110 112 MIN_KIMG_ALIGN, reserve_addr, 111 113 (u32)phys_seed); 112 114 ··· 137 139 138 140 if (status != EFI_SUCCESS) { 139 141 *reserve_size = kernel_memsize + TEXT_OFFSET; 140 - status = efi_low_alloc(sys_table_arg, *reserve_size, 142 + status = efi_low_alloc(*reserve_size, 141 143 MIN_KIMG_ALIGN, reserve_addr); 142 144 143 145 if (status != EFI_SUCCESS) {
+33 -41
drivers/firmware/efi/libstub/efi-stub-helper.c
··· 84 84 return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS; 85 85 } 86 86 87 - efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, 88 - struct efi_boot_memmap *map) 87 + efi_status_t efi_get_memory_map(struct efi_boot_memmap *map) 89 88 { 90 89 efi_memory_desc_t *m = NULL; 91 90 efi_status_t status; ··· 134 135 } 135 136 136 137 137 - unsigned long get_dram_base(efi_system_table_t *sys_table_arg) 138 + unsigned long get_dram_base(void) 138 139 { 139 140 efi_status_t status; 140 141 unsigned long map_size, buff_size; ··· 150 151 boot_map.key_ptr = NULL; 151 152 boot_map.buff_size = &buff_size; 152 153 153 - status = efi_get_memory_map(sys_table_arg, &boot_map); 154 + status = efi_get_memory_map(&boot_map); 154 155 if (status != EFI_SUCCESS) 155 156 return membase; 156 157 ··· 171 172 /* 172 173 * Allocate at the highest possible address that is not above 'max'. 173 174 */ 174 - efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, 175 - unsigned long size, unsigned long align, 175 + efi_status_t efi_high_alloc(unsigned long size, unsigned long align, 176 176 unsigned long *addr, unsigned long max) 177 177 { 178 178 unsigned long map_size, desc_size, buff_size; ··· 189 191 boot_map.key_ptr = NULL; 190 192 boot_map.buff_size = &buff_size; 191 193 192 - status = efi_get_memory_map(sys_table_arg, &boot_map); 194 + status = efi_get_memory_map(&boot_map); 193 195 if (status != EFI_SUCCESS) 194 196 goto fail; 195 197 ··· 269 271 /* 270 272 * Allocate at the lowest possible address that is not below 'min'. 271 273 */ 272 - efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg, 273 - unsigned long size, unsigned long align, 274 + efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, 274 275 unsigned long *addr, unsigned long min) 275 276 { 276 277 unsigned long map_size, desc_size, buff_size; ··· 286 289 boot_map.key_ptr = NULL; 287 290 boot_map.buff_size = &buff_size; 288 291 289 - status = efi_get_memory_map(sys_table_arg, &boot_map); 292 + status = efi_get_memory_map(&boot_map); 290 293 if (status != EFI_SUCCESS) 291 294 goto fail; 292 295 ··· 345 348 return status; 346 349 } 347 350 348 - void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, 349 - unsigned long addr) 351 + void efi_free(unsigned long size, unsigned long addr) 350 352 { 351 353 unsigned long nr_pages; 352 354 ··· 356 360 efi_call_early(free_pages, addr, nr_pages); 357 361 } 358 362 359 - static efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, 360 - efi_char16_t *filename_16, void **handle, 361 - u64 *file_sz) 363 + static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16, 364 + void **handle, u64 *file_sz) 362 365 { 363 366 efi_file_handle_t *h, *fh = __fh; 364 367 efi_file_info_t *info; ··· 416 421 return handle->close(handle); 417 422 } 418 423 419 - static efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, 420 - efi_loaded_image_t *image, 424 + static efi_status_t efi_open_volume(efi_loaded_image_t *image, 421 425 efi_file_handle_t **__fh) 422 426 { 423 427 efi_file_io_interface_t *io; ··· 510 516 * We only support loading a file from the same filesystem as 511 517 * the kernel image. 512 518 */ 513 - efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, 514 - efi_loaded_image_t *image, 519 + efi_status_t handle_cmdline_files(efi_loaded_image_t *image, 515 520 char *cmd_line, char *option_string, 516 521 unsigned long max_addr, 517 522 unsigned long *load_addr, ··· 601 608 602 609 /* Only open the volume once. */ 603 610 if (!i) { 604 - status = efi_open_volume(sys_table_arg, image, &fh); 611 + status = efi_open_volume(image, &fh); 605 612 if (status != EFI_SUCCESS) 606 613 goto free_files; 607 614 } 608 615 609 - status = efi_file_size(sys_table_arg, fh, filename_16, 610 - (void **)&file->handle, &file->size); 616 + status = efi_file_size(fh, filename_16, (void **)&file->handle, 617 + &file->size); 611 618 if (status != EFI_SUCCESS) 612 619 goto close_handles; 613 620 ··· 622 629 * so allocate enough memory for all the files. This is used 623 630 * for loading multiple files. 624 631 */ 625 - status = efi_high_alloc(sys_table_arg, file_size_total, 0x1000, 626 - &file_addr, max_addr); 632 + status = efi_high_alloc(file_size_total, 0x1000, &file_addr, 633 + max_addr); 627 634 if (status != EFI_SUCCESS) { 628 635 pr_efi_err("Failed to alloc highmem for files\n"); 629 636 goto close_handles; ··· 673 680 return status; 674 681 675 682 free_file_total: 676 - efi_free(sys_table_arg, file_size_total, file_addr); 683 + efi_free(file_size_total, file_addr); 677 684 678 685 close_handles: 679 686 for (k = j; k < i; k++) ··· 696 703 * address is not available the lowest available address will 697 704 * be used. 698 705 */ 699 - efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, 700 - unsigned long *image_addr, 706 + efi_status_t efi_relocate_kernel(unsigned long *image_addr, 701 707 unsigned long image_size, 702 708 unsigned long alloc_size, 703 709 unsigned long preferred_addr, ··· 734 742 * possible. 735 743 */ 736 744 if (status != EFI_SUCCESS) { 737 - status = efi_low_alloc_above(sys_table_arg, alloc_size, 738 - alignment, &new_addr, min_addr); 745 + status = efi_low_alloc_above(alloc_size, alignment, &new_addr, 746 + min_addr); 739 747 } 740 748 if (status != EFI_SUCCESS) { 741 749 pr_efi_err("Failed to allocate usable memory for kernel.\n"); ··· 812 820 * Size of memory allocated return in *cmd_line_len. 813 821 * Returns NULL on error. 814 822 */ 815 - char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, 816 - efi_loaded_image_t *image, 823 + char *efi_convert_cmdline(efi_loaded_image_t *image, 817 824 int *cmd_line_len) 818 825 { 819 826 const u16 *s2; ··· 841 850 842 851 options_bytes++; /* NUL termination */ 843 852 844 - status = efi_high_alloc(sys_table_arg, options_bytes, 0, 845 - &cmdline_addr, MAX_CMDLINE_ADDRESS); 853 + status = efi_high_alloc(options_bytes, 0, &cmdline_addr, 854 + MAX_CMDLINE_ADDRESS); 846 855 if (status != EFI_SUCCESS) 847 856 return NULL; 848 857 ··· 864 873 * specific structure may be passed to the function via priv. The client 865 874 * function may be called multiple times. 866 875 */ 867 - efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg, 868 - void *handle, 876 + efi_status_t efi_exit_boot_services(void *handle, 869 877 struct efi_boot_memmap *map, 870 878 void *priv, 871 879 efi_exit_boot_map_processing priv_func) 872 880 { 873 881 efi_status_t status; 874 882 875 - status = efi_get_memory_map(sys_table_arg, map); 883 + status = efi_get_memory_map(map); 876 884 877 885 if (status != EFI_SUCCESS) 878 886 goto fail; 879 887 880 - status = priv_func(sys_table_arg, map, priv); 888 + status = priv_func(map, priv); 881 889 if (status != EFI_SUCCESS) 882 890 goto free_map; 883 891 ··· 908 918 if (status != EFI_SUCCESS) 909 919 goto fail; 910 920 911 - status = priv_func(sys_table_arg, map, priv); 921 + status = priv_func(map, priv); 912 922 /* exit_boot_services() was called, thus cannot free */ 913 923 if (status != EFI_SUCCESS) 914 924 goto fail; ··· 928 938 return status; 929 939 } 930 940 931 - void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid) 941 + void *get_efi_config_table(efi_guid_t guid) 932 942 { 933 - unsigned long tables = efi_table_attr(efi_system_table, tables, sys_table); 934 - int nr_tables = efi_table_attr(efi_system_table, nr_tables, sys_table); 943 + unsigned long tables = efi_table_attr(efi_system_table, tables, 944 + efi_system_table()); 945 + int nr_tables = efi_table_attr(efi_system_table, nr_tables, 946 + efi_system_table()); 935 947 int i; 936 948 937 949 for (i = 0; i < nr_tables; i++) {
+7 -10
drivers/firmware/efi/libstub/efistub.h
··· 40 40 void efi_char16_printk(efi_char16_t *); 41 41 void efi_char16_printk(efi_char16_t *); 42 42 43 - unsigned long get_dram_base(efi_system_table_t *sys_table_arg); 43 + unsigned long get_dram_base(void); 44 44 45 - efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, 46 - void *handle, 45 + efi_status_t allocate_new_fdt_and_exit_boot(void *handle, 47 46 unsigned long *new_fdt_addr, 48 47 unsigned long max_addr, 49 48 u64 initrd_addr, u64 initrd_size, ··· 50 51 unsigned long fdt_addr, 51 52 unsigned long fdt_size); 52 53 53 - void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size); 54 + void *get_fdt(unsigned long *fdt_size); 54 55 55 56 void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size, 56 57 unsigned long desc_size, efi_memory_desc_t *runtime_map, 57 58 int *count); 58 59 59 - efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table, 60 - unsigned long size, u8 *out); 60 + efi_status_t efi_get_random_bytes(unsigned long size, u8 *out); 61 61 62 - efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, 63 - unsigned long size, unsigned long align, 62 + efi_status_t efi_random_alloc(unsigned long size, unsigned long align, 64 63 unsigned long *addr, unsigned long random_seed); 65 64 66 - efi_status_t check_platform_features(efi_system_table_t *sys_table_arg); 65 + efi_status_t check_platform_features(void); 67 66 68 - void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid); 67 + void *get_efi_config_table(efi_guid_t guid); 69 68 70 69 /* Helper macros for the usual case of using simple C variables: */ 71 70 #ifndef fdt_setprop_inplace_var
+17 -20
drivers/firmware/efi/libstub/fdt.c
··· 16 16 #define EFI_DT_ADDR_CELLS_DEFAULT 2 17 17 #define EFI_DT_SIZE_CELLS_DEFAULT 2 18 18 19 - static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt) 19 + static void fdt_update_cell_size(void *fdt) 20 20 { 21 21 int offset; 22 22 ··· 27 27 fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT); 28 28 } 29 29 30 - static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, 31 - unsigned long orig_fdt_size, 30 + static efi_status_t update_fdt(void *orig_fdt, unsigned long orig_fdt_size, 32 31 void *fdt, int new_fdt_size, char *cmdline_ptr, 33 32 u64 initrd_addr, u64 initrd_size) 34 33 { ··· 61 62 * Any failure from the following function is 62 63 * non-critical: 63 64 */ 64 - fdt_update_cell_size(sys_table, fdt); 65 + fdt_update_cell_size(fdt); 65 66 } 66 67 } 67 68 ··· 110 111 111 112 /* Add FDT entries for EFI runtime services in chosen node. */ 112 113 node = fdt_subnode_offset(fdt, 0, "chosen"); 113 - fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table); 114 + fdt_val64 = cpu_to_fdt64((u64)(unsigned long)efi_system_table()); 114 115 115 116 status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64); 116 117 if (status) ··· 139 140 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { 140 141 efi_status_t efi_status; 141 142 142 - efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64), 143 + efi_status = efi_get_random_bytes(sizeof(fdt_val64), 143 144 (u8 *)&fdt_val64); 144 145 if (efi_status == EFI_SUCCESS) { 145 146 status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64); ··· 209 210 void *new_fdt_addr; 210 211 }; 211 212 212 - static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, 213 - struct efi_boot_memmap *map, 213 + static efi_status_t exit_boot_func(struct efi_boot_memmap *map, 214 214 void *priv) 215 215 { 216 216 struct exit_boot_struct *p = priv; ··· 242 244 * with the final memory map in it. 243 245 */ 244 246 245 - efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, 246 - void *handle, 247 + efi_status_t allocate_new_fdt_and_exit_boot(void *handle, 247 248 unsigned long *new_fdt_addr, 248 249 unsigned long max_addr, 249 250 u64 initrd_addr, u64 initrd_size, ··· 272 275 * subsequent allocations adding entries, since they could not affect 273 276 * the number of EFI_MEMORY_RUNTIME regions. 274 277 */ 275 - status = efi_get_memory_map(sys_table, &map); 278 + status = efi_get_memory_map(&map); 276 279 if (status != EFI_SUCCESS) { 277 280 pr_efi_err("Unable to retrieve UEFI memory map.\n"); 278 281 return status; ··· 281 284 pr_efi("Exiting boot services and installing virtual address map...\n"); 282 285 283 286 map.map = &memory_map; 284 - status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN, 287 + status = efi_high_alloc(MAX_FDT_SIZE, EFI_FDT_ALIGN, 285 288 new_fdt_addr, max_addr); 286 289 if (status != EFI_SUCCESS) { 287 290 pr_efi_err("Unable to allocate memory for new device tree.\n"); ··· 292 295 * Now that we have done our final memory allocation (and free) 293 296 * we can get the memory map key needed for exit_boot_services(). 294 297 */ 295 - status = efi_get_memory_map(sys_table, &map); 298 + status = efi_get_memory_map(&map); 296 299 if (status != EFI_SUCCESS) 297 300 goto fail_free_new_fdt; 298 301 299 - status = update_fdt(sys_table, (void *)fdt_addr, fdt_size, 302 + status = update_fdt((void *)fdt_addr, fdt_size, 300 303 (void *)*new_fdt_addr, MAX_FDT_SIZE, cmdline_ptr, 301 304 initrd_addr, initrd_size); 302 305 ··· 310 313 priv.runtime_entry_count = &runtime_entry_count; 311 314 priv.new_fdt_addr = (void *)*new_fdt_addr; 312 315 313 - status = efi_exit_boot_services(sys_table, handle, &map, &priv, exit_boot_func); 316 + status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func); 314 317 315 318 if (status == EFI_SUCCESS) { 316 319 efi_set_virtual_address_map_t *svam; ··· 319 322 return EFI_SUCCESS; 320 323 321 324 /* Install the new virtual address map */ 322 - svam = sys_table->runtime->set_virtual_address_map; 325 + svam = efi_system_table()->runtime->set_virtual_address_map; 323 326 status = svam(runtime_entry_count * desc_size, desc_size, 324 327 desc_ver, runtime_map); 325 328 ··· 350 353 pr_efi_err("Exit boot services failed.\n"); 351 354 352 355 fail_free_new_fdt: 353 - efi_free(sys_table, MAX_FDT_SIZE, *new_fdt_addr); 356 + efi_free(MAX_FDT_SIZE, *new_fdt_addr); 354 357 355 358 fail: 356 - sys_table->boottime->free_pool(runtime_map); 359 + efi_system_table()->boottime->free_pool(runtime_map); 357 360 358 361 return EFI_LOAD_ERROR; 359 362 } 360 363 361 - void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size) 364 + void *get_fdt(unsigned long *fdt_size) 362 365 { 363 366 void *fdt; 364 367 365 - fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID); 368 + fdt = get_efi_config_table(DEVICE_TREE_GUID); 366 369 367 370 if (!fdt) 368 371 return NULL;
+4 -6
drivers/firmware/efi/libstub/gop.c
··· 88 88 #define efi_gop_attr(table, attr, instance) \ 89 89 (efi_table_attr(efi_graphics_output_protocol##table, attr, instance)) 90 90 91 - static efi_status_t 92 - setup_gop(efi_system_table_t *sys_table_arg, struct screen_info *si, 93 - efi_guid_t *proto, unsigned long size, void **handles) 91 + static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto, 92 + unsigned long size, void **handles) 94 93 { 95 94 efi_graphics_output_protocol_t *gop, *first_gop; 96 95 u16 width, height; ··· 184 185 /* 185 186 * See if we have Graphics Output Protocol 186 187 */ 187 - efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, 188 - struct screen_info *si, efi_guid_t *proto, 188 + efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, 189 189 unsigned long size) 190 190 { 191 191 efi_status_t status; ··· 201 203 if (status != EFI_SUCCESS) 202 204 goto free_handle; 203 205 204 - status = setup_gop(sys_table_arg, si, proto, size, gop_handle); 206 + status = setup_gop(si, proto, size, gop_handle); 205 207 206 208 free_handle: 207 209 efi_call_early(free_pool, gop_handle);
+4 -6
drivers/firmware/efi/libstub/random.c
··· 26 26 } mixed_mode; 27 27 }; 28 28 29 - efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, 30 - unsigned long size, u8 *out) 29 + efi_status_t efi_get_random_bytes(unsigned long size, u8 *out) 31 30 { 32 31 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 33 32 efi_status_t status; ··· 78 79 */ 79 80 #define MD_NUM_SLOTS(md) ((md)->virt_addr) 80 81 81 - efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, 82 - unsigned long size, 82 + efi_status_t efi_random_alloc(unsigned long size, 83 83 unsigned long align, 84 84 unsigned long *addr, 85 85 unsigned long random_seed) ··· 97 99 map.key_ptr = NULL; 98 100 map.buff_size = &buff_size; 99 101 100 - status = efi_get_memory_map(sys_table_arg, &map); 102 + status = efi_get_memory_map(&map); 101 103 if (status != EFI_SUCCESS) 102 104 return status; 103 105 ··· 153 155 return status; 154 156 } 155 157 156 - efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) 158 + efi_status_t efi_random_get_seed(void) 157 159 { 158 160 efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; 159 161 efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;
+1 -1
drivers/firmware/efi/libstub/secureboot.c
··· 32 32 * Please keep the logic in sync with 33 33 * arch/x86/xen/efi.c:xen_efi_get_secureboot(). 34 34 */ 35 - enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table_arg) 35 + enum efi_secureboot_mode efi_get_secureboot(void) 36 36 { 37 37 u32 attr; 38 38 u8 secboot, setupmode, moksbstate;
+3 -4
drivers/firmware/efi/libstub/tpm.c
··· 36 36 * are cleared. If userland has ensured that all secrets have been removed 37 37 * from RAM before reboot it can simply reset this variable. 38 38 */ 39 - void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) 39 + void efi_enable_reset_attack_mitigation(void) 40 40 { 41 41 u8 val = 1; 42 42 efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID; ··· 57 57 58 58 #endif 59 59 60 - void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) 60 + void efi_retrieve_tpm2_eventlog(void) 61 61 { 62 62 efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; 63 63 efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; ··· 139 139 * Figure out whether any events have already been logged to the 140 140 * final events structure, and if so how much space they take up 141 141 */ 142 - final_events_table = get_efi_config_table(sys_table_arg, 143 - LINUX_EFI_TPM_FINAL_LOG_GUID); 142 + final_events_table = get_efi_config_table(LINUX_EFI_TPM_FINAL_LOG_GUID); 144 143 if (final_events_table && final_events_table->nr_events) { 145 144 struct tcg_pcr_event2_head *header; 146 145 int offset;
+16 -27
include/linux/efi.h
··· 1495 1495 1496 1496 void efi_printk(char *str); 1497 1497 1498 - void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, 1499 - unsigned long addr); 1498 + void efi_free(unsigned long size, unsigned long addr); 1500 1499 1501 - char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, 1502 - efi_loaded_image_t *image, int *cmd_line_len); 1500 + char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len); 1503 1501 1504 - efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, 1505 - struct efi_boot_memmap *map); 1502 + efi_status_t efi_get_memory_map(struct efi_boot_memmap *map); 1506 1503 1507 - efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg, 1508 - unsigned long size, unsigned long align, 1504 + efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, 1509 1505 unsigned long *addr, unsigned long min); 1510 1506 1511 1507 static inline 1512 - efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, 1513 - unsigned long size, unsigned long align, 1508 + efi_status_t efi_low_alloc(unsigned long size, unsigned long align, 1514 1509 unsigned long *addr) 1515 1510 { 1516 1511 /* ··· 1513 1518 * checks pointers against NULL. Skip the first 8 1514 1519 * bytes so we start at a nice even number. 1515 1520 */ 1516 - return efi_low_alloc_above(sys_table_arg, size, align, addr, 0x8); 1521 + return efi_low_alloc_above(size, align, addr, 0x8); 1517 1522 } 1518 1523 1519 - efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, 1520 - unsigned long size, unsigned long align, 1524 + efi_status_t efi_high_alloc(unsigned long size, unsigned long align, 1521 1525 unsigned long *addr, unsigned long max); 1522 1526 1523 - efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, 1524 - unsigned long *image_addr, 1527 + efi_status_t efi_relocate_kernel(unsigned long *image_addr, 1525 1528 unsigned long image_size, 1526 1529 unsigned long alloc_size, 1527 1530 unsigned long preferred_addr, 1528 1531 unsigned long alignment, 1529 1532 unsigned long min_addr); 1530 1533 1531 - efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, 1532 - efi_loaded_image_t *image, 1534 + efi_status_t handle_cmdline_files(efi_loaded_image_t *image, 1533 1535 char *cmd_line, char *option_string, 1534 1536 unsigned long max_addr, 1535 1537 unsigned long *load_addr, ··· 1534 1542 1535 1543 efi_status_t efi_parse_options(char const *cmdline); 1536 1544 1537 - efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, 1538 - struct screen_info *si, efi_guid_t *proto, 1545 + efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, 1539 1546 unsigned long size); 1540 1547 1541 1548 #ifdef CONFIG_EFI ··· 1552 1561 efi_secureboot_mode_disabled, 1553 1562 efi_secureboot_mode_enabled, 1554 1563 }; 1555 - enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table); 1564 + enum efi_secureboot_mode efi_get_secureboot(void); 1556 1565 1557 1566 #ifdef CONFIG_RESET_ATTACK_MITIGATION 1558 - void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg); 1567 + void efi_enable_reset_attack_mitigation(void); 1559 1568 #else 1560 1569 static inline void 1561 - efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) { } 1570 + efi_enable_reset_attack_mitigation(void) { } 1562 1571 #endif 1563 1572 1564 - efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); 1573 + efi_status_t efi_random_get_seed(void); 1565 1574 1566 - void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table); 1575 + void efi_retrieve_tpm2_eventlog(void); 1567 1576 1568 1577 /* 1569 1578 * Arch code can implement the following three template macros, avoiding ··· 1615 1624 }) 1616 1625 1617 1626 typedef efi_status_t (*efi_exit_boot_map_processing)( 1618 - efi_system_table_t *sys_table_arg, 1619 1627 struct efi_boot_memmap *map, 1620 1628 void *priv); 1621 1629 1622 - efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table, 1623 - void *handle, 1630 + efi_status_t efi_exit_boot_services(void *handle, 1624 1631 struct efi_boot_memmap *map, 1625 1632 void *priv, 1626 1633 efi_exit_boot_map_processing priv_func);