I would like to understand how the UEFI Runtime Services function within the OS. I would also like to understand, how essential are those service for the proper functioning of an OS.
I am aware that the UEFI Runtime Services are invoked in the DXE phase of boot on an UEFI system. Please correct me if I am wrong, I understand that those services are run in a more privileged ring of the CPU than the OS (which is at ring 0). I also have read that the Runtime Services could continue execution after the bootloader launches an OS kernel. Could you please clarify the following issues:
- In what memory space do the Runtime Services run? Is it standardized? Is that memory space a region within main memory (e.g. the DDR RAM)? [1]
- How are Runtime Services scheduled on the CPU? How is control transferred to them? Should they necessarily run in parallel?
- I recall issues with System Manager Mode on PC hardware that were being coded around in Linux kernel. Specifically, the SMM had been causing unpredictable delays due to unpredictable control flow transitions. Is the situation similar with the Runtime Services?
I am aware that the ACPI has been a source of most system-specific information for OS, especially concerning a set of essential memory regions. Please correct me if I am wrong, I understand that it was possible to load an OS from BIOS without any additional information passed to the OS, and with OS only getting the system-specific information through the ACPI. As I understand it, certain basic functionalities, like power-on and power-off, as well as sleep had been implemented through ACPI in Linux and BSD system running on PC hardware. Since the ACPI specifications are a part of UEFI specifications, I see no reason why the OS could not get all the system-specific information it needs to run, and why it would not be able to invoke the ACPI functions. Could you please clarify the following issues:
- Are the UEFI Runtime Services essential for the operations of an OS like Linux or *BSD?
- Could this essential functionality be replaced by the ACPI? What additional functionality do the Runtime Services provide?
Finally, it has been suggested that the ability to use UEFI Runtime Services may depend on the bootloader support. Could you please help me to clarify:
- Does the availability of UEFI Runtime Services depend on the support of the bootloader?
- (If yes to (7), then...) Why would the absence of bootloader support affect the ability to use UEFI Runtime Services? Let's disregard the difficulties with acquiring a pointer to the memory location with the relevant function pointers. Would the services be still running in the background, if the relevant bootloader support is absent?
I've consulted the following sources:
- https://wiki.osdev.org/UEFI
- https://wiki.osdev.org/Using_UEFI_Runtime_Services_in_your_Kernel
- https://wiki.xenproject.org/wiki/Xen_EFI
Footnotes
[1] There's a partial answer to this question provided here. It is still unclear whether the memory space in question is in main memory, and whether in general an OS or a hypervisor could have access to it. (That, is it actually a standardized codified semantics?)