Page 1 of 1

Not calling ExitBootServices?

Posted: Tue Jan 02, 2024 9:32 am
by sleirsgoevy
Question: on BIOS systems there is no ExitBootServices involved, instead the OS just moves the CPU to protected mode and forgets that BIOS existed. What bad things can happen if I do the same to UEFI?

That is: not call ExitBootServices, instead just load my own GDT/IDT/page tables, reconfigure PIC/APIC/whatever and boot the OS. And maybe even keep calling the boot services in some emulated environment (this is just a random spin-off thought, please don't interpret it the way that I'm lazy to write drivers).

Watchdog might be one concern, are there others?

Re: Not calling ExitBootServices?

Posted: Tue Jan 02, 2024 10:27 am
by sounds
I think the question can be taken seriously. Is a UEFI BIOS likely to interfere if ExitBootServices is not called?

No one can give you a guarantee. You'd have to test it on real systems. But here are some things to watch out for:
  1. System Management Mode interrupts and ACPI System Control Interrupts (link) would transfer control to the UEFI BIOS and could lead to unexpected behavior.
  2. For servers, the BMC (link) would likely also behave in unexpected ways
It bears repeating: calling ExitBootServices does not mean the OS forgets all about the UEFI BIOS. The Boot Services are no longer available after that point, but the OS still accesses the UEFI BIOS when needed. Also, the things I mentioned above demonstrate how effectively the UEFI BIOS can assert itself when it wants something.

Re: Not calling ExitBootServices?

Posted: Tue Jan 02, 2024 2:08 pm
by rdos
SMIs are active even after ExitBootServices, and UEFI can reboot or take over your machine if it feels you haven't done what it wants you to do, like initialize ACPI as if you were a late Windows version. Happened to me on a laptop.

Re: Not calling ExitBootServices?

Posted: Wed Jan 03, 2024 8:02 pm
by sleirsgoevy
> ACPI

Good point. Leaving the PC without working power management is probably not a good idea.