WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 09/11] xen: introduce gnttab_map_refs and gnttab_

To: stefano.stabellini@xxxxxxxxxxxxx
Subject: [Xen-devel] Re: [PATCH 09/11] xen: introduce gnttab_map_refs and gnttab_unmap_refs
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Wed, 5 Jan 2011 15:23:55 -0500
Cc: Jeremy Fitzhardinge <Jeremy.Fitzhardinge@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
Delivery-date: Wed, 05 Jan 2011 12:26:34 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1292420446-3348-9-git-send-email-stefano.stabellini@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <alpine.DEB.2.00.1012151259510.2390@kaball-desktop> <1292420446-3348-9-git-send-email-stefano.stabellini@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
On Wed, Dec 15, 2010 at 01:40:44PM +0000, stefano.stabellini@xxxxxxxxxxxxx 
wrote:
> From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> 
> 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@xxxxxxxxxxxxx>
> Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>