The doreti_iret_fault code is always called with gs base MSR containing

kernel gs base, because %rip is adjusted only on kernel-mode trap caused
by iretq execution. On the other hand, the stack contains (hardware
part of) trap frame from the usermode. As a consequence, checking for
frame mode and doing swapgs causes the kernel to enter trap() with
usermode gs base.

Remove the check for mode and conditional swapgs, we already have right
gs base in the MSR.

Submitted by:	Nate Eldredge <neldredge math ucsd edu>
MFC after:	3 days
This commit is contained in:
Konstantin Belousov 2008-08-18 08:47:27 +00:00
parent 0f4b98311a
commit 8ad85ff260
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=181823

View File

@ -636,13 +636,10 @@ doreti_iret:
.globl doreti_iret_fault
doreti_iret_fault:
subq $TF_RIP,%rsp /* space including tf_err, tf_trapno */
testb $SEL_RPL_MASK,TF_CS(%rsp) /* Did we come from kernel? */
jz 1f /* already running with kernel GS.base */
swapgs
1: testl $PSL_I,TF_RFLAGS(%rsp)
jz 2f
testl $PSL_I,TF_RFLAGS(%rsp)
jz 1f
sti
2: movq %rdi,TF_RDI(%rsp)
1: movq %rdi,TF_RDI(%rsp)
movq %rsi,TF_RSI(%rsp)
movq %rdx,TF_RDX(%rsp)
movq %rcx,TF_RCX(%rsp)