And require it be used instead of direct munmap.
This will allow e.g. Valgrind hooks to help track incorrect use of
foreign mappings.
Switch all uses of xenforeignmemory_map to use
xenforeignmemory_unmap, not that foreign mappings via the libxc compat
xc_map_foreign_* interface will not take advantage of this and will
need converting.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
return addr;
}
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num << PAGE_SHIFT);
+}
+
/*
* Local variables:
* mode: C
/*
* Maps a range within one domain to a local address range. Mappings
- * should be unmapped with munmap and should follow the same rules as mmap
- * regarding page alignment.
+ * must be unmapped with xenforeignmemory_unmap and should follow the
+ * same rules as mmap regarding page alignment.
*
* prot is as for mmap(2).
*
void *xenforeignmemory_map(xenforeignmemory_handle *fmem, uint32_t dom,
int prot, const xen_pfn_t *arr, int *err,
unsigned int num);
+/*
+ * Unmap a mapping previous created with xenforeignmemory_map().
+ *
+ * Returns 0 on success on failure sets errno and returns -1.
+ */
+int xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num);
#endif
xenforeignmemory_open;
xenforeignmemory_close;
xenforeignmemory_map;
+ xenforeignmemory_unmap;
local: *; /* Do not expose anything by default */
};
return addr;
}
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, (unsigned long)num << PAGE_SHIFT);
+}
+
/*
* Local variables:
* mode: C
return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot);
}
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num << PAGE_SHIFT);
+}
+
/*
* Local variables:
* mode: C
}
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num*XC_PAGE_SIZE);
+}
+
/*
* Local variables:
* mode: C
}
return addr;
}
+
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num*XC_PAGE_SIZE);
+}
err:
if ( mapping )
- munmap(mapping, nr_pages * PAGE_SIZE);
+ xenforeignmemory_unmap(xch->fmem, mapping, nr_pages);
free(map_errs);
free(mfns);
err:
free(rec_pfns);
if ( guest_mapping )
- munmap(guest_mapping, nr_pages_mapped * PAGE_SIZE);
+ xenforeignmemory_unmap(xch->fmem, guest_mapping, nr_pages_mapped);
for ( i = 0; local_pages && i < nr_pfns; ++i )
free(local_pages[i]);
free(iov);
}
if ( ring_page )
- munmap(ring_page, XC_PAGE_SIZE);
+ xenforeignmemory_unmap(xch->fmem, ring_page, 1);
ring_page = NULL;
errno = saved_errno;