rdos wrote:The hand-off between UEFI/BIOS through loader to the OS kernel is already complex enough and shouldn't need to cope with this kind of strangeness from UEFI.
Sounds like your design and abstractions haven't aged well. This happens all the time in software development. I assure you that you can start APs from your kernel without any special handoff between your bootloader and kernel.
There is absolutely no relation whatsoever between starting up APs and the firmware. In fact I use the same code on both BIOS and UEFI and it works just fine.
quirck wrote:I wish UEFI was more clear about details of paging mode it sets up.
The UEFI spec is pretty clear that all available memory will be identity-mapping (effectively it's like there is no mapping, so you don't need to do anything here).
UEFI Spec 2.3.4 wrote:
Paging mode is enabled and any memory space defined by the UEFI memory map is identity
mapped (virtual address equals physical address), although the attributes of certain regions
may not have all read, write, and execute attributes or be unmarked for purposes of platform
protection. The mappings to other regions are undefined and may vary from implementation
to implementation.
quirck wrote:Will it use 5-level paging if available? Will CR4.PCIDE be set?
Why would it matter? You can read CR4.PCIDE if you really want to know. But it shouldn't matter to any bootloader out there if UEFI is using 4 or 5 levels for paging.
quirck wrote:If an OS loader isn't prepared for all that, it's probably going to crash. Who knows what future control bits will be added that need to be accounted for.
I see no reason for the UEFI to fail in this way in the future. New processors and motherboards are released all the time and bootloaders continue to work. You seem to imply that if an UEFI implementation used 5-level paging it would crash existing bootloader. I don't see why that would be the case. Can you elaborate what your thinking is here?
bzt wrote:I've implemented SMP for RPi, coreboot, BIOS, UEFI etc. And yes, UEFI was the most problematic of all because you must comply with an unknown environment (like GDT and paging), plus jump to a relocated address after set up you don't know at compilation time
That's because you are not supposed to start APs while UEFI boot services are active. Until you call ExitBootServices(), the firmware owns your hardware devices (including the APs) and you can't do as you want with them.
I understand you wanted to get the APs up and running in your bootloader and ready to be used by the kernel and I understand that the approach you took was difficult / impossible with UEFI. But you can always start them after ExitBootServices() if that's really what you want to do. Sometimes it's better to work with the constraints of the system you are dealing with rather than to try to swim against the current.