From: Ian Campbell Subject: Re: [PATCH v4 1/6] xen: improve changes to xen_add_to_physmap Date: Wed, 19 Sep 2012 14:50:15 +0100 Message-ID: <1348062615.14977.127.camel@zakaz.uk.xensource.com> References: <1345633688-31684-1-git-send-email-stefano.stabellini@eu.citrix.com> <1347627587.24226.192.camel@zakaz.uk.xensource.com> <20120914160727.1ff41de2@mantra.us.oracle.com> <1348059789.14977.119.camel@zakaz.uk.xensource.com> <1348060180.14977.123.camel@zakaz.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini Cc: "xen-devel@lists.xensource.com" , "Tim (Xen.org)" List-Id: xen-devel@lists.xenproject.org On Wed, 2012-09-19 at 14:20 +0100, Stefano Stabellini wrote: > On Wed, 19 Sep 2012, Ian Campbell wrote: > > On Wed, 2012-09-19 at 14:03 +0100, Ian Campbell wrote: > > > > > > It the final version. I think it should go in, unless we want to drop it > > > > entirely in favor of xen_add_to_physmap_range. > > > > > > Here is what I came up with on the ARM side. I'd image the X86 version > > > would not be that different. > > > > Here the (obvious) Linux side, for reference. No actual use of batching > > just yet. It's based on top of a somewhat bastardized version of > > Mukesh's PVH patches for privcmd. > > > > we also need the xen_remap_domain_mfn_range arm implementation I have that, it calls this pvh_add_to_xen_p2m. I just didn't include it here since I was just illustrating the change of the API. I have a set of patches to reimplement the hacky foreign mapping stuff on top of Mukesh's PVH privmd stuff, I'm just waiting for him to repost so I can rebase and post. > > > > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c > > index 43277f8..f01120a 100644 > > --- a/arch/arm/xen/enlighten.c > > +++ b/arch/arm/xen/enlighten.c > > @@ -88,13 +88,20 @@ static int pvh_add_to_xen_p2m(unsigned long lpfn, unsigned long fgmfn, > > unsigned int domid) > > { > > int rc; > > - struct xen_add_to_physmap pmb = {.foreign_domid = domid}; > > - > > - pmb.gpfn = lpfn; > > - pmb.idx = fgmfn; > > - pmb.space = XENMAPSPACE_gmfn_foreign; > > - > > - rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &pmb); > > + struct xen_add_to_physmap_range xatp = { > > + .domid = DOMID_SELF, > > + .foreign_domid = domid, > > + .size = 1, > > + .space = XENMAPSPACE_gmfn_foreign, > > + }; > > + unsigned long idx = fgmfn; > > + xen_pfn_t gpfn = lpfn; > > + > > + set_xen_guest_handle(xatp.idxs, &idx); > > + set_xen_guest_handle(xatp.gpfns, &gpfn); > > + domid, fgmfn, lpfn); > > + > > + rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp); > > if (rc) { > > pr_warn("Failed to map pfn to mfn rc:%d pfn:%lx mfn:%lx\n", > > rc, lpfn, fgmfn); > > diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h > > index 8728330..64cabbb 100644 > > --- a/include/xen/interface/memory.h > > +++ b/include/xen/interface/memory.h > > @@ -183,6 +183,24 @@ struct xen_add_to_physmap { > > }; > > DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap); > > > > +#define XENMEM_add_to_physmap_range 23 > > +struct xen_add_to_physmap_range { > > + /* Which domain to change the mapping for. */ > > + domid_t domid; > > + uint16_t space; /* => enum phys_map_space */ > > + > > + /* Number of pages to go through */ > > + uint16_t size; > > + domid_t foreign_domid; /* IFF gmfn_foreign */ > > + > > + /* Indexes into space being mapped. */ > > + GUEST_HANDLE(ulong) idxs; > > + > > + /* GPFN in domdwhere the source mapping page should appear. */ > > + GUEST_HANDLE(xen_pfn_t) gpfns; > > +}; > > +DEFINE_GUEST_HANDLE_STRUCT(xen_add_to_physmap_range); > > + > > /* > > * Translates a list of domain-specific GPFNs into MFNs. Returns a -ve error > > * code on failure. This call only works for auto-translated guests. > > > > > >