diff options
author | Paul Menzel <pmenzel@molgen.mpg.de> | 2019-06-24 18:44:33 +0200 |
---|---|---|
committer | Philipp Deppenwiese <zaolin.daisuki@gmail.com> | 2020-07-05 19:56:09 +0000 |
commit | 6663ad99cf36f53f454defc8f7e87eb2e7495255 (patch) | |
tree | 818e3c711d8c316c96915dff63da535f139cff7d /src/arch/x86/idt.S | |
parent | d9c6862809ca95712e18b967a1fefc24cb607a06 (diff) |
arch/x86: Support x86_64 exceptions
* Doesn't affect existing x86_32 code.
Tested on qemu using division by zero.
Tested on Lenovo T410 with additional x86_64 patches.
Change-Id: Idd12c90a95cc2989eb9b2a718740a84222193f48
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/30117
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
Diffstat (limited to 'src/arch/x86/idt.S')
-rw-r--r-- | src/arch/x86/idt.S | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/src/arch/x86/idt.S b/src/arch/x86/idt.S index a15ccbb132..6807056fe3 100644 --- a/src/arch/x86/idt.S +++ b/src/arch/x86/idt.S @@ -109,40 +109,75 @@ vec19: .global int_hand int_hand: - /* At this point, on x86-32, on the stack there is: - * 0(%esp) vector - * 4(%esp) error code - * 8(%esp) eip - * 12(%esp) cs - * 16(%esp) eflags - */ #ifdef __x86_64__ + /* At this point, on x86-64, on the stack there is: + * 0(%rsp) vector + * 8(%rsp) error code + * 16(%rsp) rip + * 24(%rsp) cs + * 32(%rsp) rflags + * 40(%rsp) rsp + * 48(%rsp) ss + */ + push %r15 + push %r14 + push %r13 + push %r12 + push %r11 + push %r10 + push %r9 + push %r8 + push %rdi push %rsi push %rbp - /* Original stack pointer */ - lea 32(%rsp), %rbp - push %rbp + push %rbx push %rdx push %rcx push %rax - push %rsp /* Pointer to structure on the stack */ + /* Pass pointer to struct as first argument */ + mov %rsp, %rdi + + /* Back up stack pointer */ + mov %rsp, %rbp + + /* Align stack to 16 bytes. */ + and $(~0xf), %rsp + call x86_exception - pop %rax /* Drop the pointer */ + + /* Restore stack pointer from backup */ + mov %rbp, %rsp pop %rax pop %rcx pop %rdx pop %rbx - pop %rbp /* Ignore saved %rsp value */ + pop %rbp pop %rsi pop %rdi - add $8, %rsp /* pop of the vector and error code */ + pop %r8 + pop %r9 + pop %r10 + pop %r11 + pop %r12 + pop %r13 + pop %r14 + pop %r15 + + add $16, %rsp /* pop of the vector and error code */ #else + /* At this point, on x86-32, on the stack there is: + * 0(%esp) vector + * 4(%esp) error code + * 8(%esp) eip + * 12(%esp) cs + * 16(%esp) eflags + */ pushl %edi pushl %esi pushl %ebp |