diff options
author | kib <kib@FreeBSD.org> | 2009-07-10 10:29:16 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2009-07-10 10:29:16 +0000 |
commit | bc06993eb4fc58e6b7b99c857dcdc29054d79d0c (patch) | |
tree | 5b8477de1ef13e4111ea0ec3cc2d7374693bc406 /sys | |
parent | e33e5dce327927280ca13509bde4fac5f9d39fe1 (diff) | |
download | FreeBSD-src-bc06993eb4fc58e6b7b99c857dcdc29054d79d0c.zip FreeBSD-src-bc06993eb4fc58e6b7b99c857dcdc29054d79d0c.tar.gz |
When amd64 CPU cannot load segment descriptor during trap return to
usermode, it generates GPF, that is mirrored to user mode as SIGSEGV.
The offending register in mcontext should contain the value loading of
which generated the GPF, and it is so on i386. On amd64, we currently
report segment descriptor in tf_err, while segment register contains the
corrected value loaded by trap handler.
Fix the issue by behaving like i386, reloading segment register in trap
frame after signal frame is pushed onto user stack.
Noted and tested by: pho
Approved by: re (kensmith)
Diffstat (limited to 'sys')
-rw-r--r-- | sys/amd64/amd64/exception.S | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S index d78e234..3d1a20e 100644 --- a/sys/amd64/amd64/exception.S +++ b/sys/amd64/amd64/exception.S @@ -766,38 +766,38 @@ doreti_iret_fault: .globl ds_load_fault ds_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) - movzwl TF_DS(%rsp),%edx - movl %edx,TF_ERR(%rsp) + movq %rsp, %rdi + call trap movw $KUDSEL,TF_DS(%rsp) - jmp calltrap + jmp doreti ALIGN_TEXT .globl es_load_fault es_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) - movzwl TF_ES(%rsp),%edx - movl %edx,TF_ERR(%rsp) + movq %rsp, %rdi + call trap movw $KUDSEL,TF_ES(%rsp) - jmp calltrap + jmp doreti ALIGN_TEXT .globl fs_load_fault fs_load_fault: movl $T_PROTFLT,TF_TRAPNO(%rsp) - movzwl TF_FS(%rsp),%edx - movl %edx,TF_ERR(%rsp) + movq %rsp, %rdi + call trap movw $KUF32SEL,TF_FS(%rsp) - jmp calltrap + jmp doreti ALIGN_TEXT .globl gs_load_fault gs_load_fault: popfq movl $T_PROTFLT,TF_TRAPNO(%rsp) - movzwl TF_GS(%rsp),%edx - movl %edx,TF_ERR(%rsp) + movq %rsp, %rdi + call trap movw $KUG32SEL,TF_GS(%rsp) - jmp calltrap + jmp doreti #ifdef HWPMC_HOOKS ENTRY(end_exceptions) #endif |