diff options
Diffstat (limited to 'drivers/xen/grant-table.c')
-rw-r--r-- | drivers/xen/grant-table.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 6c4531816496..9ef54ebc1194 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
@@ -447,6 +447,52 @@ 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 | if (ret) | ||
459 | return ret; | ||
460 | |||
461 | for (i = 0; i < count; i++) { | ||
462 | /* m2p override only supported for GNTMAP_contains_pte mappings */ | ||
463 | if (!(map_ops[i].flags & GNTMAP_contains_pte)) | ||
464 | continue; | ||
465 | pte = (pte_t *) (mfn_to_virt(PFN_DOWN(map_ops[i].host_addr)) + | ||
466 | (map_ops[i].host_addr & ~PAGE_MASK)); | ||
467 | mfn = pte_mfn(*pte); | ||
468 | ret = m2p_add_override(mfn, pages[i]); | ||
469 | if (ret) | ||
470 | return ret; | ||
471 | } | ||
472 | |||
473 | return ret; | ||
474 | } | ||
475 | EXPORT_SYMBOL_GPL(gnttab_map_refs); | ||
476 | |||
477 | int gnttab_unmap_refs(struct gnttab_unmap_grant_ref *unmap_ops, | ||
478 | struct page **pages, unsigned int count) | ||
479 | { | ||
480 | int i, ret; | ||
481 | |||
482 | ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, unmap_ops, count); | ||
483 | if (ret) | ||
484 | return ret; | ||
485 | |||
486 | for (i = 0; i < count; i++) { | ||
487 | ret = m2p_remove_override(pages[i]); | ||
488 | if (ret) | ||
489 | return ret; | ||
490 | } | ||
491 | |||
492 | return ret; | ||
493 | } | ||
494 | EXPORT_SYMBOL_GPL(gnttab_unmap_refs); | ||
495 | |||
450 | static int gnttab_map(unsigned int start_idx, unsigned int end_idx) | 496 | static int gnttab_map(unsigned int start_idx, unsigned int end_idx) |
451 | { | 497 | { |
452 | struct gnttab_setup_table setup; | 498 | struct gnttab_setup_table setup; |