Did the UEFI Specification make a mistake?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
wishedtobe
Member
Member
Posts: 34
Joined: Sat May 04, 2024 7:48 am
Libera.chat IRC: wishedtobe

Did the UEFI Specification make a mistake?

Post by wishedtobe »

According to https://uefi.org/specs/UEFI/2.10/02_Overview.html,
The registers RBX, RBP, RDI, RSI, R12, R13, R14, R15, and XMM6-XMM15 are considered nonvolatile and must be saved and restored by a function that uses them.
But obviously it didn't. Their values change after calling the EFI_BOOT_SERVICES. Is it the mistake of the author of the Specification, the programmer of the EDK2, or me?
wishedtobe
Member
Member
Posts: 34
Joined: Sat May 04, 2024 7:48 am
Libera.chat IRC: wishedtobe

Re: Did the UEFI Specification make a mistake?

Post by wishedtobe »

The error was caused by the callee dumping the register parameters into their shadow space, which I had not allocated. I still wonder why I should always reserve 0x20 bytes for the function.
Octocontrabass
Member
Member
Posts: 5655
Joined: Mon Mar 25, 2013 7:01 pm

Re: Did the UEFI Specification make a mistake?

Post by Octocontrabass »

wishedtobe wrote: Sun Jan 26, 2025 5:33 amI still wonder why I should always reserve 0x20 bytes for the function.
Because Microsoft says so. UEFI follows Microsoft's x64 ABI, and Microsoft's x64 ABI requires you to reserve that space on the stack for every function you call.
User avatar
zaval
Member
Member
Posts: 661
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: Did the UEFI Specification make a mistake?

Post by zaval »

It's called conformance to calling convention. Even if it came from GNU/Stallman, you should conform to it. But, and the specification tells this, you should conform to the CC only on the calling UEFI services boundary. For everything internal, you can use whatever "better in your haughty opinion" CC you want. As of practical reasons why to have a shadow space, one example is when one of the parameters, passed in a register, is taken address of inside of the callee.

To the author, Judging by that couple of topics tone, you have that "I know better" beginner attitude. For this case, a friendly advice - when after launching your bad4ss assembly written next gen world dominance Sygma OS and instead of feeling the enlightenment from the 4th dimension, you experience a bunch of poop thrown in your shocked face and next you don't know how it's possible and "if it's the spec/implementation is so bad or me", the answer is "no bunny at all, always no bunny at all" "it's me, it's always me". It'll help.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
Post Reply