Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86/x86 Explicitly clear l2's pcb_fpcpu when forking.



details:   https://anonhg.NetBSD.org/src/rev/fc9f98b6ee06
branches:  trunk
changeset: 833300:fc9f98b6ee06
user:      maxv <maxv%NetBSD.org@localhost>
date:      Tue Jun 19 07:23:44 2018 +0000

description:
Explicitly clear l2's pcb_fpcpu when forking.

A context switch (preemption) could occur between

        fpusave_lwp(l1, true);
and
        memcpy(pcb2, pcb1, sizeof(struct pcb));

In this case, l1's FPU state is re-installed on the current CPU, and
pcb1->pcb_fpcpu becomes non NULL. While it's fine to have l1's state
installed, we don't want to indicate l2's state is installed too.

With lazy fpu this was not a problem, because the context-switch would
not re-install the state, so pcb1->pcb_fpcpu was NULL.

Should fix PR/53383.

diffstat:

 sys/arch/x86/x86/vm_machdep.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (29 lines):

diff -r f82bd2a98cd5 -r fc9f98b6ee06 sys/arch/x86/x86/vm_machdep.c
--- a/sys/arch/x86/x86/vm_machdep.c     Tue Jun 19 05:14:36 2018 +0000
+++ b/sys/arch/x86/x86/vm_machdep.c     Tue Jun 19 07:23:44 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm_machdep.c,v 1.33 2018/03/16 12:19:35 maxv Exp $     */
+/*     $NetBSD: vm_machdep.c,v 1.34 2018/06/19 07:23:44 maxv Exp $     */
 
 /*-
  * Copyright (c) 1982, 1986 The Regents of the University of California.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.33 2018/03/16 12:19:35 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.34 2018/06/19 07:23:44 maxv Exp $");
 
 #include "opt_mtrr.h"
 
@@ -157,6 +157,10 @@
 
        /* Copy the PCB from parent. */
        memcpy(pcb2, pcb1, sizeof(struct pcb));
+
+       /* FPU state not installed. */
+       pcb2->pcb_fpcpu = NULL;
+
        /* Copy any additional fpu state */
        fpu_save_area_fork(pcb2, pcb1);
 



Home | Main Index | Thread Index | Old Index