Commit 966291f6 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Ingo Molnar

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

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

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

While at it, use 'func' as the macro parameter name for the function
pointers, which is less likely to collide and cause weird build errors.
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Borislav Petkov <bp@alien8.de>
Cc: James Morse <james.morse@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191224151025.32482-24-ardb@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 99ea8b1d
...@@ -50,9 +50,9 @@ void efi_virtmap_unload(void); ...@@ -50,9 +50,9 @@ void efi_virtmap_unload(void);
/* arch specific definitions used by the stub code */ /* arch specific definitions used by the stub code */
#define efi_call_early(f, ...) efi_system_table()->boottime->f(__VA_ARGS__) #define efi_bs_call(func, ...) efi_system_table()->boottime->func(__VA_ARGS__)
#define efi_call_runtime(f, ...) efi_system_table()->runtime->f(__VA_ARGS__) #define efi_rt_call(func, ...) efi_system_table()->runtime->func(__VA_ARGS__)
#define efi_is_native() (true) #define efi_is_native() (true)
#define efi_table_attr(inst, attr) (inst->attr) #define efi_table_attr(inst, attr) (inst->attr)
......
...@@ -93,9 +93,9 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base, ...@@ -93,9 +93,9 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
return (image_addr & ~(SZ_1G - 1UL)) + (1UL << (VA_BITS_MIN - 1)); return (image_addr & ~(SZ_1G - 1UL)) + (1UL << (VA_BITS_MIN - 1));
} }
#define efi_call_early(f, ...) efi_system_table()->boottime->f(__VA_ARGS__) #define efi_bs_call(func, ...) efi_system_table()->boottime->func(__VA_ARGS__)
#define efi_call_runtime(f, ...) efi_system_table()->runtime->f(__VA_ARGS__) #define efi_rt_call(func, ...) efi_system_table()->runtime->func(__VA_ARGS__)
#define efi_is_native() (true) #define efi_is_native() (true)
#define efi_table_attr(inst, attr) (inst->attr) #define efi_table_attr(inst, attr) (inst->attr)
......
...@@ -54,8 +54,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) ...@@ -54,8 +54,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
size = romsize + sizeof(*rom); size = romsize + sizeof(*rom);
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size,
(void **)&rom); (void **)&rom);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate memory for 'rom'\n"); efi_printk("Failed to allocate memory for 'rom'\n");
return status; return status;
...@@ -95,7 +95,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) ...@@ -95,7 +95,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
return status; return status;
free_struct: free_struct:
efi_call_early(free_pool, rom); efi_bs_call(free_pool, rom);
return status; return status;
} }
...@@ -119,23 +119,20 @@ static void setup_efi_pci(struct boot_params *params) ...@@ -119,23 +119,20 @@ static void setup_efi_pci(struct boot_params *params)
efi_handle_t h; efi_handle_t h;
int i; int i;
status = efi_call_early(locate_handle, status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL,
EFI_LOCATE_BY_PROTOCOL, &pci_proto, NULL, &size, pci_handle);
&pci_proto, NULL, &size, pci_handle);
if (status == EFI_BUFFER_TOO_SMALL) { if (status == EFI_BUFFER_TOO_SMALL) {
status = efi_call_early(allocate_pool, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size,
EFI_LOADER_DATA, (void **)&pci_handle);
size, (void **)&pci_handle);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate memory for 'pci_handle'\n"); efi_printk("Failed to allocate memory for 'pci_handle'\n");
return; return;
} }
status = efi_call_early(locate_handle, status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL,
EFI_LOCATE_BY_PROTOCOL, &pci_proto, &pci_proto, NULL, &size, pci_handle);
NULL, &size, pci_handle);
} }
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
...@@ -150,8 +147,8 @@ static void setup_efi_pci(struct boot_params *params) ...@@ -150,8 +147,8 @@ static void setup_efi_pci(struct boot_params *params)
efi_pci_io_protocol_t *pci = NULL; efi_pci_io_protocol_t *pci = NULL;
struct pci_setup_rom *rom; struct pci_setup_rom *rom;
status = efi_call_early(handle_protocol, h, status = efi_bs_call(handle_protocol, h, &pci_proto,
&pci_proto, (void **)&pci); (void **)&pci);
if (status != EFI_SUCCESS || !pci) if (status != EFI_SUCCESS || !pci)
continue; continue;
...@@ -168,7 +165,7 @@ static void setup_efi_pci(struct boot_params *params) ...@@ -168,7 +165,7 @@ static void setup_efi_pci(struct boot_params *params)
} }
free_handle: free_handle:
efi_call_early(free_pool, pci_handle); efi_bs_call(free_pool, pci_handle);
} }
static void retrieve_apple_device_properties(struct boot_params *boot_params) static void retrieve_apple_device_properties(struct boot_params *boot_params)
...@@ -179,7 +176,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) ...@@ -179,7 +176,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
u32 size = 0; u32 size = 0;
apple_properties_protocol_t *p; apple_properties_protocol_t *p;
status = efi_call_early(locate_protocol, &guid, NULL, (void **)&p); status = efi_bs_call(locate_protocol, &guid, NULL, (void **)&p);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return; return;
...@@ -193,9 +190,9 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) ...@@ -193,9 +190,9 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
return; return;
do { do {
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
size + sizeof(struct setup_data), size + sizeof(struct setup_data),
(void **)&new); (void **)&new);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate memory for 'properties'\n"); efi_printk("Failed to allocate memory for 'properties'\n");
return; return;
...@@ -204,7 +201,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) ...@@ -204,7 +201,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
status = efi_call_proto(p, get_all, new->data, &size); status = efi_call_proto(p, get_all, new->data, &size);
if (status == EFI_BUFFER_TOO_SMALL) if (status == EFI_BUFFER_TOO_SMALL)
efi_call_early(free_pool, new); efi_bs_call(free_pool, new);
} while (status == EFI_BUFFER_TOO_SMALL); } while (status == EFI_BUFFER_TOO_SMALL);
new->type = SETUP_APPLE_PROPERTIES; new->type = SETUP_APPLE_PROPERTIES;
...@@ -248,14 +245,13 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size) ...@@ -248,14 +245,13 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size)
efi_handle_t handle; efi_handle_t handle;
int i; int i;
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size,
size, (void **)&uga_handle); (void **)&uga_handle);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
status = efi_call_early(locate_handle, status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL,
EFI_LOCATE_BY_PROTOCOL, uga_proto, NULL, &size, uga_handle);
uga_proto, NULL, &size, uga_handle);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_handle; goto free_handle;
...@@ -268,13 +264,13 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size) ...@@ -268,13 +264,13 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size)
u32 w, h, depth, refresh; u32 w, h, depth, refresh;
void *pciio; void *pciio;
status = efi_call_early(handle_protocol, handle, status = efi_bs_call(handle_protocol, handle, uga_proto,
uga_proto, (void **)&uga); (void **)&uga);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
continue; continue;
pciio = NULL; pciio = NULL;
efi_call_early(handle_protocol, handle, &pciio_proto, &pciio); efi_bs_call(handle_protocol, handle, &pciio_proto, &pciio);
status = efi_call_proto(uga, get_mode, &w, &h, &depth, &refresh); status = efi_call_proto(uga, get_mode, &w, &h, &depth, &refresh);
if (status == EFI_SUCCESS && (!first_uga || pciio)) { if (status == EFI_SUCCESS && (!first_uga || pciio)) {
...@@ -312,7 +308,7 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size) ...@@ -312,7 +308,7 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size)
si->rsvd_pos = 24; si->rsvd_pos = 24;
free_handle: free_handle:
efi_call_early(free_pool, uga_handle); efi_bs_call(free_pool, uga_handle);
return status; return status;
} }
...@@ -331,17 +327,15 @@ void setup_graphics(struct boot_params *boot_params) ...@@ -331,17 +327,15 @@ void setup_graphics(struct boot_params *boot_params)
memset(si, 0, sizeof(*si)); memset(si, 0, sizeof(*si));
size = 0; size = 0;
status = efi_call_early(locate_handle, status = efi_bs_call(locate_handle, 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(si, &graphics_proto, size); status = efi_setup_gop(si, &graphics_proto, size);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
size = 0; size = 0;
status = efi_call_early(locate_handle, status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL,
EFI_LOCATE_BY_PROTOCOL, &uga_proto, NULL, &size, uga_handle);
&uga_proto, NULL, &size, uga_handle);
if (status == EFI_BUFFER_TOO_SMALL) if (status == EFI_BUFFER_TOO_SMALL)
setup_uga(si, &uga_proto, size); setup_uga(si, &uga_proto, size);
} }
...@@ -378,8 +372,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, ...@@ -378,8 +372,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
return EFI_INVALID_PARAMETER; return EFI_INVALID_PARAMETER;
status = efi_call_early(handle_protocol, handle, status = efi_bs_call(handle_protocol, handle, &proto, (void *)&image);
&proto, (void *)&image);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n"); efi_printk("Failed to get handle for LOADED_IMAGE_PROTOCOL\n");
return status; return status;
...@@ -594,13 +587,13 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext, ...@@ -594,13 +587,13 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext,
sizeof(struct e820_entry) * nr_desc; sizeof(struct e820_entry) * nr_desc;
if (*e820ext) { if (*e820ext) {
efi_call_early(free_pool, *e820ext); efi_bs_call(free_pool, *e820ext);
*e820ext = NULL; *e820ext = NULL;
*e820ext_size = 0; *e820ext_size = 0;
} }
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size,
size, (void **)e820ext); (void **)e820ext);
if (status == EFI_SUCCESS) if (status == EFI_SUCCESS)
*e820ext_size = size; *e820ext_size = size;
...@@ -762,8 +755,8 @@ struct boot_params *efi_main(efi_handle_t handle, ...@@ -762,8 +755,8 @@ struct boot_params *efi_main(efi_handle_t handle,
setup_quirks(boot_params); setup_quirks(boot_params);
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*gdt),
sizeof(*gdt), (void **)&gdt); (void **)&gdt);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate memory for 'gdt' structure\n"); efi_printk("Failed to allocate memory for 'gdt' structure\n");
goto fail; goto fail;
......
...@@ -227,17 +227,17 @@ static inline bool efi_is_native(void) ...@@ -227,17 +227,17 @@ static inline bool efi_is_native(void)
? inst->func(inst, ##__VA_ARGS__) \ ? inst->func(inst, ##__VA_ARGS__) \
: efi64_thunk(inst->mixed_mode.func, inst, ##__VA_ARGS__)) : efi64_thunk(inst->mixed_mode.func, inst, ##__VA_ARGS__))
#define efi_call_early(f, ...) \ #define efi_bs_call(func, ...) \
(efi_is_native() \ (efi_is_native() \
? efi_system_table()->boottime->f(__VA_ARGS__) \ ? efi_system_table()->boottime->func(__VA_ARGS__) \
: efi64_thunk(efi_table_attr(efi_system_table(), \ : efi64_thunk(efi_table_attr(efi_system_table(), \
boottime)->mixed_mode.f, __VA_ARGS__)) boottime)->mixed_mode.func, __VA_ARGS__))
#define efi_call_runtime(f, ...) \ #define efi_rt_call(func, ...) \
(efi_is_native() \ (efi_is_native() \
? efi_system_table()->runtime->f(__VA_ARGS__) \ ? efi_system_table()->runtime->func(__VA_ARGS__) \
: efi64_thunk(efi_table_attr(efi_system_table(), \ : efi64_thunk(efi_table_attr(efi_system_table(), \
runtime)->mixed_mode.f, __VA_ARGS__)) runtime)->mixed_mode.func, __VA_ARGS__))
extern bool efi_reboot_required(void); extern bool efi_reboot_required(void);
extern bool efi_is_table_address(unsigned long phys_addr); extern bool efi_is_table_address(unsigned long phys_addr);
......
...@@ -53,8 +53,8 @@ static struct screen_info *setup_graphics(void) ...@@ -53,8 +53,8 @@ static struct screen_info *setup_graphics(void)
struct screen_info *si = NULL; struct screen_info *si = NULL;
size = 0; size = 0;
status = efi_call_early(locate_handle, EFI_LOCATE_BY_PROTOCOL, status = efi_bs_call(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(); si = alloc_screen_info();
if (!si) if (!si)
...@@ -70,8 +70,8 @@ void install_memreserve_table(void) ...@@ -70,8 +70,8 @@ void install_memreserve_table(void)
efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID;
efi_status_t status; efi_status_t status;
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv), status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv),
(void **)&rsv); (void **)&rsv);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Failed to allocate memreserve entry!\n"); pr_efi_err("Failed to allocate memreserve entry!\n");
return; return;
...@@ -81,9 +81,8 @@ void install_memreserve_table(void) ...@@ -81,9 +81,8 @@ void install_memreserve_table(void)
rsv->size = 0; rsv->size = 0;
atomic_set(&rsv->count, 0); atomic_set(&rsv->count, 0);
status = efi_call_early(install_configuration_table, status = efi_bs_call(install_configuration_table,
&memreserve_table_guid, &memreserve_table_guid, rsv);
rsv);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
pr_efi_err("Failed to install memreserve config table!\n"); pr_efi_err("Failed to install memreserve config table!\n");
} }
......
...@@ -37,18 +37,18 @@ struct screen_info *alloc_screen_info(void) ...@@ -37,18 +37,18 @@ struct screen_info *alloc_screen_info(void)
* its contents while we hand over to the kernel proper from the * its contents while we hand over to the kernel proper from the
* decompressor. * decompressor.
*/ */
status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA, status = efi_bs_call(allocate_pool, EFI_RUNTIME_SERVICES_DATA,
sizeof(*si), (void **)&si); sizeof(*si), (void **)&si);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return NULL; return NULL;
status = efi_call_early(install_configuration_table, status = efi_bs_call(install_configuration_table,
&screen_info_guid, si); &screen_info_guid, si);
if (status == EFI_SUCCESS) if (status == EFI_SUCCESS)
return si; return si;
efi_call_early(free_pool, si); efi_bs_call(free_pool, si);
return NULL; return NULL;
} }
...@@ -57,8 +57,8 @@ void free_screen_info(struct screen_info *si) ...@@ -57,8 +57,8 @@ void free_screen_info(struct screen_info *si)
if (!si) if (!si)
return; return;
efi_call_early(install_configuration_table, &screen_info_guid, NULL); efi_bs_call(install_configuration_table, &screen_info_guid, NULL);
efi_call_early(free_pool, si); efi_bs_call(free_pool, si);
} }
static efi_status_t reserve_kernel_base(unsigned long dram_base, static efi_status_t reserve_kernel_base(unsigned long dram_base,
...@@ -91,8 +91,8 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base, ...@@ -91,8 +91,8 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base,
*/ */
alloc_addr = dram_base + MAX_UNCOMP_KERNEL_SIZE; alloc_addr = dram_base + MAX_UNCOMP_KERNEL_SIZE;
nr_pages = MAX_UNCOMP_KERNEL_SIZE / EFI_PAGE_SIZE; nr_pages = MAX_UNCOMP_KERNEL_SIZE / EFI_PAGE_SIZE;
status = efi_call_early(allocate_pages, EFI_ALLOCATE_MAX_ADDRESS, status = efi_bs_call(allocate_pages, EFI_ALLOCATE_MAX_ADDRESS,
EFI_BOOT_SERVICES_DATA, nr_pages, &alloc_addr); EFI_BOOT_SERVICES_DATA, nr_pages, &alloc_addr);
if (status == EFI_SUCCESS) { if (status == EFI_SUCCESS) {
if (alloc_addr == dram_base) { if (alloc_addr == dram_base) {
*reserve_addr = alloc_addr; *reserve_addr = alloc_addr;
...@@ -156,11 +156,11 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base, ...@@ -156,11 +156,11 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base,
start = max(start, (u64)dram_base); start = max(start, (u64)dram_base);
end = min(end, (u64)dram_base + MAX_UNCOMP_KERNEL_SIZE); end = min(end, (u64)dram_base + MAX_UNCOMP_KERNEL_SIZE);
status = efi_call_early(allocate_pages, status = efi_bs_call(allocate_pages,
EFI_ALLOCATE_ADDRESS, EFI_ALLOCATE_ADDRESS,
EFI_LOADER_DATA, EFI_LOADER_DATA,
(end - start) / EFI_PAGE_SIZE, (end - start) / EFI_PAGE_SIZE,
&start); &start);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("reserve_kernel_base(): alloc failed.\n"); pr_efi_err("reserve_kernel_base(): alloc failed.\n");
goto out; goto out;
...@@ -185,7 +185,7 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base, ...@@ -185,7 +185,7 @@ static efi_status_t reserve_kernel_base(unsigned long dram_base,
status = EFI_SUCCESS; status = EFI_SUCCESS;
out: out:
efi_call_early(free_pool, memory_map); efi_bs_call(free_pool, memory_map);
return status; return status;
} }
......
...@@ -129,10 +129,10 @@ efi_status_t handle_kernel_image(unsigned long *image_addr, ...@@ -129,10 +129,10 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,
*image_addr = *reserve_addr = preferred_offset; *image_addr = *reserve_addr = preferred_offset;
*reserve_size = round_up(kernel_memsize, EFI_ALLOC_ALIGN); *reserve_size = round_up(kernel_memsize, EFI_ALLOC_ALIGN);
status = efi_call_early(allocate_pages, EFI_ALLOCATE_ADDRESS, status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
EFI_LOADER_DATA, EFI_LOADER_DATA,
*reserve_size / EFI_PAGE_SIZE, *reserve_size / EFI_PAGE_SIZE,
(efi_physical_addr_t *)reserve_addr); (efi_physical_addr_t *)reserve_addr);
} }
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
......
...@@ -95,19 +95,19 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap *map) ...@@ -95,19 +95,19 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
*map->map_size = *map->desc_size * 32; *map->map_size = *map->desc_size * 32;
*map->buff_size = *map->map_size; *map->buff_size = *map->map_size;
again: again:
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
*map->map_size, (void **)&m); *map->map_size, (void **)&m);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
*map->desc_size = 0; *map->desc_size = 0;
key = 0; key = 0;
status = efi_call_early(get_memory_map, map->map_size, m, status = efi_bs_call(get_memory_map, map->map_size, m,
&key, map->desc_size, &desc_version); &key, map->desc_size, &desc_version);
if (status == EFI_BUFFER_TOO_SMALL || if (status == EFI_BUFFER_TOO_SMALL ||
!mmap_has_headroom(*map->buff_size, *map->map_size, !mmap_has_headroom(*map->buff_size, *map->map_size,
*map->desc_size)) { *map->desc_size)) {
efi_call_early(free_pool, m); efi_bs_call(free_pool, m);
/* /*
* Make sure there is some entries of headroom so that the * Make sure there is some entries of headroom so that the
* buffer can be reused for a new map after allocations are * buffer can be reused for a new map after allocations are
...@@ -121,7 +121,7 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap *map) ...@@ -121,7 +121,7 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap *map)
} }
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
efi_call_early(free_pool, m); efi_bs_call(free_pool, m);
if (map->key_ptr && status == EFI_SUCCESS) if (map->key_ptr && status == EFI_SUCCESS)
*map->key_ptr = key; *map->key_ptr = key;
...@@ -163,7 +163,7 @@ unsigned long get_dram_base(void) ...@@ -163,7 +163,7 @@ unsigned long get_dram_base(void)
} }
} }
efi_call_early(free_pool, map.map); efi_bs_call(free_pool, map.map);
return membase; return membase;
} }
...@@ -249,9 +249,8 @@ efi_status_t efi_high_alloc(unsigned long size, unsigned long align, ...@@ -249,9 +249,8 @@ efi_status_t efi_high_alloc(unsigned long size, unsigned long align,
if (!max_addr) if (!max_addr)
status = EFI_NOT_FOUND; status = EFI_NOT_FOUND;
else { else {
status = efi_call_early(allocate_pages, status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, EFI_LOADER_DATA, nr_pages, &max_addr);
nr_pages, &max_addr);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
max = max_addr; max = max_addr;
max_addr = 0; max_addr = 0;
...@@ -261,7 +260,7 @@ efi_status_t efi_high_alloc(unsigned long size, unsigned long align, ...@@ -261,7 +260,7 @@ efi_status_t efi_high_alloc(unsigned long size, unsigned long align,
*addr = max_addr; *addr = max_addr;
} }
efi_call_early(free_pool, map); efi_bs_call(free_pool, map);
fail: fail:
return status; return status;
} }
...@@ -328,9 +327,8 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, ...@@ -328,9 +327,8 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
if ((start + size) > end) if ((start + size) > end)
continue; continue;
status = efi_call_early(allocate_pages, status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, EFI_LOADER_DATA, nr_pages, &start);
nr_pages, &start);
if (status == EFI_SUCCESS) { if (status == EFI_SUCCESS) {
*addr = start; *addr = start;
break; break;
...@@ -340,7 +338,7 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, ...@@ -340,7 +338,7 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align,
if (i == map_size / desc_size) if (i == map_size / desc_size)
status = EFI_NOT_FOUND; status = EFI_NOT_FOUND;
efi_call_early(free_pool, map); efi_bs_call(free_pool, map);
fail: fail:
return status; return status;
} }
...@@ -386,8 +384,8 @@ static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16, ...@@ -386,8 +384,8 @@ static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16,
} }
grow: grow:
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, info_sz,
info_sz, (void **)&info); (void **)&info);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to alloc mem for file info\n"); efi_printk("Failed to alloc mem for file info\n");
return status; return status;
...@@ -395,12 +393,12 @@ static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16, ...@@ -395,12 +393,12 @@ static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16,
status = h->get_info(h, &info_guid, &info_sz, info); status = h->get_info(h, &info_guid, &info_sz, info);
if (status == EFI_BUFFER_TOO_SMALL) { if (status == EFI_BUFFER_TOO_SMALL) {
efi_call_early(free_pool, info); efi_bs_call(free_pool, info);
goto grow; goto grow;
} }
*file_sz = info->file_size; *file_sz = info->file_size;
efi_call_early(free_pool, info); efi_bs_call(free_pool, info);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
efi_printk("Failed to get initrd info\n"); efi_printk("Failed to get initrd info\n");
...@@ -428,8 +426,7 @@ static efi_status_t efi_open_volume(efi_loaded_image_t *image, ...@@ -428,8 +426,7 @@ static efi_status_t efi_open_volume(efi_loaded_image_t *image,
efi_status_t status; efi_status_t status;
efi_handle_t handle = image->device_handle; efi_handle_t handle = image->device_handle;
status = efi_call_early(handle_protocol, handle, status = efi_bs_call(handle_protocol, handle, &fs_proto, (void **)&io);
&fs_proto, (void **)&io);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Failed to handle fs_proto\n"); efi_printk("Failed to handle fs_proto\n");
return status; return status;
...@@ -562,8 +559,8 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image, ...@@ -562,8 +559,8 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
if (!nr_files) if (!nr_files)
return EFI_SUCCESS; return EFI_SUCCESS;
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
nr_files * sizeof(*files), (void **)&files); nr_files * sizeof(*files), (void **)&files);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
pr_efi_err("Failed to alloc mem for file handle list\n"); pr_efi_err("Failed to alloc mem for file handle list\n");
goto fail; goto fail;
...@@ -668,7 +665,7 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image, ...@@ -668,7 +665,7 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
} }
efi_call_early(free_pool, files); efi_bs_call(free_pool, files);
*load_addr = file_addr; *load_addr = file_addr;
*load_size = file_size_total; *load_size = file_size_total;
...@@ -682,7 +679,7 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image, ...@@ -682,7 +679,7 @@ efi_status_t handle_cmdline_files(efi_loaded_image_t *image,
for (k = j; k < i; k++) for (k = j; k < i; k++)
efi_file_close(files[k].handle); efi_file_close(files[k].handle);
free_files: free_files:
efi_call_early(free_pool, files); efi_bs_call(free_pool, files);
fail: fail:
*load_addr = 0; *load_addr = 0;
*load_size = 0; *load_size = 0;
...@@ -728,9 +725,8 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr, ...@@ -728,9 +725,8 @@ efi_status_t efi_relocate_kernel(unsigned long *image_addr,
* as possible while respecting the required alignment. * as possible while respecting the required alignment.
*/ */
nr_pages = round_up(alloc_size, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE; nr_pages = round_up(alloc_size, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE;
status = efi_call_early(allocate_pages, status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
EFI_ALLOCATE_ADDRESS, EFI_LOADER_DATA, EFI_LOADER_DATA, nr_pages, &efi_addr);
nr_pages, &efi_addr);
new_addr = efi_addr; new_addr = efi_addr;
/* /*
* If preferred address allocation failed allocate as low as * If preferred address allocation failed allocate as low as
...@@ -883,7 +879,7 @@ efi_status_t efi_exit_boot_services(void *handle, ...@@ -883,7 +879,7 @@ efi_status_t efi_exit_boot_services(void *handle,
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_map; goto free_map;
status = efi_call_early(exit_boot_services, handle, *map->key_ptr); status = efi_bs_call(exit_boot_services, handle, *map->key_ptr);
if (status == EFI_INVALID_PARAMETER) { if (status == EFI_INVALID_PARAMETER) {
/* /*
...@@ -900,12 +896,12 @@ efi_status_t efi_exit_boot_services(void *handle, ...@@ -900,12 +896,12 @@ efi_status_t efi_exit_boot_services(void *handle,
* to get_memory_map() is expected to succeed here. * to get_memory_map() is expected to succeed here.
*/ */
*map->map_size = *map->buff_size; *map->map_size = *map->buff_size;
status = efi_call_early(get_memory_map, status = efi_bs_call(get_memory_map,
map->map_size, map->map_size,
*map->map, *map->map,
map->key_ptr, map->key_ptr,
map->desc_size, map->desc_size,
map->desc_ver); map->desc_ver);
/* exit_boot_services() was called, thus cannot free */ /* exit_boot_services() was called, thus cannot free */
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
...@@ -916,7 +912,7 @@ efi_status_t efi_exit_boot_services(void *handle, ...@@ -916,7 +912,7 @@ efi_status_t efi_exit_boot_services(void *handle,
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto fail; goto fail;
status = efi_call_early(exit_boot_services, handle, *map->key_ptr); status = efi_bs_call(exit_boot_services, handle, *map->key_ptr);
} }
/* exit_boot_services() was called, thus cannot free */ /* exit_boot_services() was called, thus cannot free */
...@@ -926,7 +922,7 @@ efi_status_t efi_exit_boot_services(void *handle, ...@@ -926,7 +922,7 @@ efi_status_t efi_exit_boot_services(void *handle,
return EFI_SUCCESS; return EFI_SUCCESS;
free_map: free_map:
efi_call_early(free_pool, *map->map); efi_bs_call(free_pool, *map->map);
fail: fail:
return status; return status;
} }
......
...@@ -76,4 +76,12 @@ void *get_efi_config_table(efi_guid_t guid); ...@@ -76,4 +76,12 @@ void *get_efi_config_table(efi_guid_t guid);
fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var)) fdt_setprop((fdt), (node_offset), (name), &(var), sizeof(var))
#endif #endif
#define get_efi_var(name, vendor, ...) \
efi_rt_call(get_variable, (efi_char16_t *)(name), \
(efi_guid_t *)(vendor), __VA_ARGS__)
#define set_efi_var(name, vendor, ...) \
efi_rt_call(set_variable, (efi_char16_t *)(name), \
(efi_guid_t *)(vendor), __VA_ARGS__)
#endif #endif
...@@ -110,13 +110,11 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto, ...@@ -110,13 +110,11 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
void *dummy = NULL; void *dummy = NULL;
efi_physical_addr_t current_fb_base; efi_physical_addr_t current_fb_base;
status = efi_call_early(handle_protocol, h, status = efi_bs_call(handle_protocol, h, proto, (void **)&gop);
proto, (void **)&gop);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
continue; continue;
status = efi_call_early(handle_protocol, h, status = efi_bs_call(handle_protocol, h, &conout_proto, &dummy);
&conout_proto, &dummy);
if (status == EFI_SUCCESS) if (status == EFI_SUCCESS)
conout_found = true; conout_found = true;
...@@ -187,20 +185,19 @@ efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, ...@@ -187,20 +185,19 @@ efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto,
efi_status_t status; efi_status_t status;
void **gop_handle = NULL; void **gop_handle = NULL;
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, size,
size, (void **)&gop_handle); (void **)&gop_handle);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
status = efi_call_early(locate_handle, status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, proto, NULL,
EFI_LOCATE_BY_PROTOCOL, &size, gop_handle);
proto, NULL, &size, gop_handle);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto free_handle; goto free_handle;
status = setup_gop(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_bs_call(free_pool, gop_handle);
return status; return status;
} }
...@@ -32,8 +32,7 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out) ...@@ -32,8 +32,7 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out)
efi_status_t status; efi_status_t status;
efi_rng_protocol_t *rng = NULL; efi_rng_protocol_t *rng = NULL;
status = efi_call_early(locate_protocol, &rng_proto, NULL, status = efi_bs_call(locate_protocol, &rng_proto, NULL, (void **)&rng);
(void **)&rng);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
...@@ -141,14 +140,14 @@ efi_status_t efi_random_alloc(unsigned long size, ...@@ -141,14 +140,14 @@ efi_status_t efi_random_alloc(unsigned long size,
target = round_up(md->phys_addr, align) + target_slot * align; target = round_up(md->phys_addr, align) + target_slot * align;
pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE; pages = round_up(size, EFI_PAGE_SIZE) / EFI_PAGE_SIZE;
status = efi_call_early(allocate_pages, EFI_ALLOCATE_ADDRESS, status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
EFI_LOADER_DATA, pages, &target); EFI_LOADER_DATA, pages, &target);
if (status == EFI_SUCCESS) if (status == EFI_SUCCESS)
*addr = target; *addr = target;
break; break;
} }
efi_call_early(free_pool, memory_map); efi_bs_call(free_pool, memory_map);
return status; return status;
} }
...@@ -162,14 +161,13 @@ efi_status_t efi_random_get_seed(void) ...@@ -162,14 +161,13 @@ efi_status_t efi_random_get_seed(void)
struct linux_efi_random_seed *seed = NULL; struct linux_efi_random_seed *seed = NULL;
efi_status_t status; efi_status_t status;
status = efi_call_early(locate_protocol, &rng_proto, NULL, status = efi_bs_call(locate_protocol, &rng_proto, NULL, (void **)&rng);
(void **)&rng);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
status = efi_call_early(allocate_pool, EFI_RUNTIME_SERVICES_DATA, status = efi_bs_call(allocate_pool, EFI_RUNTIME_SERVICES_DATA,
sizeof(*seed) + EFI_RANDOM_SEED_SIZE, sizeof(*seed) + EFI_RANDOM_SEED_SIZE,
(void **)&seed); (void **)&seed);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return status; return status;
...@@ -188,14 +186,13 @@ efi_status_t efi_random_get_seed(void) ...@@ -188,14 +186,13 @@ efi_status_t efi_random_get_seed(void)
goto err_freepool; goto err_freepool;
seed->size = EFI_RANDOM_SEED_SIZE; seed->size = EFI_RANDOM_SEED_SIZE;
status = efi_call_early(install_configuration_table, &rng_table_guid, status = efi_bs_call(install_configuration_table, &rng_table_guid, seed);
seed);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto err_freepool; goto err_freepool;
return EFI_SUCCESS; return EFI_SUCCESS;
err_freepool: err_freepool:
efi_call_early(free_pool, seed); efi_bs_call(free_pool, seed);
return status; return status;
} }
...@@ -21,11 +21,6 @@ static const efi_char16_t efi_SetupMode_name[] = L"SetupMode"; ...@@ -21,11 +21,6 @@ static const efi_char16_t efi_SetupMode_name[] = L"SetupMode";
static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID; static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID;
static const efi_char16_t shim_MokSBState_name[] = L"MokSBState"; static const efi_char16_t shim_MokSBState_name[] = L"MokSBState";
#define get_efi_var(name, vendor, ...) \
efi_call_runtime(get_variable, \
(efi_char16_t *)(name), (efi_guid_t *)(vendor), \
__VA_ARGS__);
/* /*
* Determine whether we're in secure boot mode. * Determine whether we're in secure boot mode.
* *
......
...@@ -20,16 +20,6 @@ static const efi_char16_t efi_MemoryOverWriteRequest_name[] = ...@@ -20,16 +20,6 @@ static const efi_char16_t efi_MemoryOverWriteRequest_name[] =
#define MEMORY_ONLY_RESET_CONTROL_GUID \ #define MEMORY_ONLY_RESET_CONTROL_GUID \
EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29) EFI_GUID(0xe20939be, 0x32d4, 0x41be, 0xa1, 0x50, 0x89, 0x7f, 0x85, 0xd4, 0x98, 0x29)
#define get_efi_var(name, vendor, ...) \
efi_call_runtime(get_variable, \
(efi_char16_t *)(name), (efi_guid_t *)(vendor), \
__VA_ARGS__)
#define set_efi_var(name, vendor, ...) \
efi_call_runtime(set_variable, \
(efi_char16_t *)(name), (efi_guid_t *)(vendor), \
__VA_ARGS__)
/* /*
* Enable reboot attack mitigation. This requests that the firmware clear the * Enable reboot attack mitigation. This requests that the firmware clear the
* RAM on next reboot before proceeding with boot, ensuring that any secrets * RAM on next reboot before proceeding with boot, ensuring that any secrets
...@@ -72,8 +62,8 @@ void efi_retrieve_tpm2_eventlog(void) ...@@ -72,8 +62,8 @@ void efi_retrieve_tpm2_eventlog(void)
efi_tcg2_protocol_t *tcg2_protocol = NULL; efi_tcg2_protocol_t *tcg2_protocol = NULL;
int final_events_size = 0; int final_events_size = 0;
status = efi_call_early(locate_protocol, &tcg2_guid, NULL, status = efi_bs_call(locate_protocol, &tcg2_guid, NULL,
(void **)&tcg2_protocol); (void **)&tcg2_protocol);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return; return;
...@@ -125,9 +115,8 @@ void efi_retrieve_tpm2_eventlog(void) ...@@ -125,9 +115,8 @@ void efi_retrieve_tpm2_eventlog(void)
} }
/* Allocate space for the logs and copy them. */ /* Allocate space for the logs and copy them. */
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_bs_call(allocate_pool, EFI_LOADER_DATA,
sizeof(*log_tbl) + log_size, sizeof(*log_tbl) + log_size, (void **)&log_tbl);
(void **) &log_tbl);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk("Unable to allocate memory for event log\n"); efi_printk("Unable to allocate memory for event log\n");
...@@ -166,12 +155,12 @@ void efi_retrieve_tpm2_eventlog(void) ...@@ -166,12 +155,12 @@ void efi_retrieve_tpm2_eventlog(void)
log_tbl->version = version; log_tbl->version = version;
memcpy(log_tbl->log, (void *) first_entry_addr, log_size); memcpy(log_tbl->log, (void *) first_entry_addr, log_size);
status = efi_call_early(install_configuration_table, status = efi_bs_call(install_configuration_table,
&linux_eventlog_guid, log_tbl); &linux_eventlog_guid, log_tbl);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
goto err_free; goto err_free;
return; return;
err_free: err_free:
efi_call_early(free_pool, log_tbl); efi_bs_call(free_pool, log_tbl);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment