Author: jhb
Date: Fri Apr  8 13:33:57 2011
New Revision: 220452
URL: http://svn.freebsd.org/changeset/base/220452

Log:
  Fix a bug in the previous change to restore the fast path for syscall
  return.  The ast() function may cause a context switch in which case
  PCB_FULL_IRET would be set in the pcb.  However, the code was not
  rechecking the flag after ast() returned and would not properly restore
  the FSBASE and GSBASE MSRs.  To fix, recheck the PCB_FULL_IRET flag after
  ast() returns.
  
  While here, trim an instruction (and memory access) from the doreti path
  and fix a typo in a comment.
  
  MFC after:    1 week

Modified:
  head/sys/amd64/amd64/exception.S

Modified: head/sys/amd64/amd64/exception.S
==============================================================================
--- head/sys/amd64/amd64/exception.S    Fri Apr  8 13:30:48 2011        
(r220451)
+++ head/sys/amd64/amd64/exception.S    Fri Apr  8 13:33:57 2011        
(r220452)
@@ -382,10 +382,10 @@ IDTVEC(fast_syscall)
        FAKE_MCOUNT(TF_RIP(%rsp))
        movq    %rsp,%rdi
        call    syscall
-       movq    PCPU(CURPCB),%rax
+1:     movq    PCPU(CURPCB),%rax
        testl   $PCB_FULL_IRET,PCB_FLAGS(%rax)
-       jne     3f
-1:     /* Check for and handle AST's on return to userland. */
+       jnz     3f
+       /* Check for and handle AST's on return to userland. */
        cli
        movq    PCPU(CURTHREAD),%rax
        testl   $TDF_ASTPENDING | TDF_NEEDRESCHED,TD_FLAGS(%rax)
@@ -661,7 +661,7 @@ doreti:
 doreti_ast:
        /*
         * Check for ASTs atomically with returning.  Disabling CPU
-        * interrupts provides sufficient locking eve in the SMP case,
+        * interrupts provides sufficient locking even in the SMP case,
         * since we will be informed of any new ASTs by an IPI.
         */
        cli
@@ -682,8 +682,7 @@ doreti_ast:
         */
 doreti_exit:
        MEXITCOUNT
-       movq    PCPU(CURTHREAD),%r8
-       movq    TD_PCB(%r8),%r8
+       movq    PCPU(CURPCB),%r8
 
        /*
         * Do not reload segment registers for kernel.
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to