Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Don't call psignal() without holding proc_lock. Thi...



details:   https://anonhg.NetBSD.org/src/rev/d7e39cce27c2
branches:  trunk
changeset: 765834:d7e39cce27c2
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Jun 07 14:53:03 2011 +0000

description:
Don't call psignal() without holding proc_lock. This is the cause of
the reboot of PR port-xen/45028
Now that Xen2 is gone, handle FPU context switches the same way as
amd64. This makes all tests in /usr/tests/lib/libc/ieeefp pass.

diffstat:

 sys/arch/i386/i386/machdep.c           |   8 ++++----
 sys/arch/i386/isa/npx.c                |  12 ++++++------
 sys/arch/xen/include/i386/hypercalls.h |  16 +---------------
 3 files changed, 11 insertions(+), 25 deletions(-)

diffs (122 lines):

diff -r c34b0ea6f577 -r d7e39cce27c2 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Tue Jun 07 14:22:14 2011 +0000
+++ b/sys/arch/i386/i386/machdep.c      Tue Jun 07 14:53:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.702 2011/04/26 15:51:23 joerg Exp $      */
+/*     $NetBSD: machdep.c,v 1.703 2011/06/07 14:53:03 bouyer Exp $     */
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.702 2011/04/26 15:51:23 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.703 2011/06/07 14:53:03 bouyer Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_ibcs2.h"
@@ -527,7 +527,7 @@
 #ifndef XEN
        lldt(pmap_kernel()->pm_ldt_sel);
 #else
-       HYPERVISOR_fpu_taskswitch();
+       HYPERVISOR_fpu_taskswitch(1);
        XENPRINTF(("lwp tss sp %p ss %04x/%04x\n",
            (void *)pcb->pcb_esp0,
            GSEL(GDATA_SEL, SEL_KPL),
@@ -552,7 +552,7 @@
        pcb = lwp_getpcb(l);
        ci = curcpu();
        if (ci->ci_fpused) {
-               HYPERVISOR_fpu_taskswitch();
+               HYPERVISOR_fpu_taskswitch(1);
                ci->ci_fpused = 0;
        }
 
diff -r c34b0ea6f577 -r d7e39cce27c2 sys/arch/i386/isa/npx.c
--- a/sys/arch/i386/isa/npx.c   Tue Jun 07 14:22:14 2011 +0000
+++ b/sys/arch/i386/isa/npx.c   Tue Jun 07 14:53:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npx.c,v 1.139 2010/12/20 00:25:35 matt Exp $   */
+/*     $NetBSD: npx.c,v 1.140 2011/06/07 14:53:03 bouyer Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.139 2010/12/20 00:25:35 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npx.c,v 1.140 2011/06/07 14:53:03 bouyer Exp $");
 
 #if 0
 #define IPRINTF(x)     printf x
@@ -159,8 +159,8 @@
 static int     npxdna(struct cpu_info *);
 
 #ifdef XEN
-#define        clts()
-#define        stts()
+#define        clts() HYPERVISOR_fpu_taskswitch(0)
+#define        stts() HYPERVISOR_fpu_taskswitch(1)
 #endif
 
 static enum npx_type           npx_type;
@@ -190,9 +190,7 @@
 npxdna_empty(struct cpu_info *ci)
 {
 
-#ifndef XEN
        panic("npxdna vector not initialized");
-#endif
        return 0;
 }
 
@@ -507,7 +505,9 @@
                 * Currently, we treat this like an asynchronous interrupt, but
                 * this has disadvantages.
                 */
+               mutex_enter(proc_lock);
                psignal(l->l_proc, SIGFPE);
+               mutex_exit(proc_lock);
        }
 
        kpreempt_enable();
diff -r c34b0ea6f577 -r d7e39cce27c2 sys/arch/xen/include/i386/hypercalls.h
--- a/sys/arch/xen/include/i386/hypercalls.h    Tue Jun 07 14:22:14 2011 +0000
+++ b/sys/arch/xen/include/i386/hypercalls.h    Tue Jun 07 14:53:03 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hypercalls.h,v 1.11 2011/03/30 22:57:24 jym Exp $      */
+/*     $NetBSD: hypercalls.h,v 1.12 2011/06/07 14:53:03 bouyer Exp $   */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -226,7 +226,6 @@
     return ret;
 }
 
-#if 0
 static __inline int
 HYPERVISOR_fpu_taskswitch(int set)
 {
@@ -238,19 +237,6 @@
 
     return ret;
 }
-#else /* 0 */
-/* Xen2 compat: always i38HYPERVISOR_fpu_taskswitch(1) */
-static __inline int
-HYPERVISOR_fpu_taskswitch(void)
-{
-    long ret;
-    long ign1;
-    _hypercall(__HYPERVISOR_fpu_taskswitch, _harg("1" (1)),
-       _harg("=a" (ret), "=b" (ign1)));
-
-    return ret;
-}
-#endif /* 0 */
 
 static __inline int
 HYPERVISOR_update_descriptor(uint64_t ma, uint32_t word1, uint32_t word2)



Home | Main Index | Thread Index | Old Index