Source-Changes-HG archive

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

[src/trunk]: src/sys/arch Misc changes in the x86 FPU code. Reduces a future ...



details:   https://anonhg.NetBSD.org/src/rev/06f1ebf9433b
branches:  trunk
changeset: 999113:06f1ebf9433b
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun May 19 08:17:02 2019 +0000

description:
Misc changes in the x86 FPU code. Reduces a future diff. No real functional
change.

diffstat:

 sys/arch/amd64/amd64/cpufunc.S |   7 +------
 sys/arch/amd64/amd64/machdep.c |  12 ++++++------
 sys/arch/i386/i386/cpufunc.S   |   9 ++-------
 sys/arch/i386/i386/locore.S    |   8 ++++----
 sys/arch/i386/i386/machdep.c   |  15 +++++++--------
 sys/arch/x86/include/fpu.h     |  15 +++++----------
 sys/arch/x86/x86/fpu.c         |  12 ++++++------
 sys/arch/x86/x86/x86_machdep.c |   6 ++----
 8 files changed, 33 insertions(+), 51 deletions(-)

diffs (286 lines):

diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/amd64/amd64/cpufunc.S
--- a/sys/arch/amd64/amd64/cpufunc.S    Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/amd64/amd64/cpufunc.S    Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.39 2019/05/04 07:20:22 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.40 2019/05/19 08:17:02 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2007, 2008 The NetBSD Foundation, Inc.
@@ -374,11 +374,6 @@
        ret
 END(frstor)
 
-ENTRY(clts)
-       clts
-       ret
-END(clts)
-
 ENTRY(stts)
        movq    %cr0, %rax
        orq     $CR0_TS, %rax
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c    Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/amd64/amd64/machdep.c    Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.329 2019/03/24 15:58:32 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.330 2019/05/19 08:17:02 maxv Exp $       */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -110,7 +110,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.329 2019/03/24 15:58:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.330 2019/05/19 08:17:02 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_user_ldt.h"
@@ -457,15 +457,15 @@
 
        /* Update segment registers */
        if (pcb->pcb_flags & PCB_COMPAT32) {
-               update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &pcb->pcb_fs);
-               update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &pcb->pcb_gs);
+               update_descriptor(&ci->ci_gdt[GUFS_SEL], &pcb->pcb_fs);
+               update_descriptor(&ci->ci_gdt[GUGS_SEL], &pcb->pcb_gs);
                setds(GSEL(GUDATA32_SEL, SEL_UPL));
                setes(GSEL(GUDATA32_SEL, SEL_UPL));
                setfs(GSEL(GUDATA32_SEL, SEL_UPL));
                HYPERVISOR_set_segment_base(SEGBASE_GS_USER_SEL, tf->tf_gs);
        } else {
-               update_descriptor(&curcpu()->ci_gdt[GUFS_SEL], &zero);
-               update_descriptor(&curcpu()->ci_gdt[GUGS_SEL], &zero);
+               update_descriptor(&ci->ci_gdt[GUFS_SEL], &zero);
+               update_descriptor(&ci->ci_gdt[GUGS_SEL], &zero);
                setds(GSEL(GUDATA_SEL, SEL_UPL));
                setes(GSEL(GUDATA_SEL, SEL_UPL));
                setfs(0);
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/i386/i386/cpufunc.S
--- a/sys/arch/i386/i386/cpufunc.S      Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/i386/i386/cpufunc.S      Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpufunc.S,v 1.31 2019/05/04 07:20:22 maxv Exp $        */
+/*     $NetBSD: cpufunc.S,v 1.32 2019/05/19 08:17:02 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.31 2019/05/04 07:20:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.S,v 1.32 2019/05/19 08:17:02 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -289,11 +289,6 @@
        ret
 END(frstor)
 
-ENTRY(clts)
-       clts
-       ret
-END(clts)
-
 ENTRY(stts)
        movl    %cr0, %eax
        testl   $CR0_TS, %eax
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/i386/i386/locore.S
--- a/sys/arch/i386/i386/locore.S       Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/i386/i386/locore.S       Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.S,v 1.167 2019/05/15 18:27:51 maxv Exp $        */
+/*     $NetBSD: locore.S,v 1.168 2019/05/19 08:17:02 maxv Exp $        */
 
 /*
  * Copyright-o-rama!
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.167 2019/05/15 18:27:51 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.168 2019/05/19 08:17:02 maxv Exp $");
 
 #include "opt_copy_symtab.h"
 #include "opt_ddb.h"
@@ -1199,7 +1199,7 @@
        pushl   %edi
        call    _C_LABEL(i386_tls_switch)
        addl    $4,%esp
-#else /* !XENPV */
+#else
        movl    $IPL_HIGH,CPUVAR(ILEVEL)
        movl    PCB_CR0(%ebx),%ecx              /* has CR0_TS clear */
        movl    %cr0,%edx
@@ -1217,7 +1217,7 @@
        cmpl    %edx,%ecx
        je      switch_return
        movl    %ecx,%cr0
-#endif /* !XENPV */
+#endif
 
 switch_return:
        /* Return to the new LWP, returning 'oldlwp' in %eax. */
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c      Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/i386/i386/machdep.c      Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.818 2019/03/09 08:42:25 maxv Exp $       */
+/*     $NetBSD: machdep.c,v 1.819 2019/05/19 08:17:02 maxv Exp $       */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009, 2017
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.818 2019/03/09 08:42:25 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.819 2019/05/19 08:17:02 maxv Exp $");
 
 #include "opt_beep.h"
 #include "opt_compat_freebsd.h"
@@ -507,28 +507,27 @@
 {
        struct cpu_info *ci = curcpu();
        struct pcb *pcb = lwp_getpcb(l);
+
        /*
-         * Raise the IPL to IPL_HIGH.
+        * Raise the IPL to IPL_HIGH.
         * FPU IPIs can alter the LWP's saved cr0.  Dropping the priority
         * is deferred until mi_switch(), when cpu_switchto() returns.
         */
        (void)splhigh();
 
-        /*
+       /*
         * If our floating point registers are on a different CPU,
         * set CR0_TS so we'll trap rather than reuse bogus state.
         */
-
        if (l != ci->ci_fpcurlwp) {
                HYPERVISOR_fpu_taskswitch(1);
        }
 
        /* Update TLS segment pointers */
        update_descriptor(&ci->ci_gdt[GUFS_SEL],
-                         (union descriptor *) &pcb->pcb_fsd);
+           (union descriptor *)&pcb->pcb_fsd);
        update_descriptor(&ci->ci_gdt[GUGS_SEL],
-                         (union descriptor *) &pcb->pcb_gsd);
-
+           (union descriptor *)&pcb->pcb_gsd);
 }
 #endif /* XENPV */
 
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/x86/include/fpu.h
--- a/sys/arch/x86/include/fpu.h        Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/x86/include/fpu.h        Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.h,v 1.14 2019/01/20 16:55:21 maxv Exp $    */
+/*     $NetBSD: fpu.h,v 1.15 2019/05/19 08:17:02 maxv Exp $    */
 
 #ifndef        _X86_FPU_H_
 #define        _X86_FPU_H_
