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 Revert "x86/fpu.c: Sprinkle KNF."



details:   https://anonhg.NetBSD.org/src/rev/972316739163
branches:  trunk
changeset: 373812:972316739163
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Mar 03 14:32:38 2023 +0000

description:
Revert "x86/fpu.c: Sprinkle KNF."

kthread_fpu_enter/exit changes broke some hardware, unclear why, to
investigate before fixing and reapplying these changes.

diffstat:

 sys/arch/x86/x86/fpu.c |  52 ++++++++++++++++++-------------------------------
 1 files changed, 19 insertions(+), 33 deletions(-)

diffs (183 lines):

diff -r c2a45b883655 -r 972316739163 sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Fri Mar 03 14:32:27 2023 +0000
+++ b/sys/arch/x86/x86/fpu.c    Fri Mar 03 14:32:38 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.83 2023/02/25 18:28:57 riastradh Exp $       */
+/*     $NetBSD: fpu.c,v 1.84 2023/03/03 14:32:38 riastradh Exp $       */
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,38 +96,35 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.83 2023/02/25 18:28:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.84 2023/03/03 14:32:38 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
 #include <sys/param.h>
-#include <sys/types.h>
-
+#include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/cpu.h>
 #include <sys/file.h>
+#include <sys/proc.h>
 #include <sys/kernel.h>
 #include <sys/kthread.h>
-#include <sys/proc.h>
 #include <sys/sysctl.h>
-#include <sys/systm.h>
 #include <sys/xcall.h>
 
 #include <machine/cpu.h>
-#include <machine/cpufunc.h>
+#include <machine/cpuvar.h>
 #include <machine/cputypes.h>
-#include <machine/cpuvar.h>
 #include <machine/intr.h>
+#include <machine/cpufunc.h>
 #include <machine/pcb.h>
+#include <machine/trap.h>
 #include <machine/specialreg.h>
-#include <machine/trap.h>
-
 #include <x86/cpu.h>
 #include <x86/fpu.h>
 
 #ifdef XENPV
-#define        clts()  HYPERVISOR_fpu_taskswitch(0)
-#define        stts()  HYPERVISOR_fpu_taskswitch(1)
+#define clts() HYPERVISOR_fpu_taskswitch(0)
+#define stts() HYPERVISOR_fpu_taskswitch(1)
 #endif
 
 void fpu_handle_deferred(void);
@@ -182,8 +179,7 @@
        s = splvm();
        if (l->l_md.md_flags & MDL_FPU_IN_CPU) {
                KASSERT(lwp_can_haz_fpu(l));
-               fpu_area_save(area, x86_xsave_features,
-                   !(l->l_proc->p_flag & PK_32));
+               fpu_area_save(area, x86_xsave_features, !(l->l_proc->p_flag & PK_32));
                l->l_md.md_flags &= ~MDL_FPU_IN_CPU;
        }
        splx(s);
@@ -196,14 +192,12 @@
 void
 fpu_save(void)
 {
-
        fpu_save_lwp(curlwp);
 }
 
 void
 fpuinit(struct cpu_info *ci)
 {
-
        /*
         * This might not be strictly necessary since it will be initialized
         * for each process. However it does no harm.
@@ -284,7 +278,6 @@
 void
 fpu_area_save(void *area, uint64_t xsave_features, bool is_64bit)
 {
-
        switch (x86_fpu_save) {
        case FPU_SAVE_FSAVE:
                fnsave(area);
@@ -306,7 +299,6 @@
 void
 fpu_area_restore(const void *area, uint64_t xsave_features, bool is_64bit)
 {
-
        clts();
 
        switch (x86_fpu_save) {
@@ -331,7 +323,6 @@
 fpu_handle_deferred(void)
 {
        struct pcb *pcb = lwp_getpcb(curlwp);
-
        fpu_area_restore(&pcb->pcb_savefpu, x86_xsave_features,
            !(curlwp->l_proc->p_flag & PK_32));
 }
@@ -388,7 +379,7 @@
        splx(s);
 }
 
-/* ------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
 
 static const union savefpu safe_fpu __aligned(64) = {
        .sv_xmm = {
@@ -437,8 +428,8 @@
        ci->ci_kfpu_spl = s;
 
        /*
-        * If we are in a softint and have a pinned lwp, the fpu state
-        * is that of the pinned lwp, so save it there.
+        * If we are in a softint and have a pinned lwp, the fpu state is that
+        * of the pinned lwp, so save it there.
         */
        while ((l->l_pflag & LP_INTR) && (l->l_switchto != NULL))
                l = l->l_switchto;
@@ -522,7 +513,7 @@
        stts();
 }
 
-/* ------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
 
 /*
  * The following table is used to ensure that the FPE_... value
@@ -676,7 +667,6 @@
 static inline void
 fpu_xstate_reload(union savefpu *fpu_save, uint64_t xstate)
 {
-
        /*
         * Force a reload of the given xstate during the next XRSTOR.
         */
@@ -875,7 +865,6 @@
 int
 process_verify_xstate(const struct xstate *xstate)
 {
-
        /* xstate_bv must be a subset of RFBM */
        if (xstate->xs_xstate_bv & ~xstate->xs_rfbm)
                return EINVAL;
@@ -905,10 +894,8 @@
 
        /* Convert data into legacy FSAVE format. */
        if (x86_fpu_save == FPU_SAVE_FSAVE) {
-               if (xstate->xs_xstate_bv & XCR0_X87) {
-                       process_xmm_to_s87(&xstate->xs_fxsave,
-                           &fpu_save->sv_87);
-               }
+               if (xstate->xs_xstate_bv & XCR0_X87)
+                       process_xmm_to_s87(&xstate->xs_fxsave, &fpu_save->sv_87);
                return 0;
        }
 
@@ -941,16 +928,15 @@
                /*
                 * Invalid bits in mxcsr or mxcsr_mask will cause faults.
                 */
-               fpu_save->sv_xmm.fx_mxcsr_mask =
-                   xstate->xs_fxsave.fx_mxcsr_mask & x86_fpu_mxcsr_mask;
+               fpu_save->sv_xmm.fx_mxcsr_mask = xstate->xs_fxsave.fx_mxcsr_mask
+                   & x86_fpu_mxcsr_mask;
                fpu_save->sv_xmm.fx_mxcsr = xstate->xs_fxsave.fx_mxcsr &
                    fpu_save->sv_xmm.fx_mxcsr_mask;
        }
 
        if (xstate->xs_xstate_bv & XCR0_SSE) {
                memcpy(&fpu_save->sv_xsave_hdr.xsh_fxsave[160],
-                   xstate->xs_fxsave.fx_xmm,
-                   sizeof(xstate->xs_fxsave.fx_xmm));
+                   xstate->xs_fxsave.fx_xmm, sizeof(xstate->xs_fxsave.fx_xmm));
        }
 
 #define COPY_COMPONENT(xcr0_val, xsave_val, field)                     \



Home | Main Index | Thread Index | Old Index