Source-Changes-HG archive

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

[src/trunk]: src/sys/arch More inlines, prerequisites for future changes. Als...



details:   https://anonhg.NetBSD.org/src/rev/0933c175a02c
branches:  trunk
changeset: 962217:0933c175a02c
user:      maxv <maxv%NetBSD.org@localhost>
date:      Fri Jul 05 17:08:55 2019 +0000

description:
More inlines, prerequisites for future changes. Also, remove fngetsw(),
which was a duplicate of fnstsw().

diffstat:

 sys/arch/amd64/amd64/cpufunc.S |  27 +------------------
 sys/arch/i386/i386/cpufunc.S   |  33 +----------------------
 sys/arch/x86/include/cpufunc.h |  58 ++++++++++++++++++++++++++++++++++-------
 sys/arch/x86/x86/fpu.c         |   9 ++++--
 4 files changed, 56 insertions(+), 71 deletions(-)

diffs (235 lines):

diff -r 2644a37200e2 -r 0933c175a02c sys/arch/amd64/amd64/cpufunc.S
--- a/sys/arch/amd64/amd64/cpufunc.S    Fri Jul 05 15:33:07 2019 +0000
+++ b/sys/arch/amd64/amd64/cpufunc.S    Fri Jul 05 17:08:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.42 2019/07/03 17:24:37 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.43 2019/07/05 17:08:55 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -363,21 +363,6 @@
        ret
 END(fnsave)
 
-ENTRY(fnstcw)
-       fnstcw  (%rdi)
-       ret
-END(fnstcw)
-
-ENTRY(fngetsw)
-       fnstsw  %ax
-       ret
-END(fngetsw)
-
-ENTRY(fnstsw)
-       fnstsw  (%rdi)
-       ret
-END(fnstsw)
-
 ENTRY(frstor)
        frstor  (%rdi)
        ret
@@ -430,16 +415,6 @@
        ret
 END(xrstor)
 
-ENTRY(x86_stmxcsr)
-       stmxcsr (%rdi)
-       ret
-END(x86_stmxcsr)
-
-ENTRY(x86_ldmxcsr)
-       ldmxcsr (%rdi)
-       ret
-END(x86_ldmxcsr)
-
 ENTRY(inb)
        movq    %rdi, %rdx
        xorq    %rax, %rax
diff -r 2644a37200e2 -r 0933c175a02c sys/arch/i386/i386/cpufunc.S
--- a/sys/arch/i386/i386/cpufunc.S      Fri Jul 05 15:33:07 2019 +0000
+++ b/sys/arch/i386/i386/cpufunc.S      Fri Jul 05 17:08:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.33 2019/07/03 17:24:37 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.34 2019/07/05 17:08:55 maxv Exp $        */
 
 /*-
  * Copyright (c) 1998, 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include <sys/errno.h>
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.33 2019/07/03 17:24:37 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.34 2019/07/05 17:08:55 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -250,23 +250,6 @@
        ret
 END(fnsave)
 
-ENTRY(fnstcw)
-       movl    4(%esp), %eax
-       fnstcw  (%eax)
-       ret
-END(fnstcw)
-
-ENTRY(fngetsw)
-       fnstsw  %ax
-       ret
-END(fngetsw)
-
-ENTRY(fnstsw)
-       movl    4(%esp), %eax
-       fnstsw  (%eax)
-       ret
-END(fnstsw)
-
 ENTRY(frstor)
        movl    4(%esp), %eax
        frstor  (%eax)
@@ -319,18 +302,6 @@
        ret
 END(xrstor)
 
-ENTRY(x86_stmxcsr)
-       movl    4(%esp), %eax
-       stmxcsr (%eax)
-       ret
-END(x86_stmxcsr)
-
-ENTRY(x86_ldmxcsr)
-       movl    4(%esp), %eax
-       ldmxcsr (%eax)
-       ret
-END(x86_ldmxcsr)
-
 ENTRY(fldummy)
        ffree   %st(7)
        fldz
diff -r 2644a37200e2 -r 0933c175a02c sys/arch/x86/include/cpufunc.h
--- a/sys/arch/x86/include/cpufunc.h    Fri Jul 05 15:33:07 2019 +0000
+++ b/sys/arch/x86/include/cpufunc.h    Fri Jul 05 17:08:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.h,v 1.33 2019/07/03 17:24:37 maxv Exp $        */
+/*     $NetBSD: cpufunc.h,v 1.34 2019/07/05 17:08:55 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2007, 2019 The NetBSD Foundation, Inc.
@@ -280,11 +280,25 @@
        __asm volatile ("fnclex");
 }
 
-void   fnsave(union savefpu *);
-void   fnstcw(uint16_t *);
-uint16_t fngetsw(void);
-void   fnstsw(uint16_t *);
-void   frstor(const union savefpu *);
+static inline void
+fnstcw(uint16_t *val)
+{
+       __asm volatile (
+               "fnstcw %[val]"
+               : [val] "=m" (*val)
+               :
+       );
+}
+
+static inline void
+fnstsw(uint16_t *val)
+{
+       __asm volatile (
+               "fnstsw %[val]"
+               : [val] "=m" (*val)
+               :
+       );
+}
 
 static inline void
 clts(void)
@@ -293,11 +307,27 @@
 }
 
 void   stts(void);
-void   fxsave(union savefpu *);
-void   fxrstor(const union savefpu *);
+
+static inline void
+x86_stmxcsr(uint32_t *val)
+{
+       __asm volatile (
+               "stmxcsr %[val]"
+               : [val] "=m" (*val)
+               :
+       );
+}
 
-void   x86_ldmxcsr(const uint32_t *);
-void   x86_stmxcsr(uint32_t *);
+static inline void
+x86_ldmxcsr(uint32_t *val)
+{
+       __asm volatile (
+               "ldmxcsr %[val]"
+               :
+               : [val] "m" (*val)
+       );
+}
+
 void   fldummy(void);
 
 static inline uint64_t
@@ -328,9 +358,15 @@
        );
 }
 
-void   xrstor(const union savefpu *, uint64_t);
+void   fnsave(union savefpu *);
+void   frstor(const union savefpu *);
+
+void   fxsave(union savefpu *);
+void   fxrstor(const union savefpu *);
+
 void   xsave(union savefpu *, uint64_t);
 void   xsaveopt(union savefpu *, uint64_t);
+void   xrstor(const union savefpu *, uint64_t);
 
 /* -------------------------------------------------------------------------- */
 
diff -r 2644a37200e2 -r 0933c175a02c sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Fri Jul 05 15:33:07 2019 +0000
+++ b/sys/arch/x86/x86/fpu.c    Fri Jul 05 17:08:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.54 2019/06/26 12:30:13 mgorny Exp $  */
+/*     $NetBSD: fpu.c,v 1.55 2019/07/05 17:08:56 maxv 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.54 2019/06/26 12:30:13 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.55 2019/07/05 17:08:56 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -188,6 +188,8 @@
 static inline void
 fpu_errata_amd(void)
 {
+       uint16_t sw;
+
        /*
         * AMD FPUs do not restore FIP, FDP, and FOP on fxrstor and xrstor
         * when FSW.ES=0, leaking other threads' execution history.
@@ -203,7 +205,8 @@
         * which indicates that FIP/FDP/FOP are restored (same behavior
         * as Intel). We're not using it though.
         */
-       if (fngetsw() & 0x80)
+       fnstsw(&sw);
+       if (sw & 0x80)
                fnclex();
        fldummy();
 }



Home | Main Index | Thread Index | Old Index