News for hackers. Stuff that matters.
Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by fao_ on Wednesday April 25, 2018 @02:05PM (#16924288)
TianoCore was a horrible implementation of UEFI. When I used it to code against it had several standard-divergent parts.
Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by wolfgke on Wednesday April 25, 2018 @02:09PM (#16924332)
Can you give details?
Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by fao_ on Wednesday April 25, 2018 @03:10PM (#16924974)
The specific problems I had I don't entirely remember (It was around 3 - 4 years ago at this point). The bug I encountered was relating to escaping the UEFI environment. My code was written to the UEFI 2.6 standards document, and it turns out that TianoCore diverged from that document with relation to how memory allocation was dealt with, and how setting up the post-boot environment was done.

EDIT: I think that it was something along the lines of some implementations (including TianoCore) required the ExitBootServices call to be performed more than once to exit the UEFI-controlled environment correctly? Even after doing that I had some problems with it.

Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by andreiw on Wednesday April 25, 2018 @03:51PM (#16925369)
There's a few problems there, but these amount to UEFI being a terrible, abominable spec.

The specification doesn't say that an implementation must not change the memory map inside ExitBootServices, and in practice many runtime drivers clean up or even perform RT Data allocations in that path. This results in the "MapKey is incorrect" error returned to the caller. (I've seen some that modify ACPI and SMBIOS on the fly inside the ExitBootServices path, awful, awful, awful).

So yes, the program calling ExitBootServices must be written to retry the call even if it really did avoid sandwiching any calls to UEFI between the last GetMemoryMap and ExitBootServices.

The other big Achille's heel of UEFI in general is the SetVirtualAddressMap() RT call and RT Services support in general, but Tiano's driver model makes it particularly easy to shoot yourself in the face and end up with an implementation that forces the OS to call RT services with identity mappings or even with mappings for supposedly non-RT regions. Ugh. MMIO is a favorite one to "forget" to add to the memory map as an RT entry.

UEFI uses the PE format for binaries, but doesn't actually mandate how PE should be used or what the allowed relocations are. You could build a PE binary that amounted to, say, tons of executable segments, each of which will be a separate memory map entry. Now since UEFI doesn't mandate exactly how an OS will assign virtual addresses (for SetVirtualAddressMap), nor exposes relative grouping of memory descriptors (forcing the OS to relocate these keeping relative distances) I can imagine a situation where RT drivers could break if the OS decided to aggressively compact the address map or instead introduce random large VA gaps between RT memory map entries.

Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by mjg59 on Wednesday April 25, 2018 @04:26PM (#16925730)
> I think that it was something along the lines of some implementations (including TianoCore) required the ExitBootServices call to be performed more than once to exit the UEFI-controlled environment correctly?

As hinted at in andreiw's reply, this is entirely spec-compliant (if really annoying). Quoting from the spec:

"Firmware implementation may choose to do a partial shutdown of the boot services during the first call to ExitBootServices(). A UEFI OS loader should not make calls to any boot service function other than GetMemoryMap() after the first call to ExitBootServices()."

Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by fao_ on Wednesday April 25, 2018 @09:43PM (#16928156)
Ah, yes you're right, I remember reading that now. This means that I truly do not remember what the actual error was that caused me to give up.
Re:64-bit Tiano Core UEFI for the Raspberry Pi 3 by andreiw on Wednesday April 25, 2018 @02:21PM (#16924446)
A lot of it really is code quality issues, both in the core and some of the contributed I/O drivers.