From 356aaef5a37d60f060082f400617f9dcf514a9d5 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Fri, 17 Jul 2015 21:22:36 +0200 Subject: efi: improve malloc pool allocation Use allocate_pages() instead of allocate_pool(). With allocate_pages() we can specify the address. This way, any address passed to the kernel will never exceed the lower 32 bit. If possible, try to allocate a larger pool. Signed-off-by: Michael Olbrich Signed-off-by: Sascha Hauer --- arch/efi/efi/efi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'arch') diff --git a/arch/efi/efi/efi.c b/arch/efi/efi/efi.c index d351775a28..c05d183c02 100644 --- a/arch/efi/efi/efi.c +++ b/arch/efi/efi/efi.c @@ -310,7 +310,8 @@ device_initcall(efi_init); */ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) { - void *mem; + efi_physical_addr_t mem; + size_t memsize; efi_status_t efiret; #ifdef DEBUG @@ -332,8 +333,21 @@ efi_status_t efi_main(efi_handle_t image, efi_system_table_t *sys_table) fixup_tables(); - BS->allocate_pool(efi_loaded_image->image_data_type, SZ_16M, &mem); - mem_malloc_init(mem, mem + SZ_16M); + mem = 0x3fffffff; + for (memsize = SZ_256M; memsize >= SZ_8M; memsize /= 2) { + efiret = BS->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, + EFI_LOADER_DATA, + memsize/PAGE_SIZE, &mem); + if (!EFI_ERROR(efiret)) + break; + if (efiret != EFI_OUT_OF_RESOURCES) + panic("failed to allocate malloc pool: %s\n", + efi_strerror(efiret)); + } + if (EFI_ERROR(efiret)) + panic("failed to allocate malloc pool: %s\n", + efi_strerror(efiret)); + mem_malloc_init((void *)mem, (void *)mem + memsize); efi_clocksource_init(); -- cgit v1.2.3