From: Paul Durrant <Paul.Durrant@citrix.com>
To: Roger Pau Monne <roger.pau@citrix.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Wei Liu <wei.liu2@citrix.com>,
Ian Jackson <Ian.Jackson@citrix.com>
Subject: Re: [PATCH v2 REPOST 05/12] tools/libxenctrl: use new xenforeignmemory API to seed grant table
Date: Thu, 24 Aug 2017 16:09:35 +0000 [thread overview]
Message-ID: <ee3fb1061d7849d694901f734fdda045@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <20170824160258.xa65r777jnuacc4l@dhcp-3-128.uk.xensource.com>
> -----Original Message-----
> From: Roger Pau Monne
> Sent: 24 August 2017 17:03
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: xen-devel@lists.xenproject.org; Wei Liu <wei.liu2@citrix.com>; Ian
> Jackson <Ian.Jackson@citrix.com>
> Subject: Re: [Xen-devel] [PATCH v2 REPOST 05/12] tools/libxenctrl: use new
> xenforeignmemory API to seed grant table
>
> On Tue, Aug 22, 2017 at 03:50:59PM +0100, Paul Durrant wrote:
> > A previous patch added support for priv-mapping guest resources directly
> > (rather than having to foreign-map, which requires P2M modification for
> > HVM guests).
> >
> > This patch makes use of the new API to seed the guest grant table unless
> > the underlying infrastructure (i.e. privcmd) doesn't support it, in which
> > case the old scheme is used.
> >
> > NOTE: The call to xc_dom_gnttab_hvm_seed() in hvm_build_set_params()
> was
> > actually unnecessary, as the grant table has already been seeded
> > by a prior call to xc_dom_gnttab_init() made by libxl__build_dom().
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > Acked-by: Marek Marczykowski-Górecki
> <marmarek@invisiblethingslab.com>
> > ---
> > Cc: Ian Jackson <ian.jackson@eu.citrix.com>
> > Cc: Wei Liu <wei.liu2@citrix.com>
> > ---
> > tools/libxc/include/xc_dom.h | 8 +--
> > tools/libxc/xc_dom_boot.c | 102
> ++++++++++++++++++++++++++++--------
> > tools/libxc/xc_sr_restore_x86_hvm.c | 10 ++--
> > tools/libxc/xc_sr_restore_x86_pv.c | 2 +-
> > tools/libxl/libxl_dom.c | 1 -
> > tools/python/xen/lowlevel/xc/xc.c | 6 +--
> > 6 files changed, 92 insertions(+), 37 deletions(-)
> >
> > diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
> > index ce47058c41..d6ca0a8680 100644
> > --- a/tools/libxc/include/xc_dom.h
> > +++ b/tools/libxc/include/xc_dom.h
> > @@ -323,12 +323,8 @@ void *xc_dom_boot_domU_map(struct
> xc_dom_image *dom, xen_pfn_t pfn,
> > int xc_dom_boot_image(struct xc_dom_image *dom);
> > int xc_dom_compat_check(struct xc_dom_image *dom);
> > int xc_dom_gnttab_init(struct xc_dom_image *dom);
> > -int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
> > - xen_pfn_t console_gmfn,
> > - xen_pfn_t xenstore_gmfn,
> > - domid_t console_domid,
> > - domid_t xenstore_domid);
> > -int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid,
> > +int xc_dom_gnttab_seed(xc_interface *xch, domid_t guest_domid,
> > + bool is_hvm,
> > xen_pfn_t console_gmfn,
> > xen_pfn_t xenstore_gmfn,
> > domid_t console_domid,
> > diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
> > index c3b44dd399..fc3174ad7e 100644
> > --- a/tools/libxc/xc_dom_boot.c
> > +++ b/tools/libxc/xc_dom_boot.c
> > @@ -280,11 +280,11 @@ static xen_pfn_t
> xc_dom_gnttab_setup(xc_interface *xch, domid_t domid)
> > return gmfn;
> > }
> >
> > -int xc_dom_gnttab_seed(xc_interface *xch, domid_t domid,
> > - xen_pfn_t console_gmfn,
> > - xen_pfn_t xenstore_gmfn,
> > - domid_t console_domid,
> > - domid_t xenstore_domid)
> > +static int compat_gnttab_seed(xc_interface *xch, domid_t domid,
> > + xen_pfn_t console_gmfn,
> > + xen_pfn_t xenstore_gmfn,
> > + domid_t console_domid,
> > + domid_t xenstore_domid)
> > {
> >
> > xen_pfn_t gnttab_gmfn;
> > @@ -337,11 +337,11 @@ int xc_dom_gnttab_seed(xc_interface *xch,
> domid_t domid,
> > return 0;
> > }
> >
> > -int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
> > - xen_pfn_t console_gpfn,
> > - xen_pfn_t xenstore_gpfn,
> > - domid_t console_domid,
> > - domid_t xenstore_domid)
> > +static int compat_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
> > + xen_pfn_t console_gpfn,
> > + xen_pfn_t xenstore_gpfn,
> > + domid_t console_domid,
> > + domid_t xenstore_domid)
> > {
> > int rc;
> > xen_pfn_t scratch_gpfn;
> > @@ -380,7 +380,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch,
> domid_t domid,
> > return -1;
> > }
> >
> > - rc = xc_dom_gnttab_seed(xch, domid,
> > + rc = compat_gnttab_seed(xch, domid,
> > console_gpfn, xenstore_gpfn,
> > console_domid, xenstore_domid);
> > if (rc != 0)
> > @@ -405,18 +405,78 @@ int xc_dom_gnttab_hvm_seed(xc_interface
> *xch, domid_t domid,
> > return 0;
> > }
> >
> > -int xc_dom_gnttab_init(struct xc_dom_image *dom)
> > +int xc_dom_gnttab_seed(xc_interface *xch, domid_t guest_domid,
> > + bool is_hvm, xen_pfn_t console_gmfn,
> > + xen_pfn_t xenstore_gmfn, domid_t console_domid,
> > + domid_t xenstore_domid)
> > {
> > - if ( xc_dom_translated(dom) ) {
> > - return xc_dom_gnttab_hvm_seed(dom->xch, dom->guest_domid,
> > - dom->console_pfn, dom->xenstore_pfn,
> > - dom->console_domid, dom->xenstore_domid);
> > - } else {
> > - return xc_dom_gnttab_seed(dom->xch, dom->guest_domid,
> > - xc_dom_p2m(dom, dom->console_pfn),
> > - xc_dom_p2m(dom, dom->xenstore_pfn),
> > - dom->console_domid, dom->xenstore_domid);
> > + xenforeignmemory_handle* fmem = xch->fmem;
> > + xenforeignmemory_resource_handle *fres;
> > + void *addr = NULL;
> > + grant_entry_v1_t *gnttab;
> > +
> > + fres = xenforeignmemory_map_resource(fmem, guest_domid,
> > + XENMEM_resource_grant_table,
> > + 0, 0, 1,
> > + &addr, PROT_READ | PROT_WRITE, 0);
> > + if ( !fres )
> > + {
> > + if ( errno == EOPNOTSUPP )
> > + return is_hvm ?
> > + compat_gnttab_hvm_seed(xch, guest_domid,
> > + console_gmfn, xenstore_gmfn,
> > + console_domid, xenstore_domid) :
> > + compat_gnttab_seed(xch, guest_domid,
> > + console_gmfn, xenstore_gmfn,
> > + console_domid, xenstore_domid);
>
> Could be written as:
>
> return (is_hvm ? compat_gnttab_hvm_seed : compat_gnttab_seed)
> (xch, guest_domid, console_gmfn, xenstore_gmfn, console_domid,
> xenstore_domid);
Is that preferable?
>
> > +
> > + xc_dom_panic(xch, XC_INTERNAL_ERROR,
> > + "%s: failed to acquire grant table "
> > + "[errno=%d]\n",
> > + __FUNCTION__, errno);
> > + return -1;
> > }
> > +
> > + gnttab = addr;
> > +
> > + if ( guest_domid != console_domid && console_gmfn != -1)
> ^ extra space.
> > + {
> > + xc_dom_printf(xch, "%s: setting console pfn=0x%"PRI_xen_pfn,
> > + __FUNCTION__, console_gmfn);
> > +
> > + gnttab[GNTTAB_RESERVED_CONSOLE].flags = GTF_permit_access;
> > + gnttab[GNTTAB_RESERVED_CONSOLE].domid = console_domid;
> > + gnttab[GNTTAB_RESERVED_CONSOLE].frame = console_gmfn;
> > + }
> > +
> > + if ( guest_domid != xenstore_domid && xenstore_gmfn != -1)
> > + {
> > + xc_dom_printf(xch, "%s: setting xenstore pfn=0x%"PRI_xen_pfn,
> > + __FUNCTION__, xenstore_gmfn);
> > +
> > + gnttab[GNTTAB_RESERVED_XENSTORE].flags = GTF_permit_access;
> > + gnttab[GNTTAB_RESERVED_XENSTORE].domid = xenstore_domid;
> > + gnttab[GNTTAB_RESERVED_XENSTORE].frame = xenstore_gmfn;
> > + }
>
> The code above is already present in xc_dom_gnttab_seed (now renamed
> to compat_gnttab_seed, isn't there anyway that you could re-use it?
Hmm. Maybe. I'll see if I can re-work it to remove the duplication.
Thanks,
Paul
>
> Roger.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-08-24 16:12 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 14:50 [PATCH v2 REPOST 00/12] x86: guest resource mapping Paul Durrant
2017-08-22 14:50 ` [PATCH v2 REPOST 01/12] [x86|arm]: remove code duplication Paul Durrant
2017-08-24 14:12 ` Jan Beulich
2017-08-24 14:16 ` Paul Durrant
2017-08-22 14:50 ` [PATCH v2 REPOST 02/12] x86/mm: allow a privileged PV domain to map guest mfns Paul Durrant
2017-08-24 16:33 ` Wei Liu
2017-08-25 10:05 ` Paul Durrant
2017-08-28 14:38 ` Wei Liu
2017-08-29 8:37 ` Paul Durrant
2017-08-22 14:50 ` [PATCH v2 REPOST 03/12] x86/mm: add HYPERVISOR_memory_op to acquire guest resources Paul Durrant
2017-08-28 15:01 ` Wei Liu
2017-08-29 8:32 ` Paul Durrant
2017-08-29 8:59 ` Jan Beulich
2017-08-29 9:13 ` Paul Durrant
2017-08-29 9:27 ` Jan Beulich
2017-08-29 9:31 ` Paul Durrant
2017-08-29 9:38 ` Jan Beulich
2017-08-29 11:16 ` George Dunlap
2017-08-29 11:19 ` Paul Durrant
2017-08-22 14:50 ` [PATCH v2 REPOST 04/12] tools/libxenforeignmemory: add support for resource mapping Paul Durrant
2017-08-24 15:52 ` Roger Pau Monné
2017-08-24 15:58 ` Paul Durrant
2017-08-22 14:50 ` [PATCH v2 REPOST 05/12] tools/libxenctrl: use new xenforeignmemory API to seed grant table Paul Durrant
2017-08-24 16:02 ` Roger Pau Monné
2017-08-24 16:09 ` Paul Durrant [this message]
2017-08-28 15:04 ` Wei Liu
2017-08-22 14:51 ` [PATCH v2 REPOST 06/12] x86/hvm/ioreq: rename .*pfn and .*gmfn to .*gfn Paul Durrant
2017-08-24 16:06 ` Roger Pau Monné
2017-08-28 15:01 ` Wei Liu
2017-08-22 14:51 ` [PATCH v2 REPOST 07/12] x86/hvm/ioreq: use bool rather than bool_t Paul Durrant
2017-08-24 16:11 ` Roger Pau Monné
2017-08-22 14:51 ` [PATCH v2 REPOST 08/12] x86/hvm/ioreq: move is_default into struct hvm_ioreq_server Paul Durrant
2017-08-24 16:21 ` Roger Pau Monné
2017-08-24 16:31 ` Paul Durrant
2017-08-22 14:51 ` [PATCH v2 REPOST 09/12] x86/hvm/ioreq: simplify code and use consistent naming Paul Durrant
2017-08-24 17:02 ` Roger Pau Monné
2017-08-25 10:18 ` Paul Durrant
2017-08-22 14:51 ` [PATCH v2 REPOST 10/12] x86/hvm/ioreq: use gfn_t in struct hvm_ioreq_page Paul Durrant
2017-08-24 17:05 ` Roger Pau Monné
2017-08-22 14:51 ` [PATCH v2 REPOST 11/12] x86/hvm/ioreq: defer mapping gfns until they are actually requsted Paul Durrant
2017-08-24 17:21 ` Roger Pau Monné
2017-08-25 9:52 ` Paul Durrant
2017-08-28 15:08 ` Wei Liu
2017-08-29 8:51 ` Paul Durrant
2017-08-22 14:51 ` [PATCH v2 REPOST 12/12] x86/hvm/ioreq: add a new mappable resource type Paul Durrant
2017-08-25 9:32 ` Roger Pau Monné
2017-08-25 9:46 ` Paul Durrant
2017-08-25 9:53 ` Roger Pau Monne
2017-08-25 9:58 ` Paul Durrant
2017-08-29 11:36 ` George Dunlap
2017-08-29 13:40 ` George Dunlap
2017-08-29 14:10 ` Paul Durrant
2017-08-29 14:26 ` George Dunlap
2017-08-29 14:31 ` Paul Durrant
2017-08-29 14:38 ` George Dunlap
2017-08-29 14:49 ` Paul Durrant
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=ee3fb1061d7849d694901f734fdda045@AMSPEX02CL03.citrite.net \
--to=paul.durrant@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.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).