Source-Changes-HG archive

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

[src/trunk]: src/sys/kern xcall(9): If !mp_online, raise spl or set LP_BOUND ...



details:   https://anonhg.NetBSD.org/src/rev/3326fa5dee41
branches:  trunk
changeset: 377328:3326fa5dee41
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Jul 07 17:04:49 2023 +0000

description:
xcall(9): If !mp_online, raise spl or set LP_BOUND to call func.

High-priority xcalls may reasonably assume that the spl is raised to
splsoftserial, so make sure to do that in xc_broadcast.

Low-priority xcalls may reasonably enter paths that assume the lwp is
bound to a CPU, so let's make it assertable even if it doesn't have
any other consequences when !mp_online.

XXX pullup-8
XXX pullup-9
XXX pullup-10

diffstat:

 sys/kern/subr_xcall.c |  31 +++++++++++++++++++++++++------
 1 files changed, 25 insertions(+), 6 deletions(-)

diffs (70 lines):

diff -r fa3493c9f292 -r 3326fa5dee41 sys/kern/subr_xcall.c
--- a/sys/kern/subr_xcall.c     Fri Jul 07 15:56:31 2023 +0000
+++ b/sys/kern/subr_xcall.c     Fri Jul 07 17:04:49 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_xcall.c,v 1.35 2023/04/09 09:18:09 riastradh Exp $        */
+/*     $NetBSD: subr_xcall.c,v 1.36 2023/07/07 17:04:49 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2007-2010, 2019 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.35 2023/04/09 09:18:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_xcall.c,v 1.36 2023/07/07 17:04:49 riastradh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -262,7 +262,17 @@ xc_broadcast(unsigned int flags, xcfunc_
        ASSERT_SLEEPABLE();
 
        if (__predict_false(!mp_online)) {
+               int s, bound;
+
+               if (flags & XC_HIGHPRI)
+                       s = splsoftserial();
+               else
+                       bound = curlwp_bind();
                (*func)(arg1, arg2);
+               if (flags & XC_HIGHPRI)
+                       splx(s);
+               else
+                       curlwp_bindx(bound);
                return 0;
        }
 
@@ -302,9 +312,8 @@ xc_barrier(unsigned int flags)
  */
 uint64_t
 xc_unicast(unsigned int flags, xcfunc_t func, void *arg1, void *arg2,
-          struct cpu_info *ci)
+    struct cpu_info *ci)
 {
-       int s;
 
        KASSERT(ci != NULL);
        KASSERT(!cpu_intr_p());
@@ -312,10 +321,20 @@ xc_unicast(unsigned int flags, xcfunc_t 
        ASSERT_SLEEPABLE();
 
        if (__predict_false(!mp_online)) {
+               int s, bound;
+
                KASSERT(ci == curcpu());
-               s = splsoftserial();
+
+               if (flags & XC_HIGHPRI)
+                       s = splsoftserial();
+               else
+                       bound = curlwp_bind();
                (*func)(arg1, arg2);
-               splx(s);
+               if (flags & XC_HIGHPRI)
+                       splx(s);
+               else
+                       curlwp_bindx(bound);
+
                return 0;
        }
 



Home | Main Index | Thread Index | Old Index