From: Ian Campbell <ian.campbell@citrix.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: wei.liu2@citrix.com, ian.jackson@eu.citrix.com,
qemu-devel@nongnu.org, xen-devel@lists.xen.org
Subject: Re: [Qemu-devel] [PATCH QEMU-XEN v6 4/8] xen: Switch uses of xc_map_foreign_range into xc_map_foreign_pages
Date: Fri, 11 Dec 2015 15:23:16 +0000 [thread overview]
Message-ID: <1449847396.30975.49.camel@citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1512111425480.3023@kaball.uk.xensource.com>
On Fri, 2015-12-11 at 14:26 +0000, Stefano Stabellini wrote:
> On Wed, 9 Dec 2015, Ian Campbell wrote:
> > On Thu, 2015-12-03 at 11:23 +0000, Ian Campbell wrote:
> > > diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
> > > index 5e324ef..c96d974 100644
> > > --- a/hw/display/xenfb.c
> > > +++ b/hw/display/xenfb.c
> > > @@ -104,9 +104,8 @@ static int common_bind(struct common *c)
> > > if (xenstore_read_fe_int(&c->xendev, "event-channel", &c-
> > > >xendev.remote_port) == -1)
> > > return -1;
> > >
> > > - c->page = xc_map_foreign_range(xen_xc, c->xendev.dom,
> > > - XC_PAGE_SIZE,
> > > - PROT_READ | PROT_WRITE, mfn);
> > > + c->page = xc_map_foreign_pages(xen_xc, c->xendev.dom,
> > > + PROT_READ | PROT_WRITE, &mfn, 1);
> >
> > This doesn't build for i386 userspace, since mfn is a uint64_t but
> > xc_map_foreign_pages() wants a xen_pfn_t * (where xen_pfn_t == unsigned
> > long on x86).
> >
> > Until now that was just a truncation which was already checked for
> > with:
> >
> > uint64_t mfn;
> >
> > if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1)
> > return -1;
> > assert(mfn == (xen_pfn_t)mfn);
> >
> > I think in principal passing "(xen_pfn_t *)&mfn" would ok (since it is
> > a
> > singleton array in this case), but I was thinking of going a bit
> > further
> > and:
> >
> > diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
> > index 8b86b4a..54585fa 100644
> > --- a/hw/display/xenfb.c
> > +++ b/hw/display/xenfb.c
> > @@ -95,11 +95,13 @@ struct XenFB {
> >
> > static int common_bind(struct common *c)
> > {
> > - uint64_t mfn;
> > + uint64_t val;
> > + xen_pfn_t mfn;
> >
> > - if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1)
> > + if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &val) == -1)
> > return -1;
> > - assert(mfn == (xen_pfn_t)mfn);
> > + mfn = (xen_pfn_t)val;
> > + assert(val == mfn);
> >
> > if (xenstore_read_fe_int(&c->xendev, "event-channel", &c-
> > >xendev.remote_port) == -1)
> > return -1;
> >
> > Stefano, what do you think/prefer? An alternative to the above
>
> I like this change because it makes the code more obvious
Thanks, with that change may I keep your Reviewed-by?
next prev parent reply other threads:[~2015-12-11 15:24 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-03 11:21 [Qemu-devel] [Minios-devel] [PATCH v6 0/<VARIOUS>] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 0/8] " Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 1/8] xen_console: correctly cleanup primary console on teardown Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 2/8] xen: Switch to libxenevtchn interface for compat shims Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 3/8] xen: Switch to libxengnttab " Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 4/8] xen: Switch uses of xc_map_foreign_range into xc_map_foreign_pages Ian Campbell
2015-12-04 15:26 ` Stefano Stabellini
2015-12-09 13:41 ` Ian Campbell
2015-12-09 13:56 ` [Qemu-devel] [Xen-devel] " Andrew Cooper
2015-12-09 14:05 ` Ian Campbell
2015-12-11 14:26 ` [Qemu-devel] " Stefano Stabellini
2015-12-11 15:23 ` Ian Campbell [this message]
2015-12-11 16:42 ` Stefano Stabellini
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 5/8] xen: Switch uses of xc_map_foreign_{pages, bulk} to use libxenforeignmemory API Ian Campbell
2015-12-04 15:26 ` Stefano Stabellini
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 6/8] xen: Use stable library interfaces when they are available Ian Campbell
2015-12-04 15:31 ` Stefano Stabellini
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 7/8] xen: domainbuild: reopen libxenctrl interface after forking for domain watcher Ian Campbell
2015-12-03 11:23 ` [Qemu-devel] [PATCH QEMU-XEN v6 8/8] xen: make it possible to build without the Xen PV domain builder Ian Campbell
2015-12-09 12:37 ` [Qemu-devel] [Minios-devel] [PATCH v6 0/<VARIOUS>] Begin to disentangle libxenctrl and provide some stable libraries Ian Campbell
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=1449847396.30975.49.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=qemu-devel@nongnu.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@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).