From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Guyader Subject: [PATCH 3/4] xen: events, exposes evtchn_alloc_unbound_domain Date: Thu, 20 Sep 2012 10:47:05 +0100 Message-ID: <1348134426-25320-4-git-send-email-jean.guyader@citrix.com> References: <1348134426-25320-1-git-send-email-jean.guyader@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------true" Return-path: In-Reply-To: <1348134426-25320-1-git-send-email-jean.guyader@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: tim@xen.org, Jean Guyader , JBeulich@suse.com List-Id: xen-devel@lists.xenproject.org --------------true Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: quoted-printable Exposes evtchn_alloc_unbound_domain to the rest of Xen so we can create allocated unbound evtchn within Xen. Signed-off-by: Jean Guyader --- xen/common/event_channel.c | 39 +++++++++++++++++++++++++++-----------= - xen/include/xen/event.h | 3 +++ 2 files changed, 30 insertions(+), 12 deletions(-) --------------true Content-Type: text/x-patch; name="0003-xen-events-exposes-evtchn_alloc_unbound_domain.patch" Content-Disposition: attachment; filename="0003-xen-events-exposes-evtchn_alloc_unbound_domain.patch" Content-Transfer-Encoding: quoted-printable diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 53777f8..6a0e342 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -159,36 +159,51 @@ static int get_free_port(struct domain *d) =20 static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) { - struct evtchn *chn; struct domain *d; - int port; - domid_t dom =3D alloc->dom; long rc; =20 - rc =3D rcu_lock_target_domain_by_id(dom, &d); + rc =3D rcu_lock_target_domain_by_id(alloc->dom, &d); if ( rc ) return rc; =20 + rc =3D evtchn_alloc_unbound_domain(d, &alloc->port, alloc->remote_do= m); + if ( rc ) + ERROR_EXIT_DOM((int)rc, d); + + out: + rcu_unlock_domain(d); + + return rc; +} + +int evtchn_alloc_unbound_domain(struct domain *d, evtchn_port_t *port, + domid_t remote_domid) +{ + struct evtchn *chn; + int rc; + int free_port; + spin_lock(&d->event_lock); =20 - if ( (port =3D get_free_port(d)) < 0 ) - ERROR_EXIT_DOM(port, d); - chn =3D evtchn_from_port(d, port); + rc =3D free_port =3D get_free_port(d); + if ( free_port < 0 ) + goto out; =20 - rc =3D xsm_evtchn_unbound(d, chn, alloc->remote_dom); + chn =3D evtchn_from_port(d, free_port); + rc =3D xsm_evtchn_unbound(d, chn, remote_domid); if ( rc ) goto out; =20 chn->state =3D ECS_UNBOUND; - if ( (chn->u.unbound.remote_domid =3D alloc->remote_dom) =3D=3D DOMI= D_SELF ) + if ( (chn->u.unbound.remote_domid =3D remote_domid) =3D=3D DOMID_SEL= F ) chn->u.unbound.remote_domid =3D current->domain->domain_id; =20 - alloc->port =3D port; + *port =3D free_port; + /* Everything is fine, returns 0 */ + rc =3D 0; =20 out: spin_unlock(&d->event_lock); - rcu_unlock_domain(d); - return rc; } =20 diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index 71c3e92..1a0c832 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -69,6 +69,9 @@ int guest_enabled_event(struct vcpu *v, uint32_t virq); /* Notify remote end of a Xen-attached event channel.*/ void notify_via_xen_event_channel(struct domain *ld, int lport); =20 +int evtchn_alloc_unbound_domain(struct domain *d, evtchn_port_t *port, + domid_t remote_domid); + /* Internal event channel object accessors */ #define bucket_from_port(d,p) \ ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET]) --------------true Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------true--