From: Ross Lagerwall Subject: [PATCH] efi: Reallocate memory map if ExitBootServices() fails Date: Fri, 29 May 2015 08:48:59 +0100 Message-ID: <1432885739-18099-1-git-send-email-ross.lagerwall@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ross Lagerwall , Jan Beulich List-Id: xen-devel@lists.xenproject.org If calling ExitBootServices() fails, the memory map size may have increased, so determine the new size and reallocate the memory map before calling GetMemoryMap() again. This was seen on the following machine when using the iscsidxe UEFI driver. The machine would consistently fail the first call to ExitBootServices(). System Information Manufacturer: Supermicro Product Name: X10SLE-F/HF BIOS Information Vendor: American Megatrends Inc. Version: 2.00 Release Date: 04/24/2014 Signed-off-by: Ross Lagerwall --- xen/common/efi/boot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c index ef8476c..078f9b8 100644 --- a/xen/common/efi/boot.c +++ b/xen/common/efi/boot.c @@ -1053,14 +1053,14 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) efi_arch_video_init(gop, info_size, mode_info); } - efi_bs->GetMemoryMap(&efi_memmap_size, NULL, &map_key, - &efi_mdesc_size, &mdesc_ver); - efi_memmap = efi_arch_allocate_mmap_buffer(&efi_memmap_size); - if ( !efi_memmap ) - blexit(L"Unable to allocate memory for EFI memory map"); - for ( retry = 0; ; retry = 1 ) { + efi_bs->GetMemoryMap(&efi_memmap_size, NULL, &map_key, + &efi_mdesc_size, &mdesc_ver); + efi_memmap = efi_arch_allocate_mmap_buffer(&efi_memmap_size); + if ( !efi_memmap ) + blexit(L"Unable to allocate memory for EFI memory map"); + status = efi_bs->GetMemoryMap(&efi_memmap_size, efi_memmap, &map_key, &efi_mdesc_size, &mdesc_ver); if ( EFI_ERROR(status) ) -- 2.1.0