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>
This commit is contained in:
Ard Biesheuvel 2019-12-24 16:10:19 +01:00 committed by Ingo Molnar
parent 8173ec7905
commit cd33a5c1d5
14 changed files with 148 additions and 192 deletions

View file

@ -60,8 +60,8 @@ void efi_virtmap_unload(void);
#define efi_call_proto(protocol, f, instance, ...) \ #define efi_call_proto(protocol, f, instance, ...) \
instance->f(instance, ##__VA_ARGS__) instance->f(instance, ##__VA_ARGS__)
struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg); struct screen_info *alloc_screen_info(void);
void free_screen_info(efi_system_table_t *sys_table, struct screen_info *si); void free_screen_info(struct screen_info *si);
static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt) static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
{ {

View file

@ -105,8 +105,7 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
#define alloc_screen_info(x...) &screen_info #define alloc_screen_info(x...) &screen_info
static inline void free_screen_info(efi_system_table_t *sys_table_arg, static inline void free_screen_info(struct screen_info *si)
struct screen_info *si)
{ {
} }

View file

@ -340,7 +340,7 @@ void setup_graphics(struct boot_params *boot_params)
EFI_LOCATE_BY_PROTOCOL, EFI_LOCATE_BY_PROTOCOL,
&graphics_proto, NULL, &size, gop_handle); &graphics_proto, NULL, &size, gop_handle);
if (status == EFI_BUFFER_TOO_SMALL) if (status == EFI_BUFFER_TOO_SMALL)
status = efi_setup_gop(NULL, si, &graphics_proto, size); status = efi_setup_gop(si, &graphics_proto, size);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
size = 0; size = 0;
@ -390,8 +390,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
return status; return status;
} }
status = efi_low_alloc(sys_table, 0x4000, 1, status = efi_low_alloc(0x4000, 1, (unsigned long *)&boot_params);
(unsigned long *)&boot_params);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate lowmem for boot params\n"); efi_printk("Failed to allocate lowmem for boot params\n");
return status; return status;
@ -416,7 +415,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
hdr->type_of_loader = 0x21; hdr->type_of_loader = 0x21;
/* Convert unicode cmdline to ascii */ /* Convert unicode cmdline to ascii */
cmdline_ptr = efi_convert_cmdline(sys_table, image, &options_size); cmdline_ptr = efi_convert_cmdline(image, &options_size);
if (!cmdline_ptr) if (!cmdline_ptr)
goto fail; goto fail;
@ -434,7 +433,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail2; goto fail2;
status = handle_cmdline_files(sys_table, image, status = handle_cmdline_files(image,
(char *)(unsigned long)hdr->cmd_line_ptr, (char *)(unsigned long)hdr->cmd_line_ptr,
"initrd=", hdr->initrd_addr_max, "initrd=", hdr->initrd_addr_max,
&ramdisk_addr, &ramdisk_size); &ramdisk_addr, &ramdisk_size);
@ -442,7 +441,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
if (status != EFI_SUCCESS && if (status != EFI_SUCCESS &&
hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G) { hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G) {
efi_printk("Trying to load files to higher address\n"); efi_printk("Trying to load files to higher address\n");
status = handle_cmdline_files(sys_table, image, status = handle_cmdline_files(image,
(char *)(unsigned long)hdr->cmd_line_ptr, (char *)(unsigned long)hdr->cmd_line_ptr,
"initrd=", -1UL, "initrd=", -1UL,
&ramdisk_addr, &ramdisk_size); &ramdisk_addr, &ramdisk_size);
@ -461,9 +460,9 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
/* not reached */ /* not reached */
fail2: fail2:
efi_free(sys_table, options_size, hdr->cmd_line_ptr); efi_free(options_size, hdr->cmd_line_ptr);
fail: fail:
efi_free(sys_table, 0x4000, (unsigned long)boot_params); efi_free(0x4000, (unsigned long)boot_params);
return status; return status;
} }
@ -630,7 +629,7 @@ static efi_status_t allocate_e820(struct boot_params *params,
boot_map.key_ptr = NULL; boot_map.key_ptr = NULL;
boot_map.buff_size = &buff_size; boot_map.buff_size = &buff_size;
status = efi_get_memory_map(sys_table, &boot_map); status = efi_get_memory_map(&boot_map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
@ -652,8 +651,7 @@ struct exit_boot_struct {
struct efi_info *efi; struct efi_info *efi;
}; };
static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, static efi_status_t exit_boot_func(struct efi_boot_memmap *map,
struct efi_boot_memmap *map,
void *priv) void *priv)
{ {
const char *signature; const char *signature;
@ -663,14 +661,14 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg,
: EFI32_LOADER_SIGNATURE; : EFI32_LOADER_SIGNATURE;
memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32)); memcpy(&p->efi->efi_loader_signature, signature, sizeof(__u32));
p->efi->efi_systab = (unsigned long)sys_table_arg; p->efi->efi_systab = (unsigned long)efi_system_table();
p->efi->efi_memdesc_size = *map->desc_size; p->efi->efi_memdesc_size = *map->desc_size;
p->efi->efi_memdesc_version = *map->desc_ver; p->efi->efi_memdesc_version = *map->desc_ver;
p->efi->efi_memmap = (unsigned long)*map->map; p->efi->efi_memmap = (unsigned long)*map->map;
p->efi->efi_memmap_size = *map->map_size; p->efi->efi_memmap_size = *map->map_size;
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
p->efi->efi_systab_hi = (unsigned long)sys_table_arg >> 32; p->efi->efi_systab_hi = (unsigned long)efi_system_table() >> 32;
p->efi->efi_memmap_hi = (unsigned long)*map->map >> 32; p->efi->efi_memmap_hi = (unsigned long)*map->map >> 32;
#endif #endif
@ -702,8 +700,7 @@ static efi_status_t exit_boot(struct boot_params *boot_params, void *handle)
return status; return status;
/* Might as well exit boot services now */ /* Might as well exit boot services now */
status = efi_exit_boot_services(sys_table, handle, &map, &priv, status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func);
exit_boot_func);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
@ -755,14 +752,14 @@ struct boot_params *efi_main(efi_handle_t handle,
* otherwise we ask the BIOS. * otherwise we ask the BIOS.
*/ */
if (boot_params->secure_boot == efi_secureboot_mode_unset) if (boot_params->secure_boot == efi_secureboot_mode_unset)
boot_params->secure_boot = efi_get_secureboot(sys_table); boot_params->secure_boot = efi_get_secureboot();
/* Ask the firmware to clear memory on unclean shutdown */ /* Ask the firmware to clear memory on unclean shutdown */
efi_enable_reset_attack_mitigation(sys_table); efi_enable_reset_attack_mitigation();
efi_random_get_seed(sys_table); efi_random_get_seed();
efi_retrieve_tpm2_eventlog(sys_table); efi_retrieve_tpm2_eventlog();
setup_graphics(boot_params); setup_graphics(boot_params);
@ -778,8 +775,7 @@ struct boot_params *efi_main(efi_handle_t handle,
} }
gdt->size = 0x800; gdt->size = 0x800;
status = efi_low_alloc(sys_table, gdt->size, 8, status = efi_low_alloc(gdt->size, 8, (unsigned long *)&gdt->address);
(unsigned long *)&gdt->address);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate memory for 'gdt'\n"); efi_printk("Failed to allocate memory for 'gdt'\n");
goto fail; goto fail;
@ -791,7 +787,7 @@ struct boot_params *efi_main(efi_handle_t handle,
*/ */
if (hdr->pref_address != hdr->code32_start) { if (hdr->pref_address != hdr->code32_start) {
unsigned long bzimage_addr = hdr->code32_start; unsigned long bzimage_addr = hdr->code32_start;
status = efi_relocate_kernel(sys_table, &bzimage_addr, status = efi_relocate_kernel(&bzimage_addr,
hdr->init_size, hdr->init_size, hdr->init_size, hdr->init_size,
hdr->pref_address, hdr->pref_address,
hdr->kernel_alignment, hdr->kernel_alignment,

View file

@ -44,7 +44,7 @@ __pure efi_system_table_t *efi_system_table(void)
return sys_table; return sys_table;
} }
static struct screen_info *setup_graphics(efi_system_table_t *sys_table_arg) static struct screen_info *setup_graphics(void)
{ {
efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; efi_guid_t gop_proto = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
efi_status_t status; efi_status_t status;
@ -56,15 +56,15 @@ static struct screen_info *setup_graphics(efi_system_table_t *sys_table_arg)
status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL,
&gop_proto, NULL, &size, gop_handle); &gop_proto, NULL, &size, gop_handle);
if (status == EFI_BUFFER_TOO_SMALL) { if (status == EFI_BUFFER_TOO_SMALL) {
si = alloc_screen_info(sys_table_arg); si = alloc_screen_info();
if (!si) if (!si)
return NULL; return NULL;
efi_setup_gop(sys_table_arg, si, &gop_proto, size); efi_setup_gop(si, &gop_proto, size);
} }
return si; return si;
} }
void install_memreserve_table(efi_system_table_t *sys_table_arg) void install_memreserve_table(void)
{ {
struct linux_efi_memreserve *rsv; struct linux_efi_memreserve *rsv;
efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
@ -95,8 +95,7 @@ void install_memreserve_table(efi_system_table_t *sys_table_arg)
* must be reserved. On failure it is required to free all * must be reserved. On failure it is required to free all
* all allocations it has made. * all allocations it has made.
*/ */
efi_status_t handle_kernel_image(efi_system_table_t *sys_table, efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_addr,
unsigned long *image_size, unsigned long *image_size,
unsigned long *reserve_addr, unsigned long *reserve_addr,
unsigned long *reserve_size, unsigned long *reserve_size,
@ -135,7 +134,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
goto fail; goto fail;
status = check_platform_features(sys_table); status = check_platform_features();
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
@ -151,7 +150,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
goto fail; goto fail;
} }
dram_base = get_dram_base(sys_table); dram_base = get_dram_base();
if (dram_base == EFI_ERROR) { if (dram_base == EFI_ERROR) {
pr_efi_err("Failed to find DRAM base\n"); pr_efi_err("Failed to find DRAM base\n");
goto fail; goto fail;
@ -162,7 +161,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
* protocol. We are going to copy the command line into the * protocol. We are going to copy the command line into the
* device tree, so this can be allocated anywhere. * device tree, so this can be allocated anywhere.
*/ */
cmdline_ptr = efi_convert_cmdline(sys_table, image, &cmdline_size); cmdline_ptr = efi_convert_cmdline(image, &cmdline_size);
if (!cmdline_ptr) { if (!cmdline_ptr) {
pr_efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n"); pr_efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n");
goto fail; goto fail;
@ -178,9 +177,9 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
pr_efi("Booting Linux Kernel...\n"); pr_efi("Booting Linux Kernel...\n");
si = setup_graphics(sys_table); si = setup_graphics();
status = handle_kernel_image(sys_table, image_addr, &image_size, status = handle_kernel_image(image_addr, &image_size,
&reserve_addr, &reserve_addr,
&reserve_size, &reserve_size,
dram_base, image); dram_base, image);
@ -189,12 +188,12 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
goto fail_free_cmdline; goto fail_free_cmdline;
} }
efi_retrieve_tpm2_eventlog(sys_table); efi_retrieve_tpm2_eventlog();
/* Ask the firmware to clear memory on unclean shutdown */ /* Ask the firmware to clear memory on unclean shutdown */
efi_enable_reset_attack_mitigation(sys_table); efi_enable_reset_attack_mitigation();
secure_boot = efi_get_secureboot(sys_table); secure_boot = efi_get_secureboot();
/* /*
* Unauthenticated device tree data is a security hazard, so ignore * Unauthenticated device tree data is a security hazard, so ignore
@ -206,8 +205,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
if (strstr(cmdline_ptr, "dtb=")) if (strstr(cmdline_ptr, "dtb="))
pr_efi("Ignoring DTB from command line.\n"); pr_efi("Ignoring DTB from command line.\n");
} else { } else {
status = handle_cmdline_files(sys_table, image, cmdline_ptr, status = handle_cmdline_files(image, cmdline_ptr, "dtb=",
"dtb=",
~0UL, &fdt_addr, &fdt_size); ~0UL, &fdt_addr, &fdt_size);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
@ -220,7 +218,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
pr_efi("Using DTB from command line\n"); pr_efi("Using DTB from command line\n");
} else { } else {
/* Look for a device tree configuration table entry. */ /* Look for a device tree configuration table entry. */
fdt_addr = (uintptr_t)get_fdt(sys_table, &fdt_size); fdt_addr = (uintptr_t)get_fdt(&fdt_size);
if (fdt_addr) if (fdt_addr)
pr_efi("Using DTB from configuration table\n"); pr_efi("Using DTB from configuration table\n");
} }
@ -228,7 +226,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
if (!fdt_addr) if (!fdt_addr)
pr_efi("Generating empty DTB\n"); pr_efi("Generating empty DTB\n");
status = handle_cmdline_files(sys_table, image, cmdline_ptr, "initrd=", status = handle_cmdline_files(image, cmdline_ptr, "initrd=",
efi_get_max_initrd_addr(dram_base, efi_get_max_initrd_addr(dram_base,
*image_addr), *image_addr),
(unsigned long *)&initrd_addr, (unsigned long *)&initrd_addr,
@ -236,7 +234,7 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
pr_efi_err("Failed initrd from command line!\n"); pr_efi_err("Failed initrd from command line!\n");
efi_random_get_seed(sys_table); efi_random_get_seed();
/* hibernation expects the runtime regions to stay in the same place */ /* hibernation expects the runtime regions to stay in the same place */
if (!IS_ENABLED(CONFIG_HIBERNATION) && !nokaslr()) { if (!IS_ENABLED(CONFIG_HIBERNATION) && !nokaslr()) {
@ -251,18 +249,17 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
EFI_RT_VIRTUAL_SIZE; EFI_RT_VIRTUAL_SIZE;
u32 rnd; u32 rnd;
status = efi_get_random_bytes(sys_table, sizeof(rnd), status = efi_get_random_bytes(sizeof(rnd), (u8 *)&rnd);
(u8 *)&rnd);
if (status == EFI_SUCCESS) { if (status == EFI_SUCCESS) {
virtmap_base = EFI_RT_VIRTUAL_BASE + virtmap_base = EFI_RT_VIRTUAL_BASE +
(((headroom >> 21) * rnd) >> (32 - 21)); (((headroom >> 21) * rnd) >> (32 - 21));
} }
} }
install_memreserve_table(sys_table); install_memreserve_table();
new_fdt_addr = fdt_addr; new_fdt_addr = fdt_addr;
status = allocate_new_fdt_and_exit_boot(sys_table, handle, status = allocate_new_fdt_and_exit_boot(handle,
&new_fdt_addr, efi_get_max_fdt_addr(dram_base), &new_fdt_addr, efi_get_max_fdt_addr(dram_base),
initrd_addr, initrd_size, cmdline_ptr, initrd_addr, initrd_size, cmdline_ptr,
fdt_addr, fdt_size); fdt_addr, fdt_size);
@ -277,15 +274,15 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table_arg,
pr_efi_err("Failed to update FDT and exit boot services\n"); pr_efi_err("Failed to update FDT and exit boot services\n");
efi_free(sys_table, initrd_size, initrd_addr); efi_free(initrd_size, initrd_addr);
efi_free(sys_table, fdt_size, fdt_addr); efi_free(fdt_size, fdt_addr);
fail_free_image: fail_free_image:
efi_free(sys_table, image_size, *image_addr); efi_free(image_size, *image_addr);
efi_free(sys_table, reserve_size, reserve_addr); efi_free(reserve_size, reserve_addr);
fail_free_cmdline: fail_free_cmdline:
free_screen_info(sys_table, si); free_screen_info(si);
efi_free(sys_table, cmdline_size, (unsigned long)cmdline_ptr); efi_free(cmdline_size, (unsigned long)cmdline_ptr);
fail: fail:
return EFI_ERROR; return EFI_ERROR;
} }

View file

@ -7,7 +7,7 @@
#include "efistub.h" #include "efistub.h"
efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) efi_status_t check_platform_features(void)
{ {
int block; int block;
@ -26,7 +26,7 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg)
static efi_guid_t screen_info_guid = LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID; static efi_guid_t screen_info_guid = LINUX_EFI_ARM_SCREEN_INFO_TABLE_GUID;
struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg) struct screen_info *alloc_screen_info(void)
{ {
struct screen_info *si; struct screen_info *si;
efi_status_t status; efi_status_t status;
@ -52,7 +52,7 @@ struct screen_info *alloc_screen_info(efi_system_table_t *sys_table_arg)
return NULL; return NULL;
} }
void free_screen_info(efi_system_table_t *sys_table_arg, struct screen_info *si) void free_screen_info(struct screen_info *si)
{ {
if (!si) if (!si)
return; return;
@ -61,8 +61,7 @@ void free_screen_info(efi_system_table_t *sys_table_arg, struct screen_info *si)
efi_call_early(free_pool, si); efi_call_early(free_pool, si);
} }
static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg, static efi_status_t reserve_kernel_base(unsigned long dram_base,
unsigned long dram_base,
unsigned long *reserve_addr, unsigned long *reserve_addr,
unsigned long *reserve_size) unsigned long *reserve_size)
{ {
@ -119,7 +118,7 @@ static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg,
* released to the OS after ExitBootServices(), the decompressor can * released to the OS after ExitBootServices(), the decompressor can
* safely overwrite them. * safely overwrite them.
*/ */
status = efi_get_memory_map(sys_table_arg, &map); status = efi_get_memory_map(&map);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("reserve_kernel_base(): Unable to retrieve memory map.\n"); pr_efi_err("reserve_kernel_base(): Unable to retrieve memory map.\n");
return status; return status;
@ -190,8 +189,7 @@ static efi_status_t reserve_kernel_base(efi_system_table_t *sys_table_arg,
return status; return status;
} }
efi_status_t handle_kernel_image(efi_system_table_t *sys_table, efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_addr,
unsigned long *image_size, unsigned long *image_size,
unsigned long *reserve_addr, unsigned long *reserve_addr,
unsigned long *reserve_size, unsigned long *reserve_size,
@ -219,8 +217,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
*/ */
kernel_base += TEXT_OFFSET - 5 * PAGE_SIZE; kernel_base += TEXT_OFFSET - 5 * PAGE_SIZE;
status = reserve_kernel_base(sys_table, kernel_base, reserve_addr, status = reserve_kernel_base(kernel_base, reserve_addr, reserve_size);
reserve_size);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Unable to allocate memory for uncompressed kernel.\n"); pr_efi_err("Unable to allocate memory for uncompressed kernel.\n");
return status; return status;
@ -231,12 +228,11 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
* memory window. * memory window.
*/ */
*image_size = image->image_size; *image_size = image->image_size;
status = efi_relocate_kernel(sys_table, image_addr, *image_size, status = efi_relocate_kernel(image_addr, *image_size, *image_size,
*image_size,
kernel_base + MAX_UNCOMP_KERNEL_SIZE, 0, 0); kernel_base + MAX_UNCOMP_KERNEL_SIZE, 0, 0);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Failed to relocate kernel.\n"); pr_efi_err("Failed to relocate kernel.\n");
efi_free(sys_table, *reserve_size, *reserve_addr); efi_free(*reserve_size, *reserve_addr);
*reserve_size = 0; *reserve_size = 0;
return status; return status;
} }
@ -248,9 +244,9 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table,
*/ */
if (*image_addr + *image_size > dram_base + ZIMAGE_OFFSET_LIMIT) { if (*image_addr + *image_size > dram_base + ZIMAGE_OFFSET_LIMIT) {
pr_efi_err("Failed to relocate kernel, no low memory available.\n"); pr_efi_err("Failed to relocate kernel, no low memory available.\n");
efi_free(sys_table, *reserve_size, *reserve_addr); efi_free(*reserve_size, *reserve_addr);
*reserve_size = 0; *reserve_size = 0;
efi_free(sys_table, *image_size, *image_addr); efi_free(*image_size, *image_addr);
*image_size = 0; *image_size = 0;
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }

View file

@ -21,7 +21,7 @@
#include "efistub.h" #include "efistub.h"
efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) efi_status_t check_platform_features(void)
{ {
u64 tg; u64 tg;
@ -40,8 +40,7 @@ efi_status_t check_platform_features(efi_system_table_t *sys_table_arg)
return EFI_SUCCESS; return EFI_SUCCESS;
} }
efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg, efi_status_t handle_kernel_image(unsigned long *image_addr,
unsigned long *image_addr,
unsigned long *image_size, unsigned long *image_size,
unsigned long *reserve_addr, unsigned long *reserve_addr,
unsigned long *reserve_size, unsigned long *reserve_size,
@ -56,8 +55,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg,
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
if (!nokaslr()) { if (!nokaslr()) {
status = efi_get_random_bytes(sys_table_arg, status = efi_get_random_bytes(sizeof(phys_seed),
sizeof(phys_seed),
(u8 *)&phys_seed); (u8 *)&phys_seed);
if (status == EFI_NOT_FOUND) { if (status == EFI_NOT_FOUND) {
pr_efi("EFI_RNG_PROTOCOL unavailable, no randomness supplied\n"); pr_efi("EFI_RNG_PROTOCOL unavailable, no randomness supplied\n");
@ -108,7 +106,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg,
* locate the kernel at a randomized offset in physical memory. * locate the kernel at a randomized offset in physical memory.
*/ */
*reserve_size = kernel_memsize + offset; *reserve_size = kernel_memsize + offset;
status = efi_random_alloc(sys_table_arg, *reserve_size, status = efi_random_alloc(*reserve_size,
MIN_KIMG_ALIGN, reserve_addr, MIN_KIMG_ALIGN, reserve_addr,
(u32)phys_seed); (u32)phys_seed);
@ -139,7 +137,7 @@ efi_status_t handle_kernel_image(efi_system_table_t *sys_table_arg,
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
*reserve_size = kernel_memsize + TEXT_OFFSET; *reserve_size = kernel_memsize + TEXT_OFFSET;
status = efi_low_alloc(sys_table_arg, *reserve_size, status = efi_low_alloc(*reserve_size,
MIN_KIMG_ALIGN, reserve_addr); MIN_KIMG_ALIGN, reserve_addr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {

View file

@ -84,8 +84,7 @@ static inline bool mmap_has_headroom(unsigned long buff_size,
return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS; return slack / desc_size >= EFI_MMAP_NR_SLACK_SLOTS;
} }
efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
struct efi_boot_memmap *map)
{ {
efi_memory_desc_t *m = NULL; efi_memory_desc_t *m = NULL;
efi_status_t status; efi_status_t status;
@ -135,7 +134,7 @@ efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg,
} }
unsigned long get_dram_base(efi_system_table_t *sys_table_arg) unsigned long get_dram_base(void)
{ {
efi_status_t status; efi_status_t status;
unsigned long map_size, buff_size; unsigned long map_size, buff_size;
@ -151,7 +150,7 @@ unsigned long get_dram_base(efi_system_table_t *sys_table_arg)
boot_map.key_ptr = NULL; boot_map.key_ptr = NULL;
boot_map.buff_size = &buff_size; boot_map.buff_size = &buff_size;
status = efi_get_memory_map(sys_table_arg, &boot_map); status = efi_get_memory_map(&boot_map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return membase; return membase;
@ -172,8 +171,7 @@ unsigned long get_dram_base(efi_system_table_t *sys_table_arg)
/* /*
* Allocate at the highest possible address that is not above 'max'. * Allocate at the highest possible address that is not above 'max'.
*/ */
efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, efi_status_t efi_high_alloc(unsigned long size, unsigned long align,
unsigned long size, unsigned long align,
unsigned long *addr, unsigned long max) unsigned long *addr, unsigned long max)
{ {
unsigned long map_size, desc_size, buff_size; unsigned long map_size, desc_size, buff_size;
@ -191,7 +189,7 @@ efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
boot_map.key_ptr = NULL; boot_map.key_ptr = NULL;
boot_map.buff_size = &buff_size; boot_map.buff_size = &buff_size;
status = efi_get_memory_map(sys_table_arg, &boot_map); status = efi_get_memory_map(&boot_map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
@ -271,8 +269,7 @@ efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg,
/* /*
* Allocate at the lowest possible address that is not below 'min'. * Allocate at the lowest possible address that is not below 'min'.
*/ */
efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg, efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
unsigned long size, unsigned long align,
unsigned long *addr, unsigned long min) unsigned long *addr, unsigned long min)
{ {
unsigned long map_size, desc_size, buff_size; unsigned long map_size, desc_size, buff_size;
@ -289,7 +286,7 @@ efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg,
boot_map.key_ptr = NULL; boot_map.key_ptr = NULL;
boot_map.buff_size = &buff_size; boot_map.buff_size = &buff_size;
status = efi_get_memory_map(sys_table_arg, &boot_map); status = efi_get_memory_map(&boot_map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
@ -348,8 +345,7 @@ efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg,
return status; return status;
} }
void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, void efi_free(unsigned long size, unsigned long addr)
unsigned long addr)
{ {
unsigned long nr_pages; unsigned long nr_pages;
@ -360,9 +356,8 @@ void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
efi_call_early(free_pages, addr, nr_pages); efi_call_early(free_pages, addr, nr_pages);
} }
static efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16,
efi_char16_t *filename_16, void **handle, void **handle, u64 *file_sz)
u64 *file_sz)
{ {
efi_file_handle_t *h, *fh = __fh; efi_file_handle_t *h, *fh = __fh;
efi_file_info_t *info; efi_file_info_t *info;
@ -421,8 +416,7 @@ static efi_status_t efi_file_close(efi_file_handle_t *handle)
return handle->close(handle); return handle->close(handle);
} }
static efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, static efi_status_t efi_open_volume(efi_loaded_image_t *image,
efi_loaded_image_t *image,
efi_file_handle_t **__fh) efi_file_handle_t **__fh)
{ {
efi_file_io_interface_t *io; efi_file_io_interface_t *io;
@ -516,8 +510,7 @@ efi_status_t efi_parse_options(char const *cmdline)
* We only support loading a file from the same filesystem as * We only support loading a file from the same filesystem as
* the kernel image. * the kernel image.
*/ */
efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
efi_loaded_image_t *image,
char *cmd_line, char *option_string, char *cmd_line, char *option_string,
unsigned long max_addr, unsigned long max_addr,
unsigned long *load_addr, unsigned long *load_addr,
@ -608,13 +601,13 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
/* Only open the volume once. */ /* Only open the volume once. */
if (!i) { if (!i) {
status = efi_open_volume(sys_table_arg, image, &fh); status = efi_open_volume(image, &fh);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_files; goto free_files;
} }
status = efi_file_size(sys_table_arg, fh, filename_16, status = efi_file_size(fh, filename_16, (void **)&file->handle,
(void **)&file->handle, &file->size); &file->size);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto close_handles; goto close_handles;
@ -629,8 +622,8 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
* so allocate enough memory for all the files. This is used * so allocate enough memory for all the files. This is used
* for loading multiple files. * for loading multiple files.
*/ */
status = efi_high_alloc(sys_table_arg, file_size_total, 0x1000, status = efi_high_alloc(file_size_total, 0x1000, &file_addr,
&file_addr, max_addr); max_addr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Failed to alloc highmem for files\n"); pr_efi_err("Failed to alloc highmem for files\n");
goto close_handles; goto close_handles;
@ -680,7 +673,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
return status; return status;
free_file_total: free_file_total:
efi_free(sys_table_arg, file_size_total, file_addr); efi_free(file_size_total, file_addr);
close_handles: close_handles:
for (k = j; k < i; k++) for (k = j; k < i; k++)
@ -703,8 +696,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
* address is not available the lowest available address will * address is not available the lowest available address will
* be used. * be used.
*/ */
efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, efi_status_t efi_relocate_kernel(unsigned long *image_addr,
unsigned long *image_addr,
unsigned long image_size, unsigned long image_size,
unsigned long alloc_size, unsigned long alloc_size,
unsigned long preferred_addr, unsigned long preferred_addr,
@ -742,8 +734,8 @@ efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg,
* possible. * possible.
*/ */
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
status = efi_low_alloc_above(sys_table_arg, alloc_size, status = efi_low_alloc_above(alloc_size, alignment, &new_addr,
alignment, &new_addr, min_addr); min_addr);
} }
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Failed to allocate usable memory for kernel.\n"); pr_efi_err("Failed to allocate usable memory for kernel.\n");
@ -820,8 +812,7 @@ static u8 *efi_utf16_to_utf8(u8 *dst, const u16 *src, int n)
* Size of memory allocated return in *cmd_line_len. * Size of memory allocated return in *cmd_line_len.
* Returns NULL on error. * Returns NULL on error.
*/ */
char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, char *efi_convert_cmdline(efi_loaded_image_t *image,
efi_loaded_image_t *image,
int *cmd_line_len) int *cmd_line_len)
{ {
const u16 *s2; const u16 *s2;
@ -850,8 +841,8 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
options_bytes++; /* NUL termination */ options_bytes++; /* NUL termination */
status = efi_high_alloc(sys_table_arg, options_bytes, 0, status = efi_high_alloc(options_bytes, 0, &cmdline_addr,
&cmdline_addr, MAX_CMDLINE_ADDRESS); MAX_CMDLINE_ADDRESS);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return NULL; return NULL;
@ -873,20 +864,19 @@ char *efi_convert_cmdline(efi_system_table_t *sys_table_arg,
* specific structure may be passed to the function via priv. The client * specific structure may be passed to the function via priv. The client
* function may be called multiple times. * function may be called multiple times.
*/ */
efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg, efi_status_t efi_exit_boot_services(void *handle,
void *handle,
struct efi_boot_memmap *map, struct efi_boot_memmap *map,
void *priv, void *priv,
efi_exit_boot_map_processing priv_func) efi_exit_boot_map_processing priv_func)
{ {
efi_status_t status; efi_status_t status;
status = efi_get_memory_map(sys_table_arg, map); status = efi_get_memory_map(map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
status = priv_func(sys_table_arg, map, priv); status = priv_func(map, priv);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_map; goto free_map;
@ -918,7 +908,7 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg,
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
status = priv_func(sys_table_arg, map, priv); status = priv_func(map, priv);
/* exit_boot_services() was called, thus cannot free */ /* exit_boot_services() was called, thus cannot free */
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
@ -938,10 +928,12 @@ efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table_arg,
return status; return status;
} }
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid) void *get_efi_config_table(efi_guid_t guid)
{ {
unsigned long tables = efi_table_attr(efi_system_table, tables, sys_table); unsigned long tables = efi_table_attr(efi_system_table, tables,
int nr_tables = efi_table_attr(efi_system_table, nr_tables, sys_table); efi_system_table());
int nr_tables = efi_table_attr(efi_system_table, nr_tables,
efi_system_table());
int i; int i;
for (i = 0; i < nr_tables; i++) { for (i = 0; i < nr_tables; i++) {

View file

@ -40,10 +40,9 @@ extern __pure efi_system_table_t *efi_system_table(void);
void efi_char16_printk(efi_char16_t *); void efi_char16_printk(efi_char16_t *);
void efi_char16_printk(efi_char16_t *); void efi_char16_printk(efi_char16_t *);
unsigned long get_dram_base(efi_system_table_t *sys_table_arg); unsigned long get_dram_base(void);
efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
void *handle,
unsigned long *new_fdt_addr, unsigned long *new_fdt_addr,
unsigned long max_addr, unsigned long max_addr,
u64 initrd_addr, u64 initrd_size, u64 initrd_addr, u64 initrd_size,
@ -51,22 +50,20 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
unsigned long fdt_addr, unsigned long fdt_addr,
unsigned long fdt_size); unsigned long fdt_size);
void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size); void *get_fdt(unsigned long *fdt_size);
void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size, void efi_get_virtmap(efi_memory_desc_t *memory_map, unsigned long map_size,
unsigned long desc_size, efi_memory_desc_t *runtime_map, unsigned long desc_size, efi_memory_desc_t *runtime_map,
int *count); int *count);
efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table, efi_status_t efi_get_random_bytes(unsigned long size, u8 *out);
unsigned long size, u8 *out);
efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, efi_status_t efi_random_alloc(unsigned long size, unsigned long align,
unsigned long size, unsigned long align,
unsigned long *addr, unsigned long random_seed); unsigned long *addr, unsigned long random_seed);
efi_status_t check_platform_features(efi_system_table_t *sys_table_arg); efi_status_t check_platform_features(void);
void *get_efi_config_table(efi_system_table_t *sys_table, efi_guid_t guid); void *get_efi_config_table(efi_guid_t guid);
/* Helper macros for the usual case of using simple C variables: */ /* Helper macros for the usual case of using simple C variables: */
#ifndef fdt_setprop_inplace_var #ifndef fdt_setprop_inplace_var

View file

@ -16,7 +16,7 @@
#define EFI_DT_ADDR_CELLS_DEFAULT 2 #define EFI_DT_ADDR_CELLS_DEFAULT 2
#define EFI_DT_SIZE_CELLS_DEFAULT 2 #define EFI_DT_SIZE_CELLS_DEFAULT 2
static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt) static void fdt_update_cell_size(void *fdt)
{ {
int offset; int offset;
@ -27,8 +27,7 @@ static void fdt_update_cell_size(efi_system_table_t *sys_table, void *fdt)
fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT); fdt_setprop_u32(fdt, offset, "#size-cells", EFI_DT_SIZE_CELLS_DEFAULT);
} }
static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, static efi_status_t update_fdt(void *orig_fdt, unsigned long orig_fdt_size,
unsigned long orig_fdt_size,
void *fdt, int new_fdt_size, char *cmdline_ptr, void *fdt, int new_fdt_size, char *cmdline_ptr,
u64 initrd_addr, u64 initrd_size) u64 initrd_addr, u64 initrd_size)
{ {
@ -62,7 +61,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
* Any failure from the following function is * Any failure from the following function is
* non-critical: * non-critical:
*/ */
fdt_update_cell_size(sys_table, fdt); fdt_update_cell_size(fdt);
} }
} }
@ -111,7 +110,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
/* Add FDT entries for EFI runtime services in chosen node. */ /* Add FDT entries for EFI runtime services in chosen node. */
node = fdt_subnode_offset(fdt, 0, "chosen"); node = fdt_subnode_offset(fdt, 0, "chosen");
fdt_val64 = cpu_to_fdt64((u64)(unsigned long)sys_table); fdt_val64 = cpu_to_fdt64((u64)(unsigned long)efi_system_table());
status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64); status = fdt_setprop_var(fdt, node, "linux,uefi-system-table", fdt_val64);
if (status) if (status)
@ -140,7 +139,7 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt,
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) {
efi_status_t efi_status; efi_status_t efi_status;
efi_status = efi_get_random_bytes(sys_table, sizeof(fdt_val64), efi_status = efi_get_random_bytes(sizeof(fdt_val64),
(u8 *)&fdt_val64); (u8 *)&fdt_val64);
if (efi_status == EFI_SUCCESS) { if (efi_status == EFI_SUCCESS) {
status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64); status = fdt_setprop_var(fdt, node, "kaslr-seed", fdt_val64);
@ -210,8 +209,7 @@ struct exit_boot_struct {
void *new_fdt_addr; void *new_fdt_addr;
}; };
static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg, static efi_status_t exit_boot_func(struct efi_boot_memmap *map,
struct efi_boot_memmap *map,
void *priv) void *priv)
{ {
struct exit_boot_struct *p = priv; struct exit_boot_struct *p = priv;
@ -244,8 +242,7 @@ static efi_status_t exit_boot_func(efi_system_table_t *sys_table_arg,
* with the final memory map in it. * with the final memory map in it.
*/ */
efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table, efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
void *handle,
unsigned long *new_fdt_addr, unsigned long *new_fdt_addr,
unsigned long max_addr, unsigned long max_addr,
u64 initrd_addr, u64 initrd_size, u64 initrd_addr, u64 initrd_size,
@ -275,7 +272,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
* subsequent allocations adding entries, since they could not affect * subsequent allocations adding entries, since they could not affect
* the number of EFI_MEMORY_RUNTIME regions. * the number of EFI_MEMORY_RUNTIME regions.
*/ */
status = efi_get_memory_map(sys_table, &map); status = efi_get_memory_map(&map);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Unable to retrieve UEFI memory map.\n"); pr_efi_err("Unable to retrieve UEFI memory map.\n");
return status; return status;
@ -284,7 +281,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
pr_efi("Exiting boot services and installing virtual address map...\n"); pr_efi("Exiting boot services and installing virtual address map...\n");
map.map = &memory_map; map.map = &memory_map;
status = efi_high_alloc(sys_table, MAX_FDT_SIZE, EFI_FDT_ALIGN, status = efi_high_alloc(MAX_FDT_SIZE, EFI_FDT_ALIGN,
new_fdt_addr, max_addr); new_fdt_addr, max_addr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Unable to allocate memory for new device tree.\n"); pr_efi_err("Unable to allocate memory for new device tree.\n");
@ -295,11 +292,11 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
* Now that we have done our final memory allocation (and free) * Now that we have done our final memory allocation (and free)
* we can get the memory map key needed for exit_boot_services(). * we can get the memory map key needed for exit_boot_services().
*/ */
status = efi_get_memory_map(sys_table, &map); status = efi_get_memory_map(&map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail_free_new_fdt; goto fail_free_new_fdt;
status = update_fdt(sys_table, (void *)fdt_addr, fdt_size, status = update_fdt((void *)fdt_addr, fdt_size,
(void *)*new_fdt_addr, MAX_FDT_SIZE, cmdline_ptr, (void *)*new_fdt_addr, MAX_FDT_SIZE, cmdline_ptr,
initrd_addr, initrd_size); initrd_addr, initrd_size);
@ -313,7 +310,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
priv.runtime_entry_count = &runtime_entry_count; priv.runtime_entry_count = &runtime_entry_count;
priv.new_fdt_addr = (void *)*new_fdt_addr; priv.new_fdt_addr = (void *)*new_fdt_addr;
status = efi_exit_boot_services(sys_table, handle, &map, &priv, exit_boot_func); status = efi_exit_boot_services(handle, &map, &priv, exit_boot_func);
if (status == EFI_SUCCESS) { if (status == EFI_SUCCESS) {
efi_set_virtual_address_map_t *svam; efi_set_virtual_address_map_t *svam;
@ -322,7 +319,7 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
return EFI_SUCCESS; return EFI_SUCCESS;
/* Install the new virtual address map */ /* Install the new virtual address map */
svam = sys_table->runtime->set_virtual_address_map; svam = efi_system_table()->runtime->set_virtual_address_map;
status = svam(runtime_entry_count * desc_size, desc_size, status = svam(runtime_entry_count * desc_size, desc_size,
desc_ver, runtime_map); desc_ver, runtime_map);
@ -353,19 +350,19 @@ efi_status_t allocate_new_fdt_and_exit_boot(efi_system_table_t *sys_table,
pr_efi_err("Exit boot services failed.\n"); pr_efi_err("Exit boot services failed.\n");
fail_free_new_fdt: fail_free_new_fdt:
efi_free(sys_table, MAX_FDT_SIZE, *new_fdt_addr); efi_free(MAX_FDT_SIZE, *new_fdt_addr);
fail: fail:
sys_table->boottime->free_pool(runtime_map); efi_system_table()->boottime->free_pool(runtime_map);
return EFI_LOAD_ERROR; return EFI_LOAD_ERROR;
} }
void *get_fdt(efi_system_table_t *sys_table, unsigned long *fdt_size) void *get_fdt(unsigned long *fdt_size)
{ {
void *fdt; void *fdt;
fdt = get_efi_config_table(sys_table, DEVICE_TREE_GUID); fdt = get_efi_config_table(DEVICE_TREE_GUID);
if (!fdt) if (!fdt)
return NULL; return NULL;

View file

@ -88,9 +88,8 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
#define efi_gop_attr(table, attr, instance) \ #define efi_gop_attr(table, attr, instance) \
(efi_table_attr(efi_graphics_output_protocol##table, attr, instance)) (efi_table_attr(efi_graphics_output_protocol##table, attr, instance))
static efi_status_t static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
setup_gop(efi_system_table_t *sys_table_arg, struct screen_info *si, unsigned long size, void **handles)
efi_guid_t *proto, unsigned long size, void **handles)
{ {
efi_graphics_output_protocol_t *gop, *first_gop; efi_graphics_output_protocol_t *gop, *first_gop;
u16 width, height; u16 width, height;
@ -185,8 +184,7 @@ setup_gop(efi_system_table_t *sys_table_arg, struct screen_info *si,
/* /*
* See if we have Graphics Output Protocol * See if we have Graphics Output Protocol
*/ */
efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
struct screen_info *si, efi_guid_t *proto,
unsigned long size) unsigned long size)
{ {
efi_status_t status; efi_status_t status;
@ -203,7 +201,7 @@ efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg,
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_handle; goto free_handle;
status = setup_gop(sys_table_arg, si, proto, size, gop_handle); status = setup_gop(si, proto, size, gop_handle);
free_handle: free_handle:
efi_call_early(free_pool, gop_handle); efi_call_early(free_pool, gop_handle);

View file

@ -26,8 +26,7 @@ union efi_rng_protocol {
} mixed_mode; } mixed_mode;
}; };
efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, efi_status_t efi_get_random_bytes(unsigned long size, u8 *out)
unsigned long size, u8 *out)
{ {
efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
efi_status_t status; efi_status_t status;
@ -79,8 +78,7 @@ static unsigned long get_entry_num_slots(efi_memory_desc_t *md,
*/ */
#define MD_NUM_SLOTS(md) ((md)->virt_addr) #define MD_NUM_SLOTS(md) ((md)->virt_addr)
efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg, efi_status_t efi_random_alloc(unsigned long size,
unsigned long size,
unsigned long align, unsigned long align,
unsigned long *addr, unsigned long *addr,
unsigned long random_seed) unsigned long random_seed)
@ -99,7 +97,7 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
map.key_ptr = NULL; map.key_ptr = NULL;
map.buff_size = &buff_size; map.buff_size = &buff_size;
status = efi_get_memory_map(sys_table_arg, &map); status = efi_get_memory_map(&map);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
@ -155,7 +153,7 @@ efi_status_t efi_random_alloc(efi_system_table_t *sys_table_arg,
return status; return status;
} }
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) efi_status_t efi_random_get_seed(void)
{ {
efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID;
efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW;

View file

@ -32,7 +32,7 @@ static const efi_char16_t shim_MokSBState_name[] = L"MokSBState";
* Please keep the logic in sync with * Please keep the logic in sync with
* arch/x86/xen/efi.c:xen_efi_get_secureboot(). * arch/x86/xen/efi.c:xen_efi_get_secureboot().
*/ */
enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table_arg) enum efi_secureboot_mode efi_get_secureboot(void)
{ {
u32 attr; u32 attr;
u8 secboot, setupmode, moksbstate; u8 secboot, setupmode, moksbstate;

View file

@ -36,7 +36,7 @@ static const efi_char16_t efi_MemoryOverWriteRequest_name[] =
* are cleared. If userland has ensured that all secrets have been removed * are cleared. If userland has ensured that all secrets have been removed
* from RAM before reboot it can simply reset this variable. * from RAM before reboot it can simply reset this variable.
*/ */
void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) void efi_enable_reset_attack_mitigation(void)
{ {
u8 val = 1; u8 val = 1;
efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID; efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID;
@ -57,7 +57,7 @@ void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg)
#endif #endif
void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) void efi_retrieve_tpm2_eventlog(void)
{ {
efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID;
efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID;
@ -139,8 +139,7 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg)
* Figure out whether any events have already been logged to the * Figure out whether any events have already been logged to the
* final events structure, and if so how much space they take up * final events structure, and if so how much space they take up
*/ */
final_events_table = get_efi_config_table(sys_table_arg, final_events_table = get_efi_config_table(LINUX_EFI_TPM_FINAL_LOG_GUID);
LINUX_EFI_TPM_FINAL_LOG_GUID);
if (final_events_table && final_events_table->nr_events) { if (final_events_table && final_events_table->nr_events) {
struct tcg_pcr_event2_head *header; struct tcg_pcr_event2_head *header;
int offset; int offset;

View file

@ -1495,22 +1495,17 @@ static inline int efi_runtime_map_copy(void *buf, size_t bufsz)
void efi_printk(char *str); void efi_printk(char *str);
void efi_free(efi_system_table_t *sys_table_arg, unsigned long size, void efi_free(unsigned long size, unsigned long addr);
unsigned long addr);
char *efi_convert_cmdline(efi_system_table_t *sys_table_arg, char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
efi_loaded_image_t *image, int *cmd_line_len);
efi_status_t efi_get_memory_map(efi_system_table_t *sys_table_arg, efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
struct efi_boot_memmap *map);
efi_status_t efi_low_alloc_above(efi_system_table_t *sys_table_arg, efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
unsigned long size, unsigned long align,
unsigned long *addr, unsigned long min); unsigned long *addr, unsigned long min);
static inline static inline
efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg, efi_status_t efi_low_alloc(unsigned long size, unsigned long align,
unsigned long size, unsigned long align,
unsigned long *addr) unsigned long *addr)
{ {
/* /*
@ -1518,23 +1513,20 @@ efi_status_t efi_low_alloc(efi_system_table_t *sys_table_arg,
* checks pointers against NULL. Skip the first 8 * checks pointers against NULL. Skip the first 8
* bytes so we start at a nice even number. * bytes so we start at a nice even number.
*/ */
return efi_low_alloc_above(sys_table_arg, size, align, addr, 0x8); return efi_low_alloc_above(size, align, addr, 0x8);
} }
efi_status_t efi_high_alloc(efi_system_table_t *sys_table_arg, efi_status_t efi_high_alloc(unsigned long size, unsigned long align,
unsigned long size, unsigned long align,
unsigned long *addr, unsigned long max); unsigned long *addr, unsigned long max);
efi_status_t efi_relocate_kernel(efi_system_table_t *sys_table_arg, efi_status_t efi_relocate_kernel(unsigned long *image_addr,
unsigned long *image_addr,
unsigned long image_size, unsigned long image_size,
unsigned long alloc_size, unsigned long alloc_size,
unsigned long preferred_addr, unsigned long preferred_addr,
unsigned long alignment, unsigned long alignment,
unsigned long min_addr); unsigned long min_addr);
efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg, efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
efi_loaded_image_t *image,
char *cmd_line, char *option_string, char *cmd_line, char *option_string,
unsigned long max_addr, unsigned long max_addr,
unsigned long *load_addr, unsigned long *load_addr,
@ -1542,8 +1534,7 @@ efi_status_t handle_cmdline_files(efi_system_table_t *sys_table_arg,
efi_status_t efi_parse_options(char const *cmdline); efi_status_t efi_parse_options(char const *cmdline);
efi_status_t efi_setup_gop(efi_system_table_t *sys_table_arg, efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
struct screen_info *si, efi_guid_t *proto,
unsigned long size); unsigned long size);
#ifdef CONFIG_EFI #ifdef CONFIG_EFI
@ -1561,18 +1552,18 @@ enum efi_secureboot_mode {
efi_secureboot_mode_disabled, efi_secureboot_mode_disabled,
efi_secureboot_mode_enabled, efi_secureboot_mode_enabled,
}; };
enum efi_secureboot_mode efi_get_secureboot(efi_system_table_t *sys_table); enum efi_secureboot_mode efi_get_secureboot(void);
#ifdef CONFIG_RESET_ATTACK_MITIGATION #ifdef CONFIG_RESET_ATTACK_MITIGATION
void efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg); void efi_enable_reset_attack_mitigation(void);
#else #else
static inline void static inline void
efi_enable_reset_attack_mitigation(efi_system_table_t *sys_table_arg) { } efi_enable_reset_attack_mitigation(void) { }
#endif #endif
efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg); efi_status_t efi_random_get_seed(void);
void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table); void efi_retrieve_tpm2_eventlog(void);
/* /*
* Arch code can implement the following three template macros, avoiding * Arch code can implement the following three template macros, avoiding
@ -1624,12 +1615,10 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table);
}) })
typedef efi_status_t (*efi_exit_boot_map_processing)( typedef efi_status_t (*efi_exit_boot_map_processing)(
efi_system_table_t *sys_table_arg,
struct efi_boot_memmap *map, struct efi_boot_memmap *map,
void *priv); void *priv);
efi_status_t efi_exit_boot_services(efi_system_table_t *sys_table, efi_status_t efi_exit_boot_services(void *handle,
void *handle,
struct efi_boot_memmap *map, struct efi_boot_memmap *map,
void *priv, void *priv,
efi_exit_boot_map_processing priv_func); efi_exit_boot_map_processing priv_func);