From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: stefano.stabellini@eu.citrix.com
Cc: linux-kernel@vger.kernel.org, xen-devel@lists.xensource.com,
Jeremy Fitzhardinge <Jeremy.Fitzhardinge@citrix.com>
Subject: Re: [PATCH 09/11] xen: introduce gnttab_map_refs and gnttab_unmap_refs
Date: Wed, 5 Jan 2011 15:23:55 -0500 [thread overview]
Message-ID: <20110105202355.GB29993@dumpdata.com> (raw)
In-Reply-To: <1292420446-3348-9-git-send-email-stefano.stabellini@eu.citrix.com>
On Wed, Dec 15, 2010 at 01:40:44PM +0000, stefano.stabellini@eu.citrix.com wrote:
> From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>
> gnttab_map_refs maps some grant refs and uses the new m2p override to
> set a proper m2p mapping for the granted pages.
>
> gnttab_unmap_refs unmaps the granted refs and removes th mappings from
> the m2p override.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
> ---
> drivers/xen/grant-table.c | 36 ++++++++++++++++++++++++++++++++++++
> include/xen/grant_table.h | 5 +++++
> 2 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c
> index 6c45318..a5cf820 100644
> --- a/drivers/xen/grant-table.c
> +++ b/drivers/xen/grant-table.c
> @@ -447,6 +447,42 @@ unsigned int gnttab_max_grant_frames(void)
> }
> EXPORT_SYMBOL_GPL(gnttab_max_grant_frames);
>
> +int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
> + struct page **pages, unsigned int count)
> +{
> + int i, ret;
> + pte_t val;
> + pte_t *pte;
> + unsigned long pfn, mfn;
> +
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map_ops, count);
> +
> + for (i = 0; i < count; i++) {
> + pfn = mfn_to_pfn(map_ops[i].host_addr >> PAGE_SHIFT);
Shouldn't you be checking the flag to see if this a bus address? You could
also use the PFN_DOWN macro here..
> + pte = (pte_t *) __va((pfn << PAGE_SHIFT) +
> + (map_ops[i].host_addr & ~PAGE_MASK));
PFN_PHYS(pfn)? Or better You could use the mfn_to_virt macro here:
pte = (pte_t *) mfn_to_virt(PFN_DOWN(map_ops[i].ost_addr));
pte += (map_ops[i].host_addr & _PAGE_MASK);
and squash the __va((pfn ..)
> + val = *pte;
> + mfn = (native_pte_val(val) & PTE_PFN_MASK) >> PAGE_SHIFT;
mfn = pte_mfn(pte) ?
> + m2p_add_override(mfn, pages[i]);
> + }
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(gnttab_map_refs);
> +
> +int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
> + struct page **pages, unsigned int count)
> +{
> + int i, ret;
> +
> + ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count);
> + for (i = 0; i < count; i++)
> + m2p_remove_override(pages[i]);
> +
> + return ret;
> +}
> +EXPORT_SYMBOL_GPL(gnttab_unmap_refs);
> +
> static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
> {
> struct gnttab_setup_table setup;
> diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
> index 1821aa1..b1fab6b 100644
> --- a/include/xen/grant_table.h
> +++ b/include/xen/grant_table.h
> @@ -155,4 +155,9 @@ unsigned int gnttab_max_grant_frames(void);
>
> #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr))
>
> +int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops,
> + struct page **pages, unsigned int count);
> +int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops,
> + struct page **pages, unsigned int count);
> +
> #endif /* __ASM_GNTTAB_H__ */
> --
> 1.5.6.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2011-01-05 20:23 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-15 13:39 [PATCH 00/11] xen: allow usermode to map granted pages Stefano Stabellini
2010-12-15 13:40 ` [PATCH 01/11] xen: define gnttab_set_map_op/unmap_op stefano.stabellini
2011-01-05 20:25 ` Konrad Rzeszutek Wilk
2011-01-06 9:16 ` Ian Campbell
2010-12-15 13:40 ` [PATCH 02/11] xen/gntdev: allow usermode to map granted pages stefano.stabellini
2011-01-05 20:25 ` [Xen-devel] " Konrad Rzeszutek Wilk
2011-01-06 9:21 ` [SPAM] " Ian Campbell
2011-01-10 10:33 ` [Xen-devel] " Stefano Stabellini
2010-12-15 13:40 ` [PATCH 03/11] xen/gntdev: add VM_PFNMAP to vma stefano.stabellini
2010-12-15 13:40 ` [PATCH 04/11] xen: move p2m handling to separate file stefano.stabellini
2011-01-05 20:24 ` Konrad Rzeszutek Wilk
2010-12-15 13:40 ` [PATCH 05/11] xen: add m2p override mechanism stefano.stabellini
2010-12-15 13:40 ` [PATCH 06/11] xen: gntdev: move use of GNTMAP_contains_pte next to the map_op stefano.stabellini
2011-01-05 20:24 ` Konrad Rzeszutek Wilk
2011-01-10 10:32 ` Stefano Stabellini
2011-01-10 21:16 ` Konrad Rzeszutek Wilk
2010-12-15 13:40 ` [PATCH 07/11] xen/gntdev: stop using "token" argument stefano.stabellini
2010-12-15 13:40 ` [PATCH 08/11] xen p2m: transparently change the p2m mappings in the m2p override stefano.stabellini
2010-12-15 23:36 ` [Xen-devel] " Jeremy Fitzhardinge
2010-12-16 15:25 ` Stefano Stabellini
2011-01-05 20:24 ` Konrad Rzeszutek Wilk
2010-12-15 13:40 ` [PATCH 09/11] xen: introduce gnttab_map_refs and gnttab_unmap_refs stefano.stabellini
2011-01-05 20:23 ` Konrad Rzeszutek Wilk [this message]
2011-01-10 10:32 ` Stefano Stabellini
2010-12-15 13:40 ` [PATCH 10/11] xen gntdev: use " stefano.stabellini
2011-01-05 20:23 ` Konrad Rzeszutek Wilk
2011-01-10 10:33 ` Stefano Stabellini
2010-12-15 13:40 ` [PATCH 11/11] xen p2m: clear the old pte when adding a page to m2p_override stefano.stabellini
2011-01-05 20:23 ` Konrad Rzeszutek Wilk
2011-01-10 10:32 ` Stefano Stabellini
2010-12-15 13:43 ` [PATCH 00/11] xen: allow usermode to map granted pages Stefano Stabellini
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=20110105202355.GB29993@dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Jeremy.Fitzhardinge@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).