From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Guyader Subject: Re: [PATCH 4/5] xen: events, exposes evtchn_alloc_unbound_domain Date: Fri, 10 Aug 2012 08:51:01 +0100 Message-ID: <20120810075100.GA30606@spongy> References: <1344023454-31425-1-git-send-email-jean.guyader@citrix.com> <1344023454-31425-5-git-send-email-jean.guyader@citrix.com> <20120809100605.GC16986@ocelot.phlegethon.org> <1344507826.32142.116.camel@zakaz.uk.xensource.com> <20120809103557.GA17503@ocelot.phlegethon.org> <20120809232547.GA21925@spongy> <5024D5D00200007800094134@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Return-path: Content-Disposition: inline In-Reply-To: <5024D5D00200007800094134@nat28.tlf.novell.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: Jan Beulich Cc: "Tim (Xen.org)" , Ian Campbell , Jean Guyader , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline On 10/08 08:35, Jan Beulich wrote: > >>> On 10.08.12 at 01:25, Jean Guyader wrote: > >--- a/xen/common/event_channel.c > >+++ b/xen/common/event_channel.c > >@@ -159,9 +159,8 @@ static int get_free_port(struct domain *d) > > > > static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) > > { > >- struct evtchn *chn; > > struct domain *d; > >- int port; > >+ evtchn_port_t port; > > domid_t dom = alloc->dom; > > long rc; > > > >@@ -169,26 +168,47 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) > > if ( rc ) > > return rc; > > > >+ rc = evtchn_alloc_unbound_domain(d, &port, > > Any reason you can't pass &alloc->port here directly? > > >+ alloc->remote_dom == DOMID_SELF ? current->domain->domain_id > >+ : alloc->remote_dom); > > Any reason this can't/shouldn't be done in the called function? > No specific reason for both of those thing. Here is a new version based on your comments. Thanks for reviewing, Jean --FL5UXtIhxfXey3p5 Content-Type: text/x-diff; charset="us-ascii" Content-Disposition: attachment; filename="evtchn_alloc_unbound_domain.patch" commit 208384d74852df9ae26294236d79e33967a75afa Author: Jean Guyader Date: Thu Aug 2 16:19:23 2012 +0100 xen: events, exposes evtchn_alloc_unbound_domain Exposes evtchn_alloc_unbound_domain to the rest of Xen so we can create allocated unbound evtchn within Xen. diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 53777f8..fd626bf 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -159,36 +159,53 @@ static int get_free_port(struct domain *d) static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) { - struct evtchn *chn; struct domain *d; - int port; - domid_t dom = alloc->dom; long rc; - rc = rcu_lock_target_domain_by_id(dom, &d); + rc = rcu_lock_target_domain_by_id(alloc->dom, &d); if ( rc ) return rc; + rc = evtchn_alloc_unbound_domain(d, &alloc->port, alloc->remote_dom); + 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); - if ( (port = get_free_port(d)) < 0 ) - ERROR_EXIT_DOM(port, d); - chn = evtchn_from_port(d, port); + rc = free_port = get_free_port(d); + if ( free_port < 0 ) + goto out; - rc = xsm_evtchn_unbound(d, chn, alloc->remote_dom); + chn = evtchn_from_port(d, free_port); + rc = xsm_evtchn_unbound(d, chn, remote_domid); if ( rc ) goto out; chn->state = ECS_UNBOUND; - if ( (chn->u.unbound.remote_domid = alloc->remote_dom) == DOMID_SELF ) + if ( (chn->u.unbound.remote_domid = remote_domid) == DOMID_SELF ) chn->u.unbound.remote_domid = current->domain->domain_id; - alloc->port = port; + chn->u.unbound.remote_domid = remote_domid; + + *port = free_port; + /* Everything is fine, returns 0 */ + rc = 0; out: spin_unlock(&d->event_lock); - rcu_unlock_domain(d); - return rc; } 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); +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]) --FL5UXtIhxfXey3p5 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 --FL5UXtIhxfXey3p5--