Source-Changes-HG archive

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

[src/netbsd-8]: src/sys/arch Pull up the following, requested by maxv in tick...



details:   https://anonhg.NetBSD.org/src/rev/31c253113fbd
branches:  netbsd-8
changeset: 435107:31c253113fbd
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Jul 10 15:35:26 2018 +0000

description:
Pull up the following, requested by maxv in ticket #910:

        sys/arch/amd64/amd64/locore.S   r1.167 (patch)
        sys/arch/i386/i386/locore.S     r1.158 (patch)
        sys/arch/x86/x86/fpu.c          r1.44 (patch)

Don't switch the FPU when leaving a softint. This fixes
several problems when EagerFPU is enabled.

diffstat:

 sys/arch/amd64/amd64/locore.S |  28 +++++++++++++---------------
 sys/arch/i386/i386/locore.S   |  30 +++++++++++++++---------------
 sys/arch/x86/x86/fpu.c        |  18 ++++++++++++++++--
 3 files changed, 44 insertions(+), 32 deletions(-)

diffs (146 lines):

diff -r 66c32be1a7a2 -r 31c253113fbd sys/arch/amd64/amd64/locore.S
--- a/sys/arch/amd64/amd64/locore.S     Tue Jul 10 15:32:28 2018 +0000
+++ b/sys/arch/amd64/amd64/locore.S     Tue Jul 10 15:35:26 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.123.6.7 2018/06/23 11:39:01 martin Exp $  */
+/*     $NetBSD: locore.S,v 1.123.6.8 2018/07/10 15:35:26 martin Exp $  */
 
 /*
  * Copyright-o-rama!
@@ -1094,20 +1094,6 @@
        popq    %rdx
 #endif
 
-#ifndef XEN
-       /* RDI/RSI got clobbered. */
-       movq    %r13,%rdi
-       movq    %r12,%rsi
-
-       pushq   %rdx
-       movb    _C_LABEL(x86_fpu_eager),%dl
-       testb   %dl,%dl
-       jz      .Lno_eagerfpu
-       callq   _C_LABEL(fpu_eagerswitch)
-.Lno_eagerfpu:
-       popq    %rdx
-#endif
-
        /* Switch to newlwp's stack. */
        movq    L_PCB(%r12),%r14
        movq    PCB_RSP(%r14),%rsp
@@ -1148,6 +1134,18 @@
 #endif
 .Lring0_switched:
 
+#ifndef XEN
+       pushq   %rdx
+       movb    _C_LABEL(x86_fpu_eager),%dl
+       testb   %dl,%dl
+       jz      .Lno_eagerfpu
+       movq    %r13,%rdi
+       movq    %r12,%rsi
+       callq   _C_LABEL(fpu_eagerswitch)
+.Lno_eagerfpu:
+       popq    %rdx
+#endif
+
        /* Don't bother with the rest if switching to a system process. */
        testl   $LW_SYSTEM,L_FLAG(%r12)
        jnz     switch_return
diff -r 66c32be1a7a2 -r 31c253113fbd sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Tue Jul 10 15:32:28 2018 +0000
+++ b/sys/arch/i386/i386/locore.S       Tue Jul 10 15:35:26 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.145.6.4 2018/06/23 11:39:02 martin Exp $  */
+/*     $NetBSD: locore.S,v 1.145.6.5 2018/07/10 15:35:26 martin Exp $  */
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.145.6.4 2018/06/23 11:39:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.145.6.5 2018/07/10 15:35:26 martin Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_copy_symtab.h"
@@ -1089,19 +1089,6 @@
        movl    %ebp,PCB_EBP(%eax)
 skip_save:
 
-#ifndef XEN
-       pushl   %edx
-       movb    _C_LABEL(x86_fpu_eager),%dl
-       testb   %dl,%dl
-       jz      .Lno_eagerfpu
-       pushl   %edi
-       pushl   %esi
-       call    _C_LABEL(fpu_eagerswitch)
-       addl    $8,%esp
-.Lno_eagerfpu:
-       popl    %edx
-#endif
-
        /* Switch to newlwp's stack. */
        movl    L_PCB(%edi),%ebx
        movl    PCB_EBP(%ebx),%ebp
@@ -1129,6 +1116,19 @@
        movl    %eax,TSS_ESP0(%ecx)
 #endif
 
+#ifndef XEN
+       pushl   %edx
+       movb    _C_LABEL(x86_fpu_eager),%dl
+       testb   %dl,%dl
+       jz      .Lno_eagerfpu
+       pushl   %edi
+       pushl   %esi
+       call    _C_LABEL(fpu_eagerswitch)
+       addl    $8,%esp
+.Lno_eagerfpu:
+       popl    %edx
+#endif
+
        /* Don't bother with the rest if switching to a system process. */
        testl   $LW_SYSTEM,L_FLAG(%edi)
        jnz     switch_return
diff -r 66c32be1a7a2 -r 31c253113fbd sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Tue Jul 10 15:32:28 2018 +0000
+++ b/sys/arch/x86/x86/fpu.c    Tue Jul 10 15:35:26 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.12.8.2 2018/06/23 11:39:02 martin Exp $      */
+/*     $NetBSD: fpu.c,v 1.12.8.3 2018/07/10 15:35:26 martin Exp $      */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.12.8.2 2018/06/23 11:39:02 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.12.8.3 2018/07/10 15:35:26 martin Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -306,6 +306,20 @@
        int s;
 
        s = splhigh();
+#ifdef DIAGNOSTIC
+       if (oldlwp != NULL) {
+               struct pcb *pcb = lwp_getpcb(oldlwp);
+               struct cpu_info *ci = curcpu();
+               if (pcb->pcb_fpcpu == NULL) {
+                       KASSERT(ci->ci_fpcurlwp != oldlwp);
+               } else if (pcb->pcb_fpcpu == ci) {
+                       KASSERT(ci->ci_fpcurlwp == oldlwp);
+               } else {
+                       panic("%s: oldlwp's state installed elsewhere",
+                           __func__);
+               }
+       }
+#endif
        fpusave_cpu(true);
        if (!(newlwp->l_flag & LW_SYSTEM))
                fpu_eagerrestore(newlwp);



Home | Main Index | Thread Index | Old Index