From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: Re: [PATCH 11/14] arm: implement remap interfaces needed for privcmd mappings.
Date: Thu, 4 Oct 2012 11:54:00 -0400 [thread overview]
Message-ID: <20121004155400.GA12128@phenom.dumpdata.com> (raw)
In-Reply-To: <1349365718.866.63.camel@zakaz.uk.xensource.com>
On Thu, Oct 04, 2012 at 04:48:38PM +0100, Ian Campbell wrote:
> On Thu, 2012-10-04 at 16:24 +0100, Konrad Rzeszutek Wilk wrote:
> > On Thu, Oct 04, 2012 at 04:11:52PM +0100, Ian Campbell wrote:
> > > Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> > > ---
> > > arch/arm/xen/enlighten.c | 94 +++++++++++++++++++++++++++++++++++++++++++++-
> > > 1 files changed, 92 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> > > index ba5cc13..9956af5 100644
> > > --- a/arch/arm/xen/enlighten.c
> > > +++ b/arch/arm/xen/enlighten.c
> > > @@ -9,6 +9,7 @@
> > > #include <xen/platform_pci.h>
> > > #include <xen/xenbus.h>
> > > #include <xen/page.h>
> > > +#include <xen/xen-ops.h>
> > > #include <asm/xen/hypervisor.h>
> > > #include <asm/xen/hypercall.h>
> > > #include <linux/interrupt.h>
> > > @@ -18,6 +19,8 @@
> > > #include <linux/of_irq.h>
> > > #include <linux/of_address.h>
> > >
> > > +#include <linux/mm.h>
> > > +
> > > struct start_info _xen_start_info;
> > > struct start_info *xen_start_info = &_xen_start_info;
> > > EXPORT_SYMBOL_GPL(xen_start_info);
> > > @@ -43,15 +46,102 @@ EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
> > >
> > > static __read_mostly int xen_events_irq = -1;
> > >
> > > +/* map fgmfn of domid to lpfn in the current domain */
> >
> > <laughs> Say that really fast a couple of times :-)
> >
> > Any way we can explain it a bit more of what each acronym means?
>
> The names come from the x86 PVH version, which has the comment:
> /* Map foreign gmfn, fgmfn, to local pfn, lpfn. This for the user space
> * creating new guest on PVH dom0 and needs to map domU pages.
> */
> Is that preferable? (modulo removing the PVH bit)
<nods>
>
> >
> > > +static int map_foreign_page(unsigned long lpfn, unsigned long fgmfn,
> > > + unsigned int domid)
> > > +{
> > > + int rc;
> > > + struct xen_add_to_physmap xatp = {
> > > + .domid = DOMID_SELF,
> > > + .u.foreign_domid = domid,
> > > + .space = XENMAPSPACE_gmfn_foreign,
> > > + .idx = fgmfn,
> > > + .gpfn = lpfn,
> > > + };
> > > +
> > > + rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp);
> > > + if (rc) {
> > > + pr_warn("Failed to map pfn to mfn rc:%d pfn:%lx mfn:%lx\n",
> >
> > How about 'Failed to map pfn (0x%lx) to mfn (0x%lx), rc: %d\n" ?
>
> Sure, need to slip foreign domid in there somewhere now I look at it.
>
> x86 PVH has basically the same print BTW.
OK, lets address that as well in the next review of the patchset.
>
> >
> > > + rc, lpfn, fgmfn);
> > > + return 1;
> > > + }
> > > + return 0;
> > > +}
> > > +
> > > +struct remap_data {
> > > + unsigned long fgmfn; /* foreign domain's gmfn */
> >
> > Shouldn't this be called now 'xen_pfn_t' or something.
>
> xen_pfn_t is needed at the hypervisor interface layer, I'm not so sure
> about kernel internal use. I guess it can't hurt?
My thoughts.. as somebody might be wondering why here is unsigned long
but other places it is not.
>
> >
> > > + pgprot_t prot;
> > > + domid_t domid;
> > > + struct vm_area_struct *vma;
> > > + struct xen_remap_mfn_info *info;
> > > +};
> > > +
> > > +static int remap_pte_fn(pte_t *ptep, pgtable_t token, unsigned long addr,
> > > + void *data)
> > > +{
> > > + struct remap_data *info = data;
> > > + struct xen_remap_mfn_info *savp = info->info;
> > > + struct page *page = savp->pi_paga[savp->pi_next_todo++];
> > > + unsigned long pfn = page_to_pfn(page);
> > > + pte_t pte = pfn_pte(pfn, info->prot);
> > > +
> > > + if (map_foreign_page(pfn, info->fgmfn, info->domid))
> > > + return -EFAULT;
> > > + set_pte_at(info->vma->vm_mm, addr, ptep, pte);
> > > +
> > > + return 0;
> > > +}
> > > +
> > > int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
> > > unsigned long addr,
> > > unsigned long mfn, int nr,
> > > - pgprot_t prot, unsigned domid)
> > > + pgprot_t prot, unsigned domid,
> > > + struct xen_remap_mfn_info *info)
> > > {
> > > - return -ENOSYS;
> > > + int err;
> > > + struct remap_data data;
> > > +
> > > + /* TBD: Batching, current sole caller only does page at a time */
> > > + if (nr > 1)
> >
> > Lets also wrap it with WARN_ON?
>
> ACK, needs doing on x86 PVH too then.
>
> >
> > > + return -EINVAL;
> > > +
> > > + data.fgmfn = mfn;
> > > + data.prot = prot;
> > > + data.domid = domid;
> > > + data.vma = vma;
> > > + data.info = info;
> > > + err = apply_to_page_range(vma->vm_mm, addr, nr << PAGE_SHIFT,
> > > + remap_pte_fn, &data);
> > > + return err;
> > > }
> > > EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range);
> > >
> > > +/* Returns: Number of pages unmapped */
> > > +int xen_unmap_domain_mfn_range(struct vm_area_struct *vma,
> > > + struct xen_remap_mfn_info *info)
> > > +{
> > > + int count = 0;
> > > +
> > > + while (info->pi_next_todo--) {
> > > + struct xen_remove_from_physmap xrp;
> > > + unsigned long rc, pfn;
> > > +
> > > + pfn = page_to_pfn(info->pi_paga[info->pi_next_todo]);
> >
> > Won't this miss the first pi_next_todo? You did the 'pi_next_todo--' so
> > will the compiler decrement it here in this operation or will it do
> > when it gets to the 'do' logic of the loop?
>
> It's a post decrement so if pi_next_todo == 1 then the expression in the
> while will see 1 (true) but inside the loop we see zero. So we end up
> processing elements N-1..0 of the array which is correct.
OK. That is what I wanted to make sure about.
>
> This is the same as on x86 PVH, so if I'm wrong then that is too.
>
> I mentioned in the PVH thread this morning that I think this interface
> should drop pi_next_todo and have a simple for loop based on the number
> of pages between vm_start...vm_end here.
Yeah, I think we need to do that. I understand Mukesh's desire to have
an easy searchable name for variables, but that 'pi' just makes me
think of bathroom, then of 3.1415, and then I have to actually recall
really hard why it is called 'pi' .. and I still can't remember why.
>
> >
> > > +
> > > + xrp.domid = DOMID_SELF;
> > > + xrp.gpfn = pfn;
> > > + rc = HYPERVISOR_memory_op(XENMEM_remove_from_physmap, &xrp);
> >
> > 'rc' is 'unsigned long'. Is that right? You don't want it to be 'int'?
>
> Hypercalls return unsigned long these days, I think it was considered a
> mistake that some didn't. See <25744:47080c965937> in the hypervisor
> tree.
>
> Oh, wait, we are both wrong -- it's a long. I'll fix that...
>
> >
> > > + if (rc) {
> > > + pr_warn("Failed to unmap pfn:%lx rc:%ld\n",
> > > + pfn, rc);
> > > + return count;
> > > + }
> > > + count++;
> > > + }
> > > + return count;
> > > +}
> > > +EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range);
> > > +
> > > /*
> > > * see Documentation/devicetree/bindings/arm/xen.txt for the
> > > * documentation of the Xen Device Tree format.
> > > --
> > > 1.7.2.5
>
next prev parent reply other threads:[~2012-10-04 15:54 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 15:11 [RFC 00/14] arm: implement ballooning and privcmd foreign mappings based on x86 PVH Ian Campbell
2012-10-04 15:11 ` [PATCH 01/14] Build fixes which I beleive others have already fixed properly elsewhere Ian Campbell
2012-10-04 15:15 ` Konrad Rzeszutek Wilk
2012-10-04 15:11 ` [PATCH 02/14] xenbus: include features header Ian Campbell
2012-10-04 15:11 ` [PATCH 03/14] xen events: xen_callback_vector is x86 specific Ian Campbell
2012-10-05 11:43 ` Stefano Stabellini
2012-10-05 11:47 ` Ian Campbell
2012-10-05 18:40 ` Mukesh Rathor
2012-10-04 15:11 ` [PATCH 04/14] xen: balloon: don't include e820.h Ian Campbell
2012-10-04 15:11 ` [PATCH 05/14] xen: balloon: use correct type for frame_list Ian Campbell
2012-10-05 11:48 ` Stefano Stabellini
2012-10-05 12:32 ` Ian Campbell
2012-10-05 14:02 ` Stefano Stabellini
2012-10-05 14:33 ` Ian Campbell
2012-10-05 14:54 ` Stefano Stabellini
2012-10-05 16:11 ` Ian Campbell
2012-10-05 16:17 ` Ian Campbell
2012-10-09 12:31 ` Stefano Stabellini
2012-10-04 15:11 ` [PATCH 06/14] arm: make p2m operations NOPs Ian Campbell
2012-10-05 11:53 ` Stefano Stabellini
2012-10-04 15:11 ` [PATCH 07/14] xen: balloon: do not update stage 1 pagetable for autotranslated guests Ian Campbell
2012-10-05 12:05 ` Stefano Stabellini
2012-10-05 19:10 ` Mukesh Rathor
2012-10-04 15:11 ` [PATCH 08/14] xen: balloon: allow PVMMU interfaces to be compiled out Ian Campbell
2012-10-05 13:19 ` Stefano Stabellini
2012-10-05 13:33 ` Ian Campbell
2012-10-05 14:04 ` Stefano Stabellini
2012-10-05 14:05 ` Stefano Stabellini
2012-10-05 14:35 ` Ian Campbell
2012-10-04 15:11 ` [PATCH 09/14] xen: arm: enable balloon driver Ian Campbell
2012-10-05 13:18 ` Stefano Stabellini
2012-10-04 15:11 ` [PATCH 10/14] privcmd: refer to autotranslate not PVH in arch interfaces / comments Ian Campbell
2012-10-05 13:37 ` Stefano Stabellini
2012-10-05 13:39 ` Ian Campbell
2012-10-04 15:11 ` [PATCH 11/14] arm: implement remap interfaces needed for privcmd mappings Ian Campbell
2012-10-04 15:24 ` Konrad Rzeszutek Wilk
2012-10-04 15:48 ` Ian Campbell
2012-10-04 15:54 ` Konrad Rzeszutek Wilk [this message]
2012-10-05 13:36 ` Stefano Stabellini
2012-10-05 13:42 ` Ian Campbell
2012-10-09 0:59 ` Mukesh Rathor
2012-10-04 15:11 ` [PATCH 12/14] arm: xen: explain the EXPERIMENTAL dependency in the Kconfig help Ian Campbell
2012-10-05 13:21 ` Stefano Stabellini
2012-10-05 13:29 ` Ian Campbell
2012-10-04 15:11 ` [PATCH 13/14] xen: use xen_pft_t in struct xen_remove_from_physmap Ian Campbell
2012-10-05 13:22 ` Stefano Stabellini
2012-10-04 15:11 ` [PATCH 14/14] arm: implement foreign mapping using XENMEM_add_to_physmap_range Ian Campbell
2012-10-05 13:36 ` Stefano Stabellini
2012-10-05 13:51 ` Ian Campbell
2012-10-04 15:27 ` [RFC 00/14] arm: implement ballooning and privcmd foreign mappings based on x86 PVH Konrad Rzeszutek Wilk
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=20121004155400.GA12128@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Ian.Campbell@citrix.com \
--cc=Stefano.Stabellini@eu.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).