@@ -27,21 +27,16 @@
 void fputrap(struct trapframe *);
 void fpudna(struct trapframe *);
 
-/* Set all to defaults (eg during exec) */
 void fpu_save_area_clear(struct lwp *, unsigned int);
-/* Reset control words only - for signal handlers */
 void fpu_save_area_reset(struct lwp *);
 
-/* Copy data outside pcb during fork */
 void fpu_save_area_fork(struct pcb *, const struct pcb *);
 
-/* Load FP registers with user-supplied values */
-void process_write_fpregs_xmm(struct lwp *lwp, const struct fxsave *fpregs);
-void process_write_fpregs_s87(struct lwp *lwp, const struct save87 *fpregs);
+void process_write_fpregs_xmm(struct lwp *, const struct fxsave *);
+void process_write_fpregs_s87(struct lwp *, const struct save87 *);
 
-/* Save FP registers for copy to userspace */
-void process_read_fpregs_xmm(struct lwp *lwp, struct fxsave *fpregs);
-void process_read_fpregs_s87(struct lwp *lwp, struct save87 *fpregs);
+void process_read_fpregs_xmm(struct lwp *, struct fxsave *);
+void process_read_fpregs_s87(struct lwp *, struct save87 *);
 
 #endif
 
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/x86/x86/fpu.c    Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.50 2019/02/11 14:59:33 cherry Exp $  */
+/*     $NetBSD: fpu.c,v 1.51 2019/05/19 08:17:02 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.50 2019/02/11 14:59:33 cherry Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.51 2019/05/19 08:17:02 maxv Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -185,8 +185,8 @@
 #endif
 }
 
-static void
-fpu_clear_amd(void)
+static inline void
+fpu_errata_amd(void)
 {
        /*
         * AMD FPUs do not restore FIP, FDP, and FOP on fxrstor and xrstor
@@ -240,13 +240,13 @@
                break;
        case FPU_SAVE_FXSAVE:
                if (cpu_vendor == CPUVENDOR_AMD)
-                       fpu_clear_amd();
+                       fpu_errata_amd();
                fxrstor(area);
                break;
        case FPU_SAVE_XSAVE:
        case FPU_SAVE_XSAVEOPT:
                if (cpu_vendor == CPUVENDOR_AMD)
-                       fpu_clear_amd();
+                       fpu_errata_amd();
                xrstor(area, xsave_features);
                break;
        }
diff -r a6f80a461815 -r 06f1ebf9433b sys/arch/x86/x86/x86_machdep.c
--- a/sys/arch/x86/x86/x86_machdep.c    Sun May 19 07:43:17 2019 +0000
+++ b/sys/arch/x86/x86/x86_machdep.c    Sun May 19 08:17:02 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: x86_machdep.c,v 1.125 2019/05/15 17:31:41 maxv Exp $   */
+/*     $NetBSD: x86_machdep.c,v 1.126 2019/05/19 08:17:02 maxv Exp $   */
 
 /*-
  * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.125 2019/05/15 17:31:41 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.126 2019/05/19 08:17:02 maxv Exp $");
 
 #include "opt_modular.h"
 #include "opt_physmem.h"
@@ -1306,10 +1306,8 @@
        sysctl_speculation_init(clog);
 #endif
 
-#ifndef XEN
        void sysctl_eagerfpu_init(struct sysctllog **);
        sysctl_eagerfpu_init(clog);
-#endif
 
        /* None of these can ever change once the system has booted */
        const_sysctl(clog, "fpu_present", CTLTYPE_INT, i386_fpu_present,



Home | Main Index | Thread Index | Old Index