diff options
author | Stefano Stabellini <stefano.stabellini@eu.citrix.com> | 2010-12-10 09:54:44 -0500 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-01-11 14:32:00 -0500 |
commit | 289b777eac19c811b474593b4d2fd14e46340c23 (patch) | |
tree | 5474d85065eb539d51df994fbdfab5cd2cc0e400 | |
parent | 9b705f0e98c489b18ba22a6eab9d694b546c8552 (diff) |
xen: introduce gnttab_map_refs and gnttab_unmap_refs
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>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
-rw-r--r-- | drivers/xen/grant-table.c | 36 | ||||
-rw-r--r-- | 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 6c4531816496..1afd5690858c 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -447,6 +447,42 @@ unsigned int gnttab_max_grant_frames(void) | |||
447 | } | 447 | } |
448 | EXPORT_SYMBOL_GPL(gnttab_max_grant_frames); | 448 | EXPORT_SYMBOL_GPL(gnttab_max_grant_frames); |
449 | 449 | ||
450 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | ||
451 | struct page **pages, unsigned int count) | ||
452 | { | ||
453 | int i, ret; | ||
454 | pte_t *pte; | ||
455 | unsigned long mfn; | ||
456 | |||
457 | ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref, map_ops, count); | ||
458 | |||
459 | for (i = 0; i < count; i++) { | ||
460 | /* m2p override only supported for GNTMAP_contains_pte mappings */ | ||
461 | if (!(map_ops[i].flags & GNTMAP_contains_pte)) | ||
462 | continue; | ||
463 | pte = (pte_t *) (mfn_to_virt(PFN_DOWN(map_ops[i].host_addr)) + | ||
464 | (map_ops[i].host_addr & ~PAGE_MASK)); | ||
465 | mfn = pte_mfn(*pte); | ||
466 | m2p_add_override(mfn, pages[i]); | ||
467 | } | ||
468 | |||
469 | return ret; | ||
470 | } | ||
471 | EXPORT_SYMBOL_GPL(gnttab_map_refs); | ||
472 | |||
473 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | ||
474 | struct page **pages, unsigned int count) | ||
475 | { | ||
476 | int i, ret; | ||
477 | |||
478 | ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count); | ||
479 | for (i = 0; i < count; i++) | ||
480 | m2p_remove_override(pages[i]); | ||
481 | |||
482 | return ret; | ||
483 | } | ||
484 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs); | ||
485 | |||
450 | static int gnttab_map(unsigned int start_idx, unsigned int end_idx) | 486 | static int gnttab_map(unsigned int start_idx, unsigned int end_idx) |
451 | { | 487 | { |
452 | struct gnttab_setup_table setup; | 488 | struct gnttab_setup_table setup; |
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index 1821aa103d82..b1fab6b5b3ef 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h | |||
@@ -155,4 +155,9 @@ unsigned int gnttab_max_grant_frames(void); | |||
155 | 155 | ||
156 | #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) | 156 | #define gnttab_map_vaddr(map) ((void *)(map.host_virt_addr)) |
157 | 157 | ||
158 | int gnttab_map_refs(struct gnttab_map_grant_ref *map_ops, | ||
159 | struct page **pages, unsigned int count); | ||
160 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | ||
161 | struct page **pages, unsigned int count); | ||
162 | |||
158 | #endif /* __ASM_GNTTAB_H__ */ | 163 | #endif /* __ASM_GNTTAB_H__ */ |