Re: UEFI Bare Bones
Posted: Mon Apr 13, 2020 9:22 pm
One thing I could never find a satisfactory answer to is where is UEFI allowed to load your bootloader in memory. Clearly a PE file can be relocated and I have tested that this is the case on 3 computers + QEMU. In all cases, by 0-based image gets relocated "somewhere" that is different on each machine.
I do load my kernel from the bootloader and setup virtual memory space so that my kernel is at 0xF0000000. If for any reason UEFI decided to load my bootloader at or above 0xF0000000, this would be a problem: turning on virtual memory would crash the bootloader. That's the 32 bits world. So as previously mentioned you can just ignore UEFI on ia32. But what about other 32-bits platforms?
As for the 64 bits world, I am less worried because I find it even less likely for something like this to happen. But still. I am surprised by the lack of information / clarity about this issue.
Now it so happened that Windows and Linux and any other sane OS probably wants to be at the end of the address space, but I don't know that's always true especially on non-PC platforms.
One could detect this and relocate some trampoline code out of the way, but that's pain I'd rather avoid if it is not necessary.
I do load my kernel from the bootloader and setup virtual memory space so that my kernel is at 0xF0000000. If for any reason UEFI decided to load my bootloader at or above 0xF0000000, this would be a problem: turning on virtual memory would crash the bootloader. That's the 32 bits world. So as previously mentioned you can just ignore UEFI on ia32. But what about other 32-bits platforms?
As for the 64 bits world, I am less worried because I find it even less likely for something like this to happen. But still. I am surprised by the lack of information / clarity about this issue.
Now it so happened that Windows and Linux and any other sane OS probably wants to be at the end of the address space, but I don't know that's always true especially on non-PC platforms.
One could detect this and relocate some trampoline code out of the way, but that's pain I'd rather avoid if it is not necessary.