Source-Changes-HG archive

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

[src/trunk]: src/sys/arch x86, arm: Allow fpu_kern_enter/leave while cold.



details:   https://anonhg.NetBSD.org/src/rev/910c07242058
branches:  trunk
changeset: 364629:910c07242058
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Apr 01 19:57:22 2022 +0000

description:
x86, arm: Allow fpu_kern_enter/leave while cold.

Normally these are forbidden above IPL_VM, so that FPU usage doesn't
block IPL_SCHED or IPL_HIGH interrupts.  But while cold, e.g. during
builtin module initialization at boot, all interrupts are blocked
anyway so it's a moot point.

Also initialize x86 cpu_info_primary.ci_kfpu_spl to -1 so we don't
trip over an assertion about it while cold -- the assertion is meant
to detect reentrance into fpu_kern_enter/leave, which is prohibited.

Also initialize cpu0's ci_kfpu_spl.

diffstat:

 sys/arch/aarch64/aarch64/fpu.c |  9 +++++----
 sys/arch/arm/vfp/vfp_init.c    |  9 +++++----
 sys/arch/x86/x86/cpu.c         |  5 +++--
 sys/arch/x86/x86/fpu.c         |  9 +++++----
 4 files changed, 18 insertions(+), 14 deletions(-)

diffs (146 lines):

diff -r 1c4b6ede2e1c -r 910c07242058 sys/arch/aarch64/aarch64/fpu.c
--- a/sys/arch/aarch64/aarch64/fpu.c    Fri Apr 01 19:02:12 2022 +0000
+++ b/sys/arch/aarch64/aarch64/fpu.c    Fri Apr 01 19:57:22 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu.c,v 1.11 2020/12/11 18:03:33 skrll Exp $ */
+/* $NetBSD: fpu.c,v 1.12 2022/04/01 19:57:22 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,11 +31,12 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.11 2020/12/11 18:03:33 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: fpu.c,v 1.12 2022/04/01 19:57:22 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/cpu.h>
+#include <sys/kernel.h>
 #include <sys/kthread.h>
 #include <sys/lwp.h>
 #include <sys/evcnt.h>
@@ -213,7 +214,7 @@
         */
        s = splvm();
        ci = curcpu();
-       KASSERTMSG(ci->ci_cpl <= IPL_VM, "cpl=%d", ci->ci_cpl);
+       KASSERTMSG(ci->ci_cpl <= IPL_VM || cold, "cpl=%d", ci->ci_cpl);
        KASSERT(ci->ci_kfpu_spl == -1);
        ci->ci_kfpu_spl = s;
 
@@ -241,7 +242,7 @@
 
        ci = curcpu();
 
-       KASSERT(ci->ci_cpl == IPL_VM);
+       KASSERT(ci->ci_cpl == IPL_VM || cold);
        KASSERT(ci->ci_kfpu_spl != -1);
 
        /*
diff -r 1c4b6ede2e1c -r 910c07242058 sys/arch/arm/vfp/vfp_init.c
--- a/sys/arch/arm/vfp/vfp_init.c       Fri Apr 01 19:02:12 2022 +0000
+++ b/sys/arch/arm/vfp/vfp_init.c       Fri Apr 01 19:57:22 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: vfp_init.c,v 1.76 2021/10/31 16:23:48 skrll Exp $ */
+/*      $NetBSD: vfp_init.c,v 1.77 2022/04/01 19:57:22 riastradh Exp $ */
 
 /*
  * Copyright (c) 2008 ARM Ltd
@@ -32,12 +32,13 @@
 #include "opt_cputypes.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.76 2021/10/31 16:23:48 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfp_init.c,v 1.77 2022/04/01 19:57:22 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
 #include <sys/systm.h>
 #include <sys/device.h>
+#include <sys/kernel.h>
 #include <sys/kthread.h>
 #include <sys/proc.h>
 #include <sys/cpu.h>
@@ -694,7 +695,7 @@
         */
        s = splvm();
        ci = curcpu();
-       KASSERTMSG(ci->ci_cpl <= IPL_VM, "cpl=%d", ci->ci_cpl);
+       KASSERTMSG(ci->ci_cpl <= IPL_VM || cold, "cpl=%d", ci->ci_cpl);
        KASSERT(ci->ci_kfpu_spl == -1);
        ci->ci_kfpu_spl = s;
 
@@ -720,7 +721,7 @@
                return;
        }
 
-       KASSERT(ci->ci_cpl == IPL_VM);
+       KASSERT(ci->ci_cpl == IPL_VM || cold);
        KASSERT(ci->ci_kfpu_spl != -1);
 
        /*
diff -r 1c4b6ede2e1c -r 910c07242058 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Fri Apr 01 19:02:12 2022 +0000
+++ b/sys/arch/x86/x86/cpu.c    Fri Apr 01 19:57:22 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.202 2021/10/07 12:52:27 msaitoh Exp $        */
+/*     $NetBSD: cpu.c,v 1.203 2022/04/01 19:57:22 riastradh Exp $      */
 
 /*
  * Copyright (c) 2000-2020 NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.202 2021/10/07 12:52:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.203 2022/04/01 19:57:22 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -175,6 +175,7 @@
        .ci_idepth = -1,
        .ci_curlwp = &lwp0,
        .ci_curldt = -1,
+       .ci_kfpu_spl = -1,
 };
 
 struct cpu_info *cpu_info_list = &cpu_info_primary;
diff -r 1c4b6ede2e1c -r 910c07242058 sys/arch/x86/x86/fpu.c
--- a/sys/arch/x86/x86/fpu.c    Fri Apr 01 19:02:12 2022 +0000
+++ b/sys/arch/x86/x86/fpu.c    Fri Apr 01 19:57:22 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fpu.c,v 1.76 2020/10/24 07:14:30 mgorny Exp $  */
+/*     $NetBSD: fpu.c,v 1.77 2022/04/01 19:57:22 riastradh Exp $       */
 
 /*
  * Copyright (c) 2008, 2019 The NetBSD Foundation, Inc.  All
@@ -96,7 +96,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.76 2020/10/24 07:14:30 mgorny Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu.c,v 1.77 2022/04/01 19:57:22 riastradh Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -380,7 +380,8 @@
        s = splvm();
 
        ci = curcpu();
-       KASSERTMSG(ci->ci_ilevel <= IPL_VM, "ilevel=%d", ci->ci_ilevel);
+       KASSERTMSG(ci->ci_ilevel <= IPL_VM || cold, "ilevel=%d",
+           ci->ci_ilevel);
        KASSERT(ci->ci_kfpu_spl == -1);
        ci->ci_kfpu_spl = s;
 
@@ -413,7 +414,7 @@
        struct cpu_info *ci = curcpu();
        int s;
 
-       KASSERT(ci->ci_ilevel == IPL_VM);
+       KASSERT(ci->ci_ilevel == IPL_VM || cold);
        KASSERT(ci->ci_kfpu_spl != -1);
 
        /*



Home | Main Index | Thread Index | Old Index