From 1d15b98730e49b31aa6d6d644f8e394729289043 Mon Sep 17 00:00:00 2001 From: Chaohong guo Date: Mon, 17 Sep 2018 14:22:07 +0800 Subject: [PATCH] Replace the call to emalloc() to uefi pool allocation emalloc() is called only by construct_mbi() during creating e820 mmap layout. The switching has two benefits: first, UEFI FW might keep some memory in pool, unlike call to emalloc(), call to allocate_pool() might have no impact on e820 mmap; on the other hand, we can remove emalloc() routine after this switching. Tracked-On:#1260 Signed-off-by: Chaohong Guo Reviewed-by: Anthony Xu Acked-by: Gen Zheng --- hypervisor/bsp/uefi/efi/boot.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hypervisor/bsp/uefi/efi/boot.c b/hypervisor/bsp/uefi/efi/boot.c index 38c92ca3d..451638bef 100644 --- a/hypervisor/bsp/uefi/efi/boot.c +++ b/hypervisor/bsp/uefi/efi/boot.c @@ -68,11 +68,10 @@ static inline void hv_jump(EFI_PHYSICAL_ADDRESS hv_start, EFI_STATUS construct_mbi(EFI_PHYSICAL_ADDRESS hv_hpa) { - UINTN map_size, _map_size, map_key; + UINTN map_size, map_key; UINT32 desc_version; UINTN desc_size; EFI_MEMORY_DESCRIPTOR *map_buf; - EFI_PHYSICAL_ADDRESS addr; EFI_STATUS err = EFI_SUCCESS; struct multiboot_info *mbi; struct multiboot_mmap *mmap; @@ -92,11 +91,9 @@ EFI_STATUS construct_mbi(EFI_PHYSICAL_ADDRESS hv_hpa) goto out; again: - _map_size = map_size; - err = emalloc(map_size, 1, &addr); + err = allocate_pool(EfiLoaderData, map_size, (void **) &map_buf); if (err != EFI_SUCCESS) goto out; - map_buf = (EFI_MEMORY_DESCRIPTOR *)(UINTN)addr; /* * Remember! We've already allocated map_buf with emalloc (and @@ -115,7 +112,7 @@ again: * larger. 'map_size' has been updated by the * call to memory_map(). */ - efree((UINTN)map_buf, _map_size); + free_pool(map_buf); goto again; } goto out;