@@ -118,6 +118,12 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
return addr;
}
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num << PAGE_SHIFT);
+}
+
/*
* Local variables:
* mode: C
@@ -44,8 +44,8 @@ int xenforeignmemory_close(xenforeignmemory_handle *fmem);
/*
* 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).
*
@@ -57,6 +57,13 @@ int xenforeignmemory_close(xenforeignmemory_handle *fmem);
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
@@ -3,5 +3,6 @@ VERS_1.0 {
xenforeignmemory_open;
xenforeignmemory_close;
xenforeignmemory_map;
+ xenforeignmemory_unmap;
local: *; /* Do not expose anything by default */
};
@@ -282,6 +282,12 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
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
@@ -51,6 +51,12 @@ void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
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
@@ -94,6 +94,12 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom,
}
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num*XC_PAGE_SIZE);
+}
+
/*
* Local variables:
* mode: C
@@ -91,3 +91,9 @@ void *osdep_map_foreign_batch(xenforeignmem_handle *fmem, uint32_t dom,
}
return addr;
}
+
+int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
+ void *addr, unsigned int num)
+{
+ return munmap(addr, num*XC_PAGE_SIZE);
+}
@@ -378,7 +378,7 @@ static int process_page_data(struct xc_sr_context *ctx, unsigned count,
err:
if ( mapping )
- munmap(mapping, nr_pages * PAGE_SIZE);
+ xenforeignmemory_unmap(xch->fmem, mapping, nr_pages);
free(map_errs);
free(mfns);
@@ -263,7 +263,7 @@ static int write_batch(struct xc_sr_context *ctx)
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);
@@ -148,7 +148,7 @@ void *xc_vm_event_enable(xc_interface *xch, domid_t domain_id, int param,
}
if ( ring_page )
- munmap(ring_page, XC_PAGE_SIZE);
+ xenforeignmemory_unmap(xch->fmem, ring_page, 1);
ring_page = NULL;
errno = saved_errno;