Attention is currently required from: Julius Werner, Paul Menzel.
Subrata Banik has posted comments on this change by Subrata Banik. ( https://review.coreboot.org/c/coreboot/+/83036?usp=email )
Change subject: libpayload/x86: Extend exception handling to x86_64 architecture ......................................................................
Patch Set 12:
(1 comment)
File payloads/libpayload/arch/x86/exception_asm_64.S:
https://review.coreboot.org/c/coreboot/+/83036/comment/e667bf1d_265adebf?usp... : PS8, Line 207: sub $24, %rax
So this is the part where things get tricky because you're not using the IST approach. We don't have a direct way to restore the little extra stack where the processor added values automatically when it took the exception (what `%rax` was pointing to in the earlier parts of this function) because we don't store it in exception_state. For i386 this was easy because the processor always just pushes three dwords to the existing stack, so we knew `old_rsp - 24` would always get us that value back. For x86_64 it's more tricky because it aligns the stack to 16 bytes first.
So one option to do this right would be forcing that same alignment by doing
movq old_rsp, %rax and $0xfffffffffffffff0, %rax sub $32, %rax
Another would be to just create that stack somewhere else (e.g. on exception_stack), because it doesn't actually matter where it is, just that it is aligned and there's space for us to write 5 quadwords. So I think you could also actually just do
movq exception_stack, %rax
this is very nice suggestion. thanks.
and then that should work too (since we know exception_stack is aligned, and since we're currently busy popping off the last few values from the top of that stack we know that the bottom should be unused and available).
Alternatively, we could create a new datastructure as below to hold the 5 registers after existing from `exception_dispatcher`.
inside exception.h
``` struct exception_old_stack { size_t reg_ip; size_t cs; size_t reg_flags; size_t reg_sp; size_t ss; } __packed;
extern struct exception_old_stack *exception_old_stack; ```
inside exception_asm_64.S
``` .global exception_old_stack exception_old_stack: .quad 0 ```