Home | History | Annotate | Line # | Download | only in rumpkern
intr.c revision 1.56.24.1
      1  1.56.24.1  perseant /*	$NetBSD: intr.c,v 1.56.24.1 2025/08/02 05:57:53 perseant Exp $	*/
      2        1.2        ad 
      3        1.5     pooka /*
      4       1.48     pooka  * Copyright (c) 2008-2010, 2015 Antti Kantee.  All Rights Reserved.
      5        1.2        ad  *
      6        1.2        ad  * Redistribution and use in source and binary forms, with or without
      7        1.2        ad  * modification, are permitted provided that the following conditions
      8        1.2        ad  * are met:
      9        1.2        ad  * 1. Redistributions of source code must retain the above copyright
     10        1.2        ad  *    notice, this list of conditions and the following disclaimer.
     11        1.2        ad  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.2        ad  *    notice, this list of conditions and the following disclaimer in the
     13        1.2        ad  *    documentation and/or other materials provided with the distribution.
     14        1.2        ad  *
     15        1.5     pooka  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     16        1.5     pooka  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17        1.5     pooka  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18        1.5     pooka  * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     19        1.5     pooka  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20        1.5     pooka  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21        1.5     pooka  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22        1.5     pooka  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23        1.5     pooka  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24        1.5     pooka  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25        1.5     pooka  * SUCH DAMAGE.
     26        1.2        ad  */
     27        1.2        ad 
     28       1.11     pooka #include <sys/cdefs.h>
     29  1.56.24.1  perseant __KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.56.24.1 2025/08/02 05:57:53 perseant Exp $");
     30       1.11     pooka 
     31        1.2        ad #include <sys/param.h>
     32       1.29    martin #include <sys/atomic.h>
     33        1.5     pooka #include <sys/cpu.h>
     34       1.24     pooka #include <sys/kernel.h>
     35       1.12     pooka #include <sys/kmem.h>
     36        1.5     pooka #include <sys/kthread.h>
     37       1.28     pooka #include <sys/malloc.h>
     38        1.2        ad #include <sys/intr.h>
     39       1.24     pooka #include <sys/timetc.h>
     40        1.2        ad 
     41       1.54     pooka #include <rump-sys/kern.h>
     42       1.54     pooka 
     43        1.5     pooka #include <rump/rumpuser.h>
     44        1.5     pooka 
     45        1.5     pooka /*
     46        1.5     pooka  * Interrupt simulator.  It executes hardclock() and softintrs.
     47        1.5     pooka  */
     48        1.5     pooka 
     49       1.18     pooka #define SI_MPSAFE 0x01
     50       1.32     pooka #define SI_KILLME 0x02
     51       1.20     pooka 
     52       1.32     pooka struct softint_percpu;
     53        1.5     pooka struct softint {
     54        1.5     pooka 	void (*si_func)(void *);
     55        1.5     pooka 	void *si_arg;
     56       1.18     pooka 	int si_flags;
     57       1.20     pooka 	int si_level;
     58        1.5     pooka 
     59       1.32     pooka 	struct softint_percpu *si_entry; /* [0,ncpu-1] */
     60       1.32     pooka };
     61       1.32     pooka 
     62       1.32     pooka struct softint_percpu {
     63       1.32     pooka 	struct softint *sip_parent;
     64       1.32     pooka 	bool sip_onlist;
     65       1.47     pooka 	bool sip_onlist_cpu;
     66       1.32     pooka 
     67       1.48     pooka 	TAILQ_ENTRY(softint_percpu) sip_entries;	/* scheduled */
     68       1.47     pooka 	TAILQ_ENTRY(softint_percpu) sip_entries_cpu;	/* to be scheduled */
     69        1.2        ad };
     70       1.10     pooka 
     71       1.22     pooka struct softint_lev {
     72       1.20     pooka 	struct rumpuser_cv *si_cv;
     73       1.48     pooka 	TAILQ_HEAD(, softint_percpu) si_pending;
     74       1.22     pooka };
     75       1.10     pooka 
     76       1.47     pooka static TAILQ_HEAD(, softint_percpu) sicpupending \
     77       1.47     pooka     = TAILQ_HEAD_INITIALIZER(sicpupending);
     78       1.47     pooka static struct rumpuser_mtx *sicpumtx;
     79       1.47     pooka static struct rumpuser_cv *sicpucv;
     80       1.47     pooka 
     81       1.23     pooka kcondvar_t lbolt; /* Oh Kath Ra */
     82       1.23     pooka 
     83       1.34     pooka static int ncpu_final;
     84       1.24     pooka 
     85       1.51     pooka void noclock(void); void noclock(void) {return;}
     86       1.51     pooka __strong_alias(sched_schedclock,noclock);
     87       1.51     pooka __strong_alias(cpu_initclocks,noclock);
     88       1.51     pooka __strong_alias(addupc_intr,noclock);
     89       1.51     pooka __strong_alias(sched_tick,noclock);
     90       1.51     pooka __strong_alias(setstatclockrate,noclock);
     91       1.14     pooka 
     92       1.10     pooka /*
     93       1.10     pooka  * clock "interrupt"
     94       1.10     pooka  */
     95       1.10     pooka static void
     96       1.10     pooka doclock(void *noarg)
     97       1.10     pooka {
     98       1.38     pooka 	struct timespec thetick, curclock;
     99       1.52     pooka 	struct clockframe *clkframe;
    100       1.40     pooka 	int64_t sec;
    101       1.40     pooka 	long nsec;
    102       1.24     pooka 	int error;
    103       1.51     pooka 	struct cpu_info *ci = curcpu();
    104       1.14     pooka 
    105       1.39     pooka 	error = rumpuser_clock_gettime(RUMPUSER_CLOCK_ABSMONO, &sec, &nsec);
    106       1.38     pooka 	if (error)
    107       1.38     pooka 		panic("clock: cannot get monotonic time");
    108       1.38     pooka 
    109       1.38     pooka 	curclock.tv_sec = sec;
    110       1.38     pooka 	curclock.tv_nsec = nsec;
    111       1.24     pooka 	thetick.tv_sec = 0;
    112       1.24     pooka 	thetick.tv_nsec = 1000000000/hz;
    113       1.14     pooka 
    114       1.52     pooka 	/* generate dummy clockframe for hardclock to consume */
    115       1.52     pooka 	clkframe = rump_cpu_makeclockframe();
    116       1.51     pooka 
    117       1.10     pooka 	for (;;) {
    118       1.51     pooka 		int lbolt_ticks = 0;
    119       1.51     pooka 
    120       1.52     pooka 		hardclock(clkframe);
    121       1.51     pooka 		if (CPU_IS_PRIMARY(ci)) {
    122       1.51     pooka 			if (++lbolt_ticks >= hz) {
    123       1.51     pooka 				lbolt_ticks = 0;
    124       1.51     pooka 				cv_broadcast(&lbolt);
    125       1.51     pooka 			}
    126       1.51     pooka 		}
    127        1.5     pooka 
    128       1.39     pooka 		error = rumpuser_clock_sleep(RUMPUSER_CLOCK_ABSMONO,
    129       1.39     pooka 		    curclock.tv_sec, curclock.tv_nsec);
    130       1.53     pooka 		if (error) {
    131       1.53     pooka 			panic("rumpuser_clock_sleep failed with error %d",
    132       1.53     pooka 			    error);
    133       1.53     pooka 		}
    134       1.38     pooka 		timespecadd(&curclock, &thetick, &curclock);
    135       1.10     pooka 	}
    136       1.10     pooka }
    137        1.8     pooka 
    138       1.10     pooka /*
    139       1.28     pooka  * Soft interrupt execution thread.  This thread is pinned to the
    140       1.28     pooka  * same CPU that scheduled the interrupt, so we don't need to do
    141       1.28     pooka  * lock against si_lvl.
    142       1.10     pooka  */
    143       1.10     pooka static void
    144       1.10     pooka sithread(void *arg)
    145       1.10     pooka {
    146       1.32     pooka 	struct softint_percpu *sip;
    147       1.10     pooka 	struct softint *si;
    148       1.10     pooka 	void (*func)(void *) = NULL;
    149       1.10     pooka 	void *funarg;
    150       1.10     pooka 	bool mpsafe;
    151       1.20     pooka 	int mylevel = (uintptr_t)arg;
    152       1.22     pooka 	struct softint_lev *si_lvlp, *si_lvl;
    153       1.22     pooka 	struct cpu_data *cd = &curcpu()->ci_data;
    154       1.20     pooka 
    155       1.22     pooka 	si_lvlp = cd->cpu_softcpu;
    156       1.22     pooka 	si_lvl = &si_lvlp[mylevel];
    157       1.22     pooka 
    158       1.10     pooka 	for (;;) {
    159       1.48     pooka 		if (!TAILQ_EMPTY(&si_lvl->si_pending)) {
    160       1.48     pooka 			sip = TAILQ_FIRST(&si_lvl->si_pending);
    161       1.32     pooka 			si = sip->sip_parent;
    162       1.32     pooka 
    163        1.5     pooka 			func = si->si_func;
    164        1.5     pooka 			funarg = si->si_arg;
    165       1.18     pooka 			mpsafe = si->si_flags & SI_MPSAFE;
    166        1.5     pooka 
    167       1.32     pooka 			sip->sip_onlist = false;
    168       1.48     pooka 			TAILQ_REMOVE(&si_lvl->si_pending, sip, sip_entries);
    169       1.20     pooka 			if (si->si_flags & SI_KILLME) {
    170       1.18     pooka 				softint_disestablish(si);
    171       1.20     pooka 				continue;
    172       1.20     pooka 			}
    173       1.10     pooka 		} else {
    174       1.28     pooka 			rump_schedlock_cv_wait(si_lvl->si_cv);
    175       1.10     pooka 			continue;
    176        1.5     pooka 		}
    177        1.5     pooka 
    178       1.10     pooka 		if (!mpsafe)
    179       1.10     pooka 			KERNEL_LOCK(1, curlwp);
    180       1.10     pooka 		func(funarg);
    181       1.10     pooka 		if (!mpsafe)
    182       1.10     pooka 			KERNEL_UNLOCK_ONE(curlwp);
    183        1.5     pooka 	}
    184       1.20     pooka 
    185       1.20     pooka 	panic("sithread unreachable");
    186        1.5     pooka }
    187        1.2        ad 
    188       1.47     pooka /*
    189       1.47     pooka  * Helper for softint_schedule_cpu()
    190       1.47     pooka  */
    191       1.47     pooka static void
    192       1.47     pooka sithread_cpu_bouncer(void *arg)
    193       1.47     pooka {
    194       1.47     pooka 	struct lwp *me;
    195       1.47     pooka 
    196       1.47     pooka 	me = curlwp;
    197       1.47     pooka 	me->l_pflag |= LP_BOUND;
    198       1.47     pooka 
    199       1.47     pooka 	rump_unschedule();
    200       1.47     pooka 	for (;;) {
    201       1.47     pooka 		struct softint_percpu *sip;
    202       1.47     pooka 		struct softint *si;
    203       1.47     pooka 		struct cpu_info *ci;
    204       1.47     pooka 		unsigned int cidx;
    205       1.47     pooka 
    206       1.47     pooka 		rumpuser_mutex_enter_nowrap(sicpumtx);
    207       1.47     pooka 		while (TAILQ_EMPTY(&sicpupending)) {
    208       1.47     pooka 			rumpuser_cv_wait_nowrap(sicpucv, sicpumtx);
    209       1.47     pooka 		}
    210       1.47     pooka 		sip = TAILQ_FIRST(&sicpupending);
    211       1.47     pooka 		TAILQ_REMOVE(&sicpupending, sip, sip_entries_cpu);
    212       1.47     pooka 		sip->sip_onlist_cpu = false;
    213       1.47     pooka 		rumpuser_mutex_exit(sicpumtx);
    214       1.47     pooka 
    215       1.47     pooka 		/*
    216       1.47     pooka 		 * ok, now figure out which cpu we need the softint to
    217       1.47     pooka 		 * be handled on
    218       1.47     pooka 		 */
    219       1.47     pooka 		si = sip->sip_parent;
    220       1.47     pooka 		cidx = sip - si->si_entry;
    221       1.47     pooka 		ci = cpu_lookup(cidx);
    222       1.47     pooka 		me->l_target_cpu = ci;
    223       1.47     pooka 
    224       1.47     pooka 		/* schedule ourselves there, and then schedule the softint */
    225       1.47     pooka 		rump_schedule();
    226       1.47     pooka 		KASSERT(curcpu() == ci);
    227       1.47     pooka 		softint_schedule(si);
    228       1.47     pooka 		rump_unschedule();
    229       1.47     pooka 	}
    230       1.47     pooka 	panic("sithread_cpu_bouncer unreasonable");
    231       1.47     pooka }
    232       1.47     pooka 
    233       1.41     pooka static kmutex_t sithr_emtx;
    234       1.41     pooka static unsigned int sithr_est;
    235       1.41     pooka static int sithr_canest;
    236       1.41     pooka 
    237       1.41     pooka /*
    238       1.41     pooka  * Create softint handler threads when the softint for each respective
    239       1.41     pooka  * level is established for the first time.  Most rump kernels don't
    240       1.41     pooka  * need at least half of the softint levels, so on-demand saves bootstrap
    241       1.41     pooka  * time and memory resources.  Note, though, that this routine may be
    242       1.41     pooka  * called before it's possible to call kthread_create().  Creation of
    243       1.41     pooka  * those softints (SOFTINT_CLOCK, as of writing this) will be deferred
    244       1.41     pooka  * to until softint_init() is called for the main CPU.
    245       1.41     pooka  */
    246       1.41     pooka static void
    247       1.41     pooka sithread_establish(int level)
    248       1.41     pooka {
    249       1.41     pooka 	int docreate, rv;
    250       1.41     pooka 	int lvlbit = 1<<level;
    251       1.41     pooka 	int i;
    252       1.41     pooka 
    253       1.41     pooka 	KASSERT((level & ~SOFTINT_LVLMASK) == 0);
    254       1.41     pooka 	if (__predict_true(sithr_est & lvlbit))
    255       1.41     pooka 		return;
    256       1.41     pooka 
    257       1.41     pooka 	mutex_enter(&sithr_emtx);
    258       1.41     pooka 	docreate = (sithr_est & lvlbit) == 0 && sithr_canest;
    259       1.41     pooka 	sithr_est |= lvlbit;
    260       1.41     pooka 	mutex_exit(&sithr_emtx);
    261       1.41     pooka 
    262       1.41     pooka 	if (docreate) {
    263       1.41     pooka 		for (i = 0; i < ncpu_final; i++) {
    264       1.41     pooka 			if ((rv = kthread_create(PRI_NONE,
    265       1.41     pooka 			    KTHREAD_MPSAFE | KTHREAD_INTR,
    266       1.41     pooka 			    cpu_lookup(i), sithread, (void *)(uintptr_t)level,
    267       1.41     pooka 			    NULL, "rsi%d/%d", i, level)) != 0)
    268       1.41     pooka 				panic("softint thread create failed: %d", rv);
    269       1.41     pooka 		}
    270       1.41     pooka 	}
    271       1.41     pooka }
    272       1.41     pooka 
    273        1.5     pooka void
    274       1.34     pooka rump_intr_init(int numcpu)
    275       1.22     pooka {
    276       1.22     pooka 
    277       1.23     pooka 	cv_init(&lbolt, "oh kath ra");
    278       1.41     pooka 	mutex_init(&sithr_emtx, MUTEX_DEFAULT, IPL_NONE);
    279       1.34     pooka 	ncpu_final = numcpu;
    280       1.22     pooka }
    281       1.22     pooka 
    282       1.22     pooka void
    283        1.5     pooka softint_init(struct cpu_info *ci)
    284        1.2        ad {
    285       1.22     pooka 	struct cpu_data *cd = &ci->ci_data;
    286       1.22     pooka 	struct softint_lev *slev;
    287       1.20     pooka 	int rv, i;
    288        1.5     pooka 
    289       1.22     pooka 	if (!rump_threads)
    290       1.22     pooka 		return;
    291       1.22     pooka 
    292       1.46     pooka 	slev = kmem_alloc(sizeof(struct softint_lev) * SOFTINT_COUNT, KM_SLEEP);
    293       1.46     pooka 	for (i = 0; i < SOFTINT_COUNT; i++) {
    294       1.46     pooka 		rumpuser_cv_init(&slev[i].si_cv);
    295       1.48     pooka 		TAILQ_INIT(&slev[i].si_pending);
    296       1.46     pooka 	}
    297       1.46     pooka 	cd->cpu_softcpu = slev;
    298       1.46     pooka 
    299       1.41     pooka 	/* overloaded global init ... */
    300       1.46     pooka 	/* XXX: should be done the last time we are called */
    301       1.25     pooka 	if (ci->ci_index == 0) {
    302       1.41     pooka 		int sithr_swap;
    303       1.41     pooka 
    304       1.51     pooka 		/* pretend that we have our own for these */
    305       1.51     pooka 		stathz = 1;
    306       1.51     pooka 		schedhz = 1;
    307       1.51     pooka 		profhz = 1;
    308       1.51     pooka 
    309       1.51     pooka 		initclocks();
    310       1.41     pooka 
    311       1.41     pooka 		/* create deferred softint threads */
    312       1.41     pooka 		mutex_enter(&sithr_emtx);
    313       1.41     pooka 		sithr_swap = sithr_est;
    314       1.41     pooka 		sithr_est = 0;
    315       1.41     pooka 		sithr_canest = 1;
    316       1.41     pooka 		mutex_exit(&sithr_emtx);
    317       1.41     pooka 		for (i = 0; i < SOFTINT_COUNT; i++) {
    318       1.41     pooka 			if (sithr_swap & (1<<i))
    319       1.41     pooka 				sithread_establish(i);
    320       1.41     pooka 		}
    321       1.25     pooka 	}
    322       1.25     pooka 
    323       1.41     pooka 	/* well, not really a "soft" interrupt ... */
    324       1.41     pooka 	if ((rv = kthread_create(PRI_NONE, KTHREAD_MPSAFE,
    325       1.41     pooka 	    ci, doclock, NULL, NULL, "rumpclk%d", ci->ci_index)) != 0)
    326       1.25     pooka 		panic("clock thread creation failed: %d", rv);
    327       1.47     pooka 
    328       1.47     pooka 	/* not one either, but at least a softint helper */
    329  1.56.24.1  perseant 	if (CPU_IS_PRIMARY(ci)) {
    330  1.56.24.1  perseant 		rumpuser_mutex_init(&sicpumtx, RUMPUSER_MTX_SPIN);
    331  1.56.24.1  perseant 		rumpuser_cv_init(&sicpucv);
    332  1.56.24.1  perseant 		if ((rv = kthread_create(PRI_NONE, KTHREAD_MPSAFE,
    333  1.56.24.1  perseant 		    NULL, sithread_cpu_bouncer, NULL, NULL, "sipbnc")) != 0)
    334  1.56.24.1  perseant 			panic("softint cpu bouncer creation failed: %d", rv);
    335  1.56.24.1  perseant 	}
    336        1.2        ad }
    337        1.2        ad 
    338        1.5     pooka void *
    339        1.5     pooka softint_establish(u_int flags, void (*func)(void *), void *arg)
    340        1.2        ad {
    341        1.5     pooka 	struct softint *si;
    342       1.32     pooka 	struct softint_percpu *sip;
    343       1.41     pooka 	int level = flags & SOFTINT_LVLMASK;
    344       1.32     pooka 	int i;
    345        1.2        ad 
    346       1.28     pooka 	si = malloc(sizeof(*si), M_TEMP, M_WAITOK);
    347        1.5     pooka 	si->si_func = func;
    348        1.5     pooka 	si->si_arg = arg;
    349       1.18     pooka 	si->si_flags = flags & SOFTINT_MPSAFE ? SI_MPSAFE : 0;
    350       1.41     pooka 	si->si_level = level;
    351       1.20     pooka 	KASSERT(si->si_level < SOFTINT_COUNT);
    352       1.34     pooka 	si->si_entry = malloc(sizeof(*si->si_entry) * ncpu_final,
    353       1.32     pooka 	    M_TEMP, M_WAITOK | M_ZERO);
    354       1.34     pooka 	for (i = 0; i < ncpu_final; i++) {
    355       1.32     pooka 		sip = &si->si_entry[i];
    356       1.32     pooka 		sip->sip_parent = si;
    357       1.32     pooka 	}
    358       1.41     pooka 	sithread_establish(level);
    359        1.5     pooka 
    360        1.5     pooka 	return si;
    361        1.2        ad }
    362        1.2        ad 
    363       1.47     pooka static struct softint_percpu *
    364       1.47     pooka sitosip(struct softint *si, struct cpu_info *ci)
    365       1.47     pooka {
    366       1.47     pooka 
    367       1.47     pooka 	return &si->si_entry[ci->ci_index];
    368       1.47     pooka }
    369       1.47     pooka 
    370       1.33     pooka /*
    371       1.33     pooka  * Soft interrupts bring two choices.  If we are running with thread
    372       1.33     pooka  * support enabled, defer execution, otherwise execute in place.
    373       1.33     pooka  */
    374       1.33     pooka 
    375        1.2        ad void
    376        1.2        ad softint_schedule(void *arg)
    377        1.2        ad {
    378        1.5     pooka 	struct softint *si = arg;
    379       1.42     pooka 	struct cpu_info *ci = curcpu();
    380       1.47     pooka 	struct softint_percpu *sip = sitosip(si, ci);
    381       1.42     pooka 	struct cpu_data *cd = &ci->ci_data;
    382       1.22     pooka 	struct softint_lev *si_lvl = cd->cpu_softcpu;
    383        1.2        ad 
    384        1.5     pooka 	if (!rump_threads) {
    385        1.5     pooka 		si->si_func(si->si_arg);
    386        1.5     pooka 	} else {
    387       1.32     pooka 		if (!sip->sip_onlist) {
    388       1.48     pooka 			TAILQ_INSERT_TAIL(&si_lvl[si->si_level].si_pending,
    389       1.32     pooka 			    sip, sip_entries);
    390       1.32     pooka 			sip->sip_onlist = true;
    391        1.5     pooka 		}
    392        1.5     pooka 	}
    393        1.2        ad }
    394        1.2        ad 
    395       1.47     pooka /*
    396       1.47     pooka  * Like softint_schedule(), except schedule softint to be handled on
    397       1.47     pooka  * the core designated by ci_tgt instead of the core the call is made on.
    398       1.47     pooka  *
    399       1.47     pooka  * Unlike softint_schedule(), the performance is not important
    400       1.47     pooka  * (unless ci_tgt == curcpu): high-performance rump kernel I/O stacks
    401       1.47     pooka  * should arrange data to already be on the right core at the driver
    402       1.47     pooka  * layer.
    403       1.47     pooka  */
    404       1.43     rmind void
    405       1.47     pooka softint_schedule_cpu(void *arg, struct cpu_info *ci_tgt)
    406       1.43     rmind {
    407       1.47     pooka 	struct softint *si = arg;
    408       1.47     pooka 	struct cpu_info *ci_cur = curcpu();
    409       1.47     pooka 	struct softint_percpu *sip;
    410       1.47     pooka 
    411       1.47     pooka 	KASSERT(rump_threads);
    412       1.47     pooka 
    413       1.47     pooka 	/* preferred case (which can be optimized some day) */
    414       1.47     pooka 	if (ci_cur == ci_tgt) {
    415       1.47     pooka 		softint_schedule(si);
    416       1.47     pooka 		return;
    417       1.47     pooka 	}
    418       1.47     pooka 
    419       1.44     rmind 	/*
    420       1.47     pooka 	 * no?  then it's softint turtles all the way down
    421       1.44     rmind 	 */
    422       1.47     pooka 
    423       1.47     pooka 	sip = sitosip(si, ci_tgt);
    424       1.47     pooka 	rumpuser_mutex_enter_nowrap(sicpumtx);
    425       1.47     pooka 	if (sip->sip_onlist_cpu) {
    426       1.47     pooka 		rumpuser_mutex_exit(sicpumtx);
    427       1.47     pooka 		return;
    428       1.47     pooka 	}
    429       1.47     pooka 	TAILQ_INSERT_TAIL(&sicpupending, sip, sip_entries_cpu);
    430       1.47     pooka 	sip->sip_onlist_cpu = true;
    431       1.47     pooka 	rumpuser_cv_signal(sicpucv);
    432       1.47     pooka 	rumpuser_mutex_exit(sicpumtx);
    433       1.43     rmind }
    434       1.43     rmind 
    435       1.32     pooka /*
    436       1.32     pooka  * flimsy disestablish: should wait for softints to finish.
    437       1.32     pooka  */
    438       1.18     pooka void
    439       1.18     pooka softint_disestablish(void *cook)
    440       1.18     pooka {
    441       1.18     pooka 	struct softint *si = cook;
    442       1.32     pooka 	int i;
    443       1.18     pooka 
    444       1.34     pooka 	for (i = 0; i < ncpu_final; i++) {
    445       1.32     pooka 		struct softint_percpu *sip;
    446       1.32     pooka 
    447       1.32     pooka 		sip = &si->si_entry[i];
    448       1.32     pooka 		if (sip->sip_onlist) {
    449       1.32     pooka 			si->si_flags |= SI_KILLME;
    450       1.32     pooka 			return;
    451       1.32     pooka 		}
    452       1.18     pooka 	}
    453       1.32     pooka 	free(si->si_entry, M_TEMP);
    454       1.28     pooka 	free(si, M_TEMP);
    455       1.18     pooka }
    456       1.18     pooka 
    457       1.20     pooka void
    458       1.20     pooka rump_softint_run(struct cpu_info *ci)
    459       1.20     pooka {
    460       1.22     pooka 	struct cpu_data *cd = &ci->ci_data;
    461       1.22     pooka 	struct softint_lev *si_lvl = cd->cpu_softcpu;
    462       1.20     pooka 	int i;
    463       1.20     pooka 
    464       1.22     pooka 	if (!rump_threads)
    465       1.22     pooka 		return;
    466       1.22     pooka 
    467       1.20     pooka 	for (i = 0; i < SOFTINT_COUNT; i++) {
    468       1.48     pooka 		if (!TAILQ_EMPTY(&si_lvl[i].si_pending))
    469       1.56  christos 			rump_schedlock_cv_signal(ci, si_lvl[i].si_cv);
    470       1.20     pooka 	}
    471       1.20     pooka }
    472       1.20     pooka 
    473        1.2        ad bool
    474        1.9  christos cpu_intr_p(void)
    475        1.2        ad {
    476        1.2        ad 
    477        1.2        ad 	return false;
    478        1.2        ad }
    479