[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 4/7] minios: add gnttab_find_grant_of_page
Needed to implement minios_gntshr_munmap without introducing additional mapping (frame->gref). Signed-off-by: Marek Marczykowski <marmarek@xxxxxxxxxxxxxxxxxxxxxx> --- extras/mini-os/gnttab.c | 23 +++++++++++++++++++++++ extras/mini-os/include/gnttab.h | 1 + 2 files changed, 24 insertions(+) diff --git a/extras/mini-os/gnttab.c b/extras/mini-os/gnttab.c index 2f1b3d7..ec32e69 100644 --- a/extras/mini-os/gnttab.c +++ b/extras/mini-os/gnttab.c @@ -157,6 +157,29 @@ gnttab_alloc_and_grant(void **map) return gref; } +/* This function is used by gnttab_munmap call. It is rather rare to call it - + * mostly at sthudown, so save memory at price of efficiency */ +grant_ref_t +gnttab_find_grant_of_page(void *map) +{ + unsigned long flags; + int i, mfn; + grant_ref_t ref = 0; + + mfn = virt_to_mfn(map); + local_irq_save(flags); + for (i = NR_RESERVED_ENTRIES; i < NR_GRANT_ENTRIES; i++) { + if (!gnttab_table[i].flags) + continue; + if (gnttab_table[i].frame == mfn) { + ref = i; + break; + } + } + local_irq_restore(flags); + return ref; +} + static const char * const gnttabop_error_msgs[] = GNTTABOP_error_msgs; const char * diff --git a/extras/mini-os/include/gnttab.h b/extras/mini-os/include/gnttab.h index acd6c39..fb69daf 100644 --- a/extras/mini-os/include/gnttab.h +++ b/extras/mini-os/include/gnttab.h @@ -10,6 +10,7 @@ grant_ref_t gnttab_grant_access(domid_t domid, unsigned long frame, grant_ref_t gnttab_grant_transfer(domid_t domid, unsigned long pfn); unsigned long gnttab_end_transfer(grant_ref_t gref); int gnttab_end_access(grant_ref_t ref); +grant_ref_t gnttab_find_grant_of_page(void *map); const char *gnttabop_error(int16_t status); void fini_gnttab(void); -- 1.8.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |