Author: kib
Date: Sat Mar 29 11:56:33 2014
New Revision: 263912
URL: http://svnweb.freebsd.org/changeset/base/263912

Log:
  Clear the kernel grab of the FPU state on fork.  The pcb_save pointer
  is already correctly reset to the FPU user save area, only PCB_KERNFPU
  flag might leak from old thread state into the new state.
  
  For creation of the user-mode thread, the change is nop since
  corresponding syscall code does not use FPU.  On the other hand,
  creation of a kernel thread forks from a thread selected arbitrary
  from proc0, which might use FPU.
  
  Reported and tested by:       Chris Torek <[email protected]>
  Sponsored by: The FreeBSD Foundation
  MFC after:    1 week

Modified:
  head/sys/amd64/amd64/vm_machdep.c
  head/sys/i386/i386/vm_machdep.c

Modified: head/sys/amd64/amd64/vm_machdep.c
==============================================================================
--- head/sys/amd64/amd64/vm_machdep.c   Sat Mar 29 11:33:52 2014        
(r263911)
+++ head/sys/amd64/amd64/vm_machdep.c   Sat Mar 29 11:56:33 2014        
(r263912)
@@ -446,7 +446,8 @@ cpu_set_upcall(struct thread *td, struct
         * values here.
         */
        bcopy(td0->td_pcb, pcb2, sizeof(*pcb2));
-       clear_pcb_flags(pcb2, PCB_FPUINITDONE | PCB_USERFPUINITDONE);
+       clear_pcb_flags(pcb2, PCB_FPUINITDONE | PCB_USERFPUINITDONE |
+           PCB_KERNFPU);
        pcb2->pcb_save = get_pcb_user_save_pcb(pcb2);
        bcopy(get_pcb_user_save_td(td0), pcb2->pcb_save,
            cpu_max_ext_state_size);

Modified: head/sys/i386/i386/vm_machdep.c
==============================================================================
--- head/sys/i386/i386/vm_machdep.c     Sat Mar 29 11:33:52 2014        
(r263911)
+++ head/sys/i386/i386/vm_machdep.c     Sat Mar 29 11:56:33 2014        
(r263912)
@@ -457,7 +457,8 @@ cpu_set_upcall(struct thread *td, struct
         * values here.
         */
        bcopy(td0->td_pcb, pcb2, sizeof(*pcb2));
-       pcb2->pcb_flags &= ~(PCB_NPXINITDONE | PCB_NPXUSERINITDONE);
+       pcb2->pcb_flags &= ~(PCB_NPXINITDONE | PCB_NPXUSERINITDONE |
+           PCB_KERNNPX);
        pcb2->pcb_save = &pcb2->pcb_user_save;
 
        /*
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to