File 55780aaa-efi-avoid-calling-boot-services-after-ExitBootServices.patch of Package xen.950
# Commit d4300db3a03a0cd999745135d7879fc4b6b5aa61
# Date 2015-06-10 12:00:10 +0200
# Author Ross Lagerwall <ross.lagerwall@citrix.com>
# Committer Jan Beulich <jbeulich@suse.com>
efi: avoid calling boot services after ExitBootServices()
After the first call to ExitBootServices(), avoid calling any boot
services (except GetMemoryMap() and ExitBootServices()) by setting
setting efi_bs to NULL and halting in blexit(). Only GetMemoryMap() and
ExitBootServices() are explicitly allowed to be called after the first
call to ExitBootServices() and so are are called via
SystemTable->BootServices.
Suggested-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
--- a/xen/arch/x86/efi/boot.c
+++ b/xen/arch/x86/efi/boot.c
@@ -189,6 +189,13 @@ static void __init __attribute__((__nore
PrintStr((CHAR16 *)str);
PrintStr(newline);
+ if ( !efi_bs )
+ {
+ local_irq_disable();
+ for ( ; ; )
+ halt();
+ }
+
if ( cfg.addr )
efi_bs->FreePages(cfg.addr, PFN_UP(cfg.size));
if ( kernel.addr )
@@ -1394,8 +1401,10 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY
struct e820entry *e;
efi_memmap_size = info_size;
- status = efi_bs->GetMemoryMap(&efi_memmap_size, efi_memmap, &map_key,
- &efi_mdesc_size, &mdesc_ver);
+ status = SystemTable->BootServices->GetMemoryMap(&efi_memmap_size,
+ efi_memmap, &map_key,
+ &efi_mdesc_size,
+ &mdesc_ver);
if ( EFI_ERROR(status) )
PrintErrMesg(L"Cannot obtain memory map", status);
@@ -1458,7 +1467,9 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SY
relocate_trampoline(cfg.addr);
}
- status = efi_bs->ExitBootServices(ImageHandle, map_key);
+ status = SystemTable->BootServices->ExitBootServices(ImageHandle,
+ map_key);
+ efi_bs = NULL;
if ( status != EFI_INVALID_PARAMETER || retry )
break;
}