xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ross Philipson <ross.philipson@citrix.com>
To: xen-devel@lists.xen.org
Cc: Ross Philipson <ross.philipson@citrix.com>
Subject: [PATCH (V9) 1/2] xen: events, exposes evtchn_alloc_unbound_domain
Date: Tue, 28 May 2013 15:43:30 -0400	[thread overview]
Message-ID: <1369770211-4509-2-git-send-email-ross.philipson@citrix.com> (raw)
In-Reply-To: <1369770211-4509-1-git-send-email-ross.philipson@citrix.com>

Exposes evtchn_alloc_unbound_domain to the rest of
Xen so we can create allocated unbound evtchn within Xen.

Signed-off-by: Ross Philipson <ross.philipson@citrix.com>
---
 xen/common/event_channel.c |   45 +++++++++++++++++++++++++++++++-------------
 xen/include/xen/event.h    |    3 +++
 2 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 64c976b..d416f97 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -160,35 +160,54 @@ 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;
 
-    d = rcu_lock_domain_by_any_id(dom);
+    d = rcu_lock_domain_by_any_id(alloc->dom);
     if ( d == NULL )
         return -ESRCH;
 
-    spin_lock(&d->event_lock);
+    rc = evtchn_alloc_unbound_domain(d, &alloc->port, alloc->remote_dom, 1);
+    if ( rc )
+        ERROR_EXIT_DOM((int)rc, d);
 
-    if ( (port = get_free_port(d)) < 0 )
-        ERROR_EXIT_DOM(port, d);
-    chn = evtchn_from_port(d, port);
+ out:
+    rcu_unlock_domain(d);
 
-    rc = xsm_evtchn_unbound(XSM_TARGET, d, chn, alloc->remote_dom);
-    if ( rc )
+    return rc;
+}
+
+int evtchn_alloc_unbound_domain(struct domain *d, evtchn_port_t *port,
+                                domid_t remote_domid, bool_t call_xsm)
+{
+    struct evtchn *chn;
+    int           rc;
+    int           free_port;
+
+    spin_lock(&d->event_lock);
+
+    rc = free_port = get_free_port(d);
+    if ( free_port < 0 )
         goto out;
 
+    chn = evtchn_from_port(d, free_port);
+    if ( call_xsm )
+    {
+        rc = xsm_evtchn_unbound(XSM_TARGET, 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;
+    *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 4ac39ad..5edca53 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, bool_t call_xsm);
+
 /* Internal event channel object accessors */
 #define bucket_from_port(d,p) \
     ((d)->evtchn[(p)/EVTCHNS_PER_BUCKET])
-- 
1.7.10.4

  reply	other threads:[~2013-05-28 19:43 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-28 19:43 [PATCH (V9) 0/2] Add V4V to Xen Ross Philipson
2013-05-28 19:43 ` Ross Philipson [this message]
2013-05-28 19:43 ` [PATCH (V9) 2/2] xen: Add V4V implementation Ross Philipson
2013-05-29  0:43   ` Matt Wilson
2013-05-29 19:28     ` Ross Philipson
2013-05-29  8:34   ` Jan Beulich
2013-05-29 19:26     ` Ross Philipson
2013-05-30  5:16       ` Jan Beulich
2013-05-29  9:56   ` Vincent Hanquez
2013-05-30 16:20   ` Tim Deegan
2013-06-04 18:01     ` Ross Philipson
2013-06-10 15:06   ` David Vrabel
2013-05-30 11:57 ` [PATCH (V9) 0/2] Add V4V to Xen Ian Campbell
2013-05-31  7:36   ` Vincent Hanquez
2013-05-31  7:50     ` Ian Campbell
2013-05-31  8:56       ` Vincent Hanquez
2013-05-31  9:01         ` Ian Campbell
2013-05-31  9:26           ` Vincent Hanquez
2013-05-31 16:29             ` Ross Philipson
2013-05-31 16:38               ` Ian Campbell
2013-05-30 12:07 ` Ian Campbell
2013-05-30 16:08   ` David Vrabel
2013-05-31  7:25     ` Vincent Hanquez
2013-05-31 10:21       ` David Vrabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1369770211-4509-2-git-send-email-ross.philipson@citrix.com \
    --to=ross.philipson@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).