From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@citrix.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCH 11/14] arm: implement remap interfaces needed for privcmd mappings.
Date: Thu, 4 Oct 2012 11:24:59 -0400 [thread overview]
Message-ID: <20121004152459.GC11426@phenom.dumpdata.com> (raw)
In-Reply-To: <1349363515-26190-11-git-send-email-ian.campbell@citrix.com>
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?
> +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" ?
> + 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.
> + 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?
> + 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?
> +
> + 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'?
> + 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:24 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 [this message]
2012-10-04 15:48 ` Ian Campbell
2012-10-04 15:54 ` Konrad Rzeszutek Wilk
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=20121004152459.GC11426@phenom.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@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).