Module Name: src Committed By: cherry Date: Wed Oct 10 03:54:54 UTC 2018
Modified Files: src/sys/arch/xen/xen: xenevt.c Log Message: Do not re-expose the innards of evtchn.c, now that we have a way to register interrupts via intr.c:intr_establish_xname() evtchn.c is going to get refactored soon, so use the latter method. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/arch/xen/xen/xenevt.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/xen/xen/xenevt.c diff -u src/sys/arch/xen/xen/xenevt.c:1.48 src/sys/arch/xen/xen/xenevt.c:1.49 --- src/sys/arch/xen/xen/xenevt.c:1.48 Thu Nov 30 20:25:54 2017 +++ src/sys/arch/xen/xen/xenevt.c Wed Oct 10 03:54:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: xenevt.c,v 1.48 2017/11/30 20:25:54 christos Exp $ */ +/* $NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $ */ /* * Copyright (c) 2005 Manuel Bouyer. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.48 2017/11/30 20:25:54 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: xenevt.c,v 1.49 2018/10/10 03:54:54 cherry Exp $"); #include "opt_xen.h" #include <sys/param.h> @@ -145,15 +145,28 @@ long xenevt_ev1; long xenevt_ev2[NR_EVENT_CHANNELS]; static int xenevt_processevt(void *); +static evtchn_port_t xenevt_alloc_event(void) +{ + evtchn_op_t op; + op.cmd = EVTCHNOP_alloc_unbound; + op.u.alloc_unbound.dom = DOMID_SELF; + op.u.alloc_unbound.remote_dom = DOMID_SELF; + if (HYPERVISOR_event_channel_op(&op) != 0) + panic("%s: Failed to allocate loopback event\n", __func__); + + return op.u.alloc_unbound.port; +} + /* called at boot time */ void xenevtattach(int n) { struct intrhand *ih; - int s; int level = IPL_HIGH; #ifdef MULTIPROCESSOR bool mpsafe = (level != IPL_VM); +#else + bool mpsafe = false; #endif /* MULTIPROCESSOR */ mutex_init(&devevent_lock, MUTEX_DEFAULT, IPL_HIGH); @@ -165,26 +178,19 @@ xenevtattach(int n) xenevt_ev1 = 0; memset(xenevt_ev2, 0, sizeof(xenevt_ev2)); - /* register a handler at splhigh, so that spllower() will call us */ - ih = malloc(sizeof (struct intrhand), M_DEVBUF, - M_WAITOK|M_ZERO); - if (ih == NULL) - panic("can't allocate xenevt interrupt source"); - ih->ih_level = level; - ih->ih_fun = ih->ih_realfun = xenevt_processevt; - ih->ih_arg = ih->ih_realarg = NULL; - ih->ih_next = NULL; - ih->ih_cpu = &cpu_info_primary; -#ifdef MULTIPROCESSOR - if (!mpsafe) { - ih->ih_fun = xen_intr_biglock_wrapper; - ih->ih_arg = ih; - } -#endif /* MULTIPROCESSOR */ + /* + * Allocate a loopback event port. + * This helps us massage xenevt_processevt() into the + * callchain at the appropriate level using only + * intr_establish_xname(). + */ + evtchn_port_t evtchn = xenevt_alloc_event(); + + /* The real objective here is to wiggle into the ih callchain for IPL level */ + ih = intr_establish_xname(0, &xen_pic, evtchn, IST_LEVEL, level, + xenevt_processevt, NULL, mpsafe, "xenevt"); - s = splhigh(); - event_set_iplhandler(ih->ih_cpu, ih, level); - splx(s); + KASSERT(ih != NULL); } /* register pending event - always called with interrupt disabled */