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



details:   https://anonhg.NetBSD.org/src/rev/27be365a49ea
branches:  trunk
changeset: 373750:27be365a49ea
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Feb 25 18:28:57 2023 +0000

description:
x86/fpu.c: Sprinkle KNF.

No functional change intended.

diffstat:

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

diffs (183 lines):

diff -r b5cb4674fcae -r 27be365a49ea sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Sat Feb 25 18:04:42 2023 +0000
+++ b/sys/arch/x86/x86/fpu.c    Sat Feb 25 18:28:57 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.82 2023/02/25 18:04:42 riastradh Exp $       */
+/*     $NetBSD: fpu.c,v 1.83 2023/02/25 18:28:57 riastradh Exp $       */
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,35 +96,38 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.82 2023/02/25 18:04:42 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.83 2023/02/25 18:28:57 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
 #include <sys/param.h>
-#include <sys/systm.h>
+#include <sys/types.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/cputypes.h>
 #include <machine/cpuvar.h>
-#include <machine/cputypes.h>
 #include <machine/intr.h>
-#include <machine/cpufunc.h>
 #include <machine/pcb.h>
+#include <machine/specialreg.h>
 #include <machine/trap.h>
-#include <machine/specialreg.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);
@@ -179,7 +182,8 @@
        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);
@@ -192,12 +196,14 @@
 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.
@@ -278,6 +284,7 @@
 void
 fpu_area_save(void *area, uint64_t xsave_features, bool is_64bit)
 {
+
        switch (x86_fpu_save) {
        case FPU_SAVE_FSAVE:
                fnsave(area);
@@ -299,6 +306,7 @@
 void
 fpu_area_restore(const void *area, uint64_t xsave_features, bool is_64bit)
 {
+
        clts();
 
        switch (x86_fpu_save) {
@@ -323,6 +331,7 @@
 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));
 }
@@ -379,7 +388,7 @@
        splx(s);
 }
 
-/* -------------------------------------------------------------------------- */
+/* ------------------------------------------------------------------------- */
 
 static const union savefpu safe_fpu __aligned(64) = {
        .sv_xmm = {
@@ -428,8 +437,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;
@@ -513,7 +522,7 @@
        stts();
 }
 
-/* -------------------------------------------------------------------------- */
+/* ------------------------------------------------------------------------- */
 
 /*
  * The following table is used to ensure that the FPE_... value
@@ -667,6 +676,7 @@
 static inline void
 fpu_xstate_reload(union savefpu *fpu_save, uint64_t xstate)
 {
+
        /*
         * Force a reload of the given xstate during the next XRSTOR.
         */
@@ -865,6 +875,7 @@
 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;
@@ -894,8 +905,10 @@
 
        /* 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;
        }
 
@@ -928,15 +941,16 @@
                /*
                 * 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