diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index f81dd66626ce..ec92c4decc86 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -901,3 +901,19 @@ struct boot_params *efi_main(efi_handle_t handle, for (;;) asm("hlt"); } + +#ifdef CONFIG_EFI_MIXED +void efi_free_native(unsigned long size, unsigned long addr); + +void efi_free(unsigned long size, unsigned long addr) +{ + if (!size) + return; + + if (efi_is_native()) + efi_free_native(size, addr); + else + efi64_thunk(efi_system_table()->boottime->mixed_mode.free_pages, + addr, 0, DIV_ROUND_UP(size, EFI_PAGE_SIZE)); +} +#endif diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index d4215571f05a..b715ac6a0c94 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -346,6 +346,9 @@ efi_status_t efi_low_alloc_above(unsigned long size, unsigned long align, } void efi_free(unsigned long size, unsigned long addr) + __weak __alias(efi_free_native); + +void efi_free_native(unsigned long size, unsigned long addr) { unsigned long nr_pages; @@ -353,7 +356,7 @@ void efi_free(unsigned long size, unsigned long addr) return; nr_pages = round_up(size, EFI_ALLOC_ALIGN) / EFI_PAGE_SIZE; - efi_call_early(free_pages, addr, nr_pages); + efi_system_table()->boottime->free_pages(addr, nr_pages); } static efi_status_t efi_file_size(void *__fh, efi_char16_t *filename_16,