Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Mar 2014 11:56:33 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r263912 - in head/sys: amd64/amd64 i386/i386
Message-ID:  <201403291156.s2TBuXC3050725@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <torek@torek.net>
  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;
 
 	/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403291156.s2TBuXC3050725>