From: Jean Guyader <jean.guyader@citrix.com>
To: Jean Guyader <jean.guyader@gmail.com>
Cc: "Tim (Xen.org)" <tim@xen.org>,
Ian Campbell <Ian.Campbell@citrix.com>,
"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH 4/5] xen: events, exposes evtchn_alloc_unbound_domain
Date: Fri, 10 Aug 2012 00:25:47 +0100 [thread overview]
Message-ID: <20120809232547.GA21925@spongy> (raw)
In-Reply-To: <CAEBdQ91rVN-wFwWBkfX1Ne133c4TDeXk+iktTDLTuM3StXdRFw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2331 bytes --]
On 09/08 11:40, Jean Guyader wrote:
> On 9 August 2012 11:35, Tim Deegan <tim@xen.org> wrote:
> > At 11:23 +0100 on 09 Aug (1344511426), Ian Campbell wrote:
> >> On Thu, 2012-08-09 at 11:06 +0100, Tim Deegan wrote:
> >> > At 20:50 +0100 on 03 Aug (1344027053), Jean Guyader wrote:
> >> > >
> >> > > Exposes evtchn_alloc_unbound_domain to the rest of
> >> > > Xen so we can create allocated unbound evtchn within Xen.
> >> > >
> >> > > Signed-off-by: Jean Guyader <jean.guyader@citrix.com>
> >> >
> >> > > @@ -161,18 +163,18 @@ 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;
> >> > > + int rc;
> >> >
> >> > The function returns long; if you're tidying this up to be an int, might
> >> > as well change the return type too.
> >>
> >> I'm not sure if this is relevant but Jan just sent a patch to "make all
> >> (native) hypercalls consistently have "long" return type". I
> >> think/suspect this rc here turns into the result of the hypercall?
> >>
> >> Jan's patch was motivated by something to do with sign extension when a
> >> hypercall's int return is written to the long in the multicall arg
> >> struct which causes strangeness. Perhaps not totally relevant to
> >> evtchn_alloc which is unlikely to be in a MC.
> >
> > Yes, this eventually ends up in a hypercall handler, but s/long/int/
> > here doesn't cause problems because
> > - rc is only ever set to an 'int' value here so we can't lose data
> > from the type being too narrow; and
> > - Those int values get cast up to long (either in here or in the
> > caller) directly, which will sign-extend the.
> >
> > It really doesn't matter whether this function returns an int or a long,
> > but it's a bit untidy to change it half-way.
> >
>
> The main reason why I changed it only base ERROR_EXIT_DOM expects an int based
> on the format string. I guess I could cast the long in int for the
> call to ERROR_EXIT_DOM
> but that doesn't really look nice either.
>
Hi,
Here is a new version that should address the comments from Tim and Jan.
Signed-off-by: Jean Guyader <jean.guyader@citrix.com>
Jean
[-- Attachment #2: evtchn_alloc_unbound_domain.patch --]
[-- Type: text/x-diff, Size: 2881 bytes --]
commit c43dbcee9c4e9d65520f9a562b39e8e6455efc36
Author: Jean Guyader <jean.guyader@citrix.com>
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..880395e 100644
--- 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,
+ alloc->remote_dom == DOMID_SELF ? current->domain->domain_id
+ : alloc->remote_dom);
+ if ( rc )
+ ERROR_EXIT_DOM((int)rc, d);
+
+ alloc->port = port;
+
+ 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 )
- chn->u.unbound.remote_domid = current->domain->domain_id;
+ chn->u.unbound.remote_domid = remote_domid;
- 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 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])
[-- Attachment #3: Type: text/plain, Size: 126 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2012-08-09 23:25 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-03 19:50 [PATCH 0/5] RFC: V4V (v3) Jean Guyader
2012-08-03 19:50 ` [PATCH 1/5] xen: add ssize_t Jean Guyader
2012-08-06 8:08 ` Jan Beulich
2012-08-06 14:47 ` Jean Guyader
2012-08-09 9:51 ` Tim Deegan
2012-08-09 10:19 ` Jean Guyader
2012-08-09 10:39 ` Jan Beulich
2012-08-09 10:48 ` Jean Guyader
2012-08-09 13:02 ` Jan Beulich
2012-08-09 10:59 ` Tim Deegan
2012-08-09 11:08 ` Jean Guyader
2012-08-03 19:50 ` [PATCH 2/5] xen: Introduce guest_handle_for_field Jean Guyader
2012-08-03 19:50 ` [PATCH 3/5] xen: virq, remove VIRQ_XC_RESERVED Jean Guyader
2012-08-06 8:10 ` Jan Beulich
2012-08-06 14:46 ` Jean Guyader
2012-08-06 14:49 ` Andrew Cooper
2012-08-06 14:56 ` Ian Campbell
2012-08-06 15:01 ` Jean Guyader
2012-08-06 15:13 ` Ian Campbell
2012-08-06 15:46 ` Jan Beulich
2012-08-03 19:50 ` [PATCH 4/5] xen: events, exposes evtchn_alloc_unbound_domain Jean Guyader
2012-08-06 8:19 ` Jan Beulich
2012-08-09 10:06 ` Tim Deegan
2012-08-09 10:23 ` Ian Campbell
2012-08-09 10:35 ` Tim Deegan
2012-08-09 10:40 ` Jean Guyader
2012-08-09 23:25 ` Jean Guyader [this message]
2012-08-10 7:35 ` Jan Beulich
2012-08-10 7:51 ` Jean Guyader
2012-08-10 7:57 ` Jan Beulich
2012-08-23 12:03 ` Jean Guyader
2012-08-03 19:50 ` [PATCH 5/5] xen: Add V4V implementation Jean Guyader
2012-08-06 8:45 ` Jan Beulich
2012-08-23 11:57 ` Jean Guyader
2012-08-24 20:06 ` Jan Beulich
2012-09-01 20:58 ` Jean Guyader
2012-09-01 20:56 ` Jean Guyader
2013-06-11 17:10 ` [PATCH 5/5] xen: Add V4V implementation - padding question Ross Philipson
2013-06-11 17:25 ` Tim Deegan
2013-06-11 17:40 ` Ross Philipson
2013-06-11 17:54 ` Ross Philipson
2013-06-11 18:04 ` Tim Deegan
2013-06-12 7:45 ` Jan Beulich
2013-06-13 17:21 ` Stefano Stabellini
2012-08-09 10:38 ` [PATCH 5/5] xen: Add V4V implementation Tim Deegan
2012-08-10 16:51 ` Jean Guyader
2012-08-13 9:38 ` Tim Deegan
2012-08-13 12:43 ` Jean Guyader
2012-08-16 12:32 ` Tim Deegan
2012-08-04 13:24 ` [PATCH 0/5] RFC: V4V (v3) Jean Guyader
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=20120809232547.GA21925@spongy \
--to=jean.guyader@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=jean.guyader@gmail.com \
--cc=tim@xen.org \
--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).