efi: Do not fail on first ExitBootServices() attempt

This commit is contained in:
mintsuki 2022-02-27 05:47:03 +01:00
parent f9048dbd4d
commit c9c437971f

View File

@ -189,18 +189,25 @@ bool efi_exit_boot_services(void) {
if (status)
goto fail;
size_t retries = 0;
retry:
status = gBS->GetMemoryMap(&efi_mmap_size, efi_mmap, &mmap_key, &efi_desc_size, &efi_desc_ver);
if (status)
goto fail;
// Be gone, UEFI!
status = gBS->ExitBootServices(efi_image_handle, mmap_key);
if (status) {
if (retries == 128) {
goto fail;
}
retries++;
goto retry;
}
asm volatile ("cli" ::: "memory");
if (status)
goto fail;
pmm_reclaim_uefi_mem();
// Go through new EFI memmap and free up bootloader entries