# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1263370376 0
# Node ID 0b138a01929237f671a3bb7021755d304e294699
# Parent 0e3910f1de6483cd22d066d491db646a6bc41fa4
libxc: use new (replacement) mmap-batch ioctl
Replace all calls to xc_map_foreign_batch() where the caller doesn't
look at the passed in array to check for errors by calls to
xc_map_foreign_pages(). Replace all remaining calls by such to the
newly introduced xc_map_foreign_bulk().
As a sideband modification (needed while writing the patch to ensure
they're unused) eliminate unused parameters to
uncanonicalize_pagetable() and xc_map_foreign_batch_single(). Also
unmap live_p2m_frame_list earlier in map_and_save_p2m_table(),
reducing the peak amount of virtual address space required.
All supported OSes other than Linux continue to use the old ioctl for
the time being.
Also change libxc's MAJOR to 4.0 to reflect the API change.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxxxx>
---
tools/include/xen-sys/Linux/privcmd.h | 10 ++
tools/libxc/Makefile | 2
tools/libxc/xc_domain_restore.c | 16 ++--
tools/libxc/xc_domain_save.c | 49 +++++++-----
tools/libxc/xc_linux.c | 133 ++++++++++++++++++++++++++++++++--
tools/libxc/xc_misc.c | 73 ++++++++++++++----
tools/libxc/xc_resume.c | 4 -
tools/libxc/xenctrl.h | 10 ++
tools/xenpaging/xenpaging.c | 13 ---
9 files changed, 251 insertions(+), 59 deletions(-)
diff -r 0e3910f1de64 -r 0b138a019292 tools/include/xen-sys/Linux/privcmd.h
--- a/tools/include/xen-sys/Linux/privcmd.h Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/include/xen-sys/Linux/privcmd.h Wed Jan 13 08:12:56 2010 +0000
@@ -64,6 +64,14 @@ typedef struct privcmd_mmapbatch {
xen_pfn_t __user *arr; /* array of mfns - top nibble set on err */
} privcmd_mmapbatch_t;
+typedef struct privcmd_mmapbatch_v2 {
+ unsigned int num; /* number of pages to populate */
+ domid_t dom; /* target domain */
+ __u64 addr; /* virtual address */
+ const xen_pfn_t __user *arr; /* array of mfns */
+ int __user *err; /* array of error codes */
+} privcmd_mmapbatch_v2_t;
+
/*
* @cmd: IOCTL_PRIVCMD_HYPERCALL
* @arg: &privcmd_hypercall_t
@@ -75,5 +83,7 @@ typedef struct privcmd_mmapbatch {
_IOC(_IOC_NONE, 'P', 2, sizeof(privcmd_mmap_t))
#define IOCTL_PRIVCMD_MMAPBATCH \
_IOC(_IOC_NONE, 'P', 3, sizeof(privcmd_mmapbatch_t))
+#define IOCTL_PRIVCMD_MMAPBATCH_V2 \
+ _IOC(_IOC_NONE, 'P', 4, sizeof(privcmd_mmapbatch_v2_t))
#endif /* __LINUX_PUBLIC_PRIVCMD_H__ */
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/Makefile
--- a/tools/libxc/Makefile Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/Makefile Wed Jan 13 08:12:56 2010 +0000
@@ -1,7 +1,7 @@ XEN_ROOT = ../..
XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Rules.mk
-MAJOR = 3.4
+MAJOR = 4.0
MINOR = 0
CTRL_SRCS-y :=
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/xc_domain_restore.c Wed Jan 13 08:12:56 2010 +0000
@@ -118,7 +118,7 @@ static int break_super_page(int xc_handl
page_array[i] = start_pfn + i;
}
- ram_base = xc_map_foreign_batch(xc_handle, dom, PROT_READ,
+ ram_base = xc_map_foreign_pages(xc_handle, dom, PROT_READ,
page_array, tot_pfns);
if ( ram_base == NULL )
@@ -166,7 +166,7 @@ static int break_super_page(int xc_handl
page_array[i] = start_pfn + i;
}
- ram_base = xc_map_foreign_batch(xc_handle, dom, PROT_WRITE,
+ ram_base = xc_map_foreign_pages(xc_handle, dom, PROT_WRITE,
page_array, tot_pfns);
if ( ram_base == NULL )
{
@@ -494,7 +494,7 @@ static ssize_t read_exact_timed(int fd,
** the (now known) appropriate mfn values.
*/
static int uncanonicalize_pagetable(int xc_handle, uint32_t dom, struct
restore_ctx *ctx,
- unsigned long type, void *page, int
superpages)
+ void *page, int superpages)
{
int i, pte_last;
unsigned long pfn;
@@ -1186,7 +1186,7 @@ static int apply_batch(int xc_handle, ui
}
/* Map relevant mfns */
- region_base = xc_map_foreign_batch(
+ region_base = xc_map_foreign_pages(
xc_handle, dom, PROT_WRITE, region_mfn, j);
if ( region_base == NULL )
@@ -1240,7 +1240,7 @@ static int apply_batch(int xc_handle, ui
(pagetype != XEN_DOMCTL_PFINFO_L1TAB)) {
if (!uncanonicalize_pagetable(xc_handle, dom, ctx,
- pagetype, page, superpages)) {
+ page, superpages)) {
/*
** Failing to uncanonicalize a page table can be ok
** under live migration since the pages type may have
@@ -1655,7 +1655,7 @@ int xc_domain_restore(int xc_handle, int
if ( (i == (dinfo->p2m_size-1)) || (j == MAX_BATCH_SIZE) )
{
- region_base = xc_map_foreign_batch(
+ region_base = xc_map_foreign_pages(
xc_handle, dom, PROT_READ | PROT_WRITE, region_mfn, j);
if ( region_base == NULL )
{
@@ -1666,7 +1666,7 @@ int xc_domain_restore(int xc_handle, int
for ( k = 0; k < j; k++ )
{
if ( !uncanonicalize_pagetable(
- xc_handle, dom, ctx, XEN_DOMCTL_PFINFO_L1TAB,
+ xc_handle, dom, ctx,
region_base + k*PAGE_SIZE, superpages) )
{
ERROR("failed uncanonicalize pt!");
@@ -1949,7 +1949,7 @@ int xc_domain_restore(int xc_handle, int
}
/* Copy the P2M we've constructed to the 'live' P2M */
- if ( !(ctx->live_p2m = xc_map_foreign_batch(xc_handle, dom, PROT_WRITE,
+ if ( !(ctx->live_p2m = xc_map_foreign_pages(xc_handle, dom, PROT_WRITE,
p2m_frame_list, P2M_FL_ENTRIES)) )
{
ERROR("Couldn't map p2m table");
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/xc_domain_save.c
--- a/tools/libxc/xc_domain_save.c Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/xc_domain_save.c Wed Jan 13 08:12:56 2010 +0000
@@ -709,7 +709,7 @@ static xen_pfn_t *map_and_save_p2m_table
p2m_frame_list_list[i] = ((uint32_t *)p2m_frame_list_list)[i];
live_p2m_frame_list =
- xc_map_foreign_batch(xc_handle, dom, PROT_READ,
+ xc_map_foreign_pages(xc_handle, dom, PROT_READ,
p2m_frame_list_list,
P2M_FLL_ENTRIES);
if ( !live_p2m_frame_list )
@@ -726,6 +726,9 @@ static xen_pfn_t *map_and_save_p2m_table
}
memset(p2m_frame_list, 0, P2M_TOOLS_FL_SIZE);
memcpy(p2m_frame_list, live_p2m_frame_list, P2M_GUEST_FL_SIZE);
+
+ munmap(live_p2m_frame_list, P2M_FLL_ENTRIES * PAGE_SIZE);
+ live_p2m_frame_list = NULL;
/* Canonicalize guest's unsigned long vs ours */
if ( dinfo->guest_width > sizeof(unsigned long) )
@@ -741,7 +744,7 @@ static xen_pfn_t *map_and_save_p2m_table
(its not clear why it would want to change them, and we'll be OK
from a safety POV anyhow. */
- p2m = xc_map_foreign_batch(xc_handle, dom, PROT_READ,
+ p2m = xc_map_foreign_pages(xc_handle, dom, PROT_READ,
p2m_frame_list,
P2M_FL_ENTRIES);
if ( !p2m )
@@ -873,8 +876,9 @@ int xc_domain_save(int xc_handle, int io
vcpu_guest_context_any_t ctxt;
/* A table containing the type of each PFN (/not/ MFN!). */
- unsigned long *pfn_type = NULL;
+ xen_pfn_t *pfn_type = NULL;
unsigned long *pfn_batch = NULL;
+ int *pfn_err = NULL;
/* A copy of one frame of guest memory. */
char page[PAGE_SIZE];
@@ -1263,8 +1267,8 @@ int xc_domain_save(int xc_handle, int io
if ( batch == 0 )
goto skip; /* vanishingly unlikely... */
- region_base = xc_map_foreign_batch(
- xc_handle, dom, PROT_READ, pfn_type, batch);
+ region_base = xc_map_foreign_bulk(
+ xc_handle, dom, PROT_READ, pfn_type, pfn_err, batch);
if ( region_base == NULL )
{
ERROR("map batch failed");
@@ -1275,14 +1279,19 @@ int xc_domain_save(int xc_handle, int io
{
/* Look for and skip completely empty batches. */
for ( j = 0; j < batch; j++ )
- if ( (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) !=
- XEN_DOMCTL_PFINFO_XTAB )
+ {
+ if ( !pfn_err[j] )
break;
+ pfn_type[j] |= XEN_DOMCTL_PFINFO_XTAB;
+ }
if ( j == batch )
{
munmap(region_base, batch*PAGE_SIZE);
continue; /* bail on this batch: no valid pages */
}
+ for ( ; j < batch; j++ )
+ if ( pfn_err[j] )
+ pfn_type[j] |= XEN_DOMCTL_PFINFO_XTAB;
}
else
{
@@ -1296,16 +1305,17 @@ int xc_domain_save(int xc_handle, int io
goto out;
}
for ( j = batch-1; j >= 0; j-- )
- pfn_type[j] = ((uint32_t *)pfn_type)[j];
+ pfn_type[j] = ((uint32_t *)pfn_type)[j] &
+ XEN_DOMCTL_PFINFO_LTAB_MASK;
for ( j = 0; j < batch; j++ )
{
+ unsigned long mfn = pfn_to_mfn(pfn_batch[j]);
- if ( (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) ==
- XEN_DOMCTL_PFINFO_XTAB )
+ if ( pfn_type[j] == XEN_DOMCTL_PFINFO_XTAB )
{
DPRINTF("type fail: page %i mfn %08lx\n",
- j, pfn_type[j]);
+ j, mfn);
continue;
}
@@ -1313,16 +1323,13 @@ int xc_domain_save(int xc_handle, int io
DPRINTF("%d pfn= %08lx mfn= %08lx [mfn]= %08lx"
" sum= %08lx\n",
iter,
- (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) |
- pfn_batch[j],
- pfn_type[j],
- mfn_to_pfn(pfn_type[j] &
- ~XEN_DOMCTL_PFINFO_LTAB_MASK),
+ pfn_type[j] | pfn_batch[j],
+ mfn,
+ mfn_to_pfn(mfn),
csum_page(region_base + (PAGE_SIZE*j)));
/* canonicalise mfn->pfn */
- pfn_type[j] = (pfn_type[j] & XEN_DOMCTL_PFINFO_LTAB_MASK) |
- pfn_batch[j];
+ pfn_type[j] |= pfn_batch[j];
}
}
@@ -1332,11 +1339,17 @@ int xc_domain_save(int xc_handle, int io
goto out;
}
+ if ( sizeof(unsigned long) < sizeof(*pfn_type) )
+ for ( j = 0; j < batch; j++ )
+ ((unsigned long *)pfn_type)[j] = pfn_type[j];
if ( write_exact(io_fd, pfn_type, sizeof(unsigned long)*batch) )
{
PERROR("Error when writing to state file (3)");
goto out;
}
+ if ( sizeof(unsigned long) < sizeof(*pfn_type) )
+ while ( --j >= 0 )
+ pfn_type[j] = ((unsigned long *)pfn_type)[j];
/* entering this loop, pfn_type is now in pfns (Not mfns) */
run = 0;
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/xc_linux.c Wed Jan 13 08:12:56 2010 +0000
@@ -64,7 +64,7 @@ int xc_interface_close(int xc_handle)
return close(xc_handle);
}
-static int xc_map_foreign_batch_single(int xc_handle, uint32_t dom, int prot,
+static int xc_map_foreign_batch_single(int xc_handle, uint32_t dom,
xen_pfn_t *mfn, unsigned long addr)
{
privcmd_mmapbatch_t ioctlx;
@@ -116,7 +116,7 @@ void *xc_map_foreign_batch(int xc_handle
XEN_DOMCTL_PFINFO_PAGEDTAB )
{
unsigned long paged_addr = (unsigned long)addr + (i <<
PAGE_SHIFT);
- rc = xc_map_foreign_batch_single(xc_handle, dom, prot, &arr[i],
+ rc = xc_map_foreign_batch_single(xc_handle, dom, &arr[i],
paged_addr);
if ( rc < 0 )
goto out;
@@ -137,6 +137,131 @@ void *xc_map_foreign_batch(int xc_handle
return addr;
}
+void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,
+ const xen_pfn_t *arr, int *err, unsigned int num)
+{
+ privcmd_mmapbatch_v2_t ioctlx;
+ void *addr;
+ unsigned int i;
+ int rc;
+
+ addr = mmap(NULL, (unsigned long)num << PAGE_SHIFT, prot, MAP_SHARED,
+ xc_handle, 0);
+ if ( addr == MAP_FAILED )
+ {
+ perror("xc_map_foreign_batch: mmap failed");
+ return NULL;
+ }
+
+ ioctlx.num = num;
+ ioctlx.dom = dom;
+ ioctlx.addr = (unsigned long)addr;
+ ioctlx.arr = arr;
+ ioctlx.err = err;
+
+ rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH_V2, &ioctlx);
+
+ if ( rc < 0 && errno == ENOENT )
+ {
+ for ( i = rc = 0; rc == 0 && i < num; i++ )
+ {
+ if ( err[i] != -ENOENT )
+ continue;
+
+ ioctlx.num = 1;
+ ioctlx.dom = dom;
+ ioctlx.addr = (unsigned long)addr + ((unsigned long)i<<PAGE_SHIFT);
+ ioctlx.arr = arr + i;
+ ioctlx.err = err + i;
+ do {
+ usleep(100);
+ rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH_V2, &ioctlx);
+ } while ( rc < 0 && err[i] == -ENOENT );
+ }
+ }
+
+ if ( rc < 0 && errno == ENOTTY && (int)num > 0 )
+ {
+ /*
+ * IOCTL_PRIVCMD_MMAPBATCH_V2 is not supported - fall back to
+ * IOCTL_PRIVCMD_MMAPBATCH.
+ */
+ xen_pfn_t *pfn = calloc(num, sizeof(*pfn));
+
+ if ( pfn )
+ {
+ privcmd_mmapbatch_t ioctlx;
+
+ memcpy(pfn, arr, num * sizeof(*arr));
+
+ ioctlx.num = num;
+ ioctlx.dom = dom;
+ ioctlx.addr = (unsigned long)addr;
+ ioctlx.arr = pfn;
+
+ rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
+
+ rc = rc < 0 ? -errno : 0;
+
+ for ( i = 0; i < num; ++i )
+ {
+ switch ( pfn[i] ^ arr[i] )
+ {
+ case 0:
+ err[i] = rc != -ENOENT ? rc : 0;
+ continue;
+ default:
+ err[i] = -EINVAL;
+ continue;
+ case XEN_DOMCTL_PFINFO_PAGEDTAB:
+ if ( rc != -ENOENT )
+ {
+ err[i] = rc ?: -EINVAL;
+ continue;
+ }
+ rc = xc_map_foreign_batch_single(xc_handle, dom, pfn + i,
+ (unsigned long)addr + ((unsigned long)i<<PAGE_SHIFT));
+ if ( rc < 0 )
+ {
+ rc = -errno;
+ break;
+ }
+ rc = -ENOENT;
+ continue;
+ }
+ break;
+ }
+
+ free(pfn);
+
+ if ( rc == -ENOENT && i == num )
+ rc = 0;
+ else if ( rc )
+ {
+ errno = -rc;
+ rc = -1;
+ }
+ }
+ else
+ {
+ errno = -ENOMEM;
+ rc = -1;
+ }
+ }
+
+ if ( rc < 0 )
+ {
+ int saved_errno = errno;
+
+ perror("xc_map_foreign_bulk: ioctl failed");
+ (void)munmap(addr, (unsigned long)num << PAGE_SHIFT);
+ errno = saved_errno;
+ return NULL;
+ }
+
+ return addr;
+}
+
void *xc_map_foreign_range(int xc_handle, uint32_t dom, int size, int prot,
unsigned long mfn)
{
@@ -151,7 +276,7 @@ void *xc_map_foreign_range(int xc_handle
for ( i = 0; i < num; i++ )
arr[i] = mfn + i;
- ret = xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
+ ret = xc_map_foreign_pages(xc_handle, dom, prot, arr, num);
free(arr);
return ret;
}
@@ -175,7 +300,7 @@ void *xc_map_foreign_ranges(int xc_handl
for ( j = 0; j < num_per_entry; j++ )
arr[i * num_per_entry + j] = entries[i].mfn + j;
- ret = xc_map_foreign_batch(xc_handle, dom, prot, arr, num);
+ ret = xc_map_foreign_pages(xc_handle, dom, prot, arr, num);
free(arr);
return ret;
}
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/xc_misc.c Wed Jan 13 08:12:56 2010 +0000
@@ -352,25 +352,23 @@ void *xc_map_foreign_pages(int xc_handle
void *xc_map_foreign_pages(int xc_handle, uint32_t dom, int prot,
const xen_pfn_t *arr, int num)
{
- xen_pfn_t *pfn;
void *res;
- int i;
-
- pfn = malloc(num * sizeof(*pfn));
- if (!pfn)
+ int i, *err;
+
+ if (num < 0) {
+ errno = -EINVAL;
return NULL;
- memcpy(pfn, arr, num * sizeof(*pfn));
-
- res = xc_map_foreign_batch(xc_handle, dom, prot, pfn, num);
+ }
+
+ err = calloc(num, sizeof(*err));
+ if (!err)
+ return NULL;
+
+ res = xc_map_foreign_bulk(xc_handle, dom, prot, arr, err, num);
if (res) {
for (i = 0; i < num; i++) {
- if ((pfn[i] & 0xF0000000UL) == 0xF0000000UL) {
- /*
- * xc_map_foreign_batch() doesn't give us an error
- * code, so we have to make one up. May not be the
- * appropriate one.
- */
- errno = EINVAL;
+ if (err[i]) {
+ errno = -err[i];
munmap(res, num * PAGE_SIZE);
res = NULL;
break;
@@ -378,8 +376,51 @@ void *xc_map_foreign_pages(int xc_handle
}
}
+ free(err);
+ return res;
+}
+
+/* stub for all not yet converted OSes */
+void *
+#ifdef __GNUC__
+__attribute__((__weak__))
+#endif
+xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,
+ const xen_pfn_t *arr, int *err, unsigned int num)
+{
+ xen_pfn_t *pfn;
+ unsigned int i;
+ void *ret;
+
+ if ((int)num <= 0) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ pfn = calloc(num, sizeof(*pfn));
+ if (!pfn) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ memcpy(pfn, arr, num * sizeof(*arr));
+ ret = xc_map_foreign_batch(xc_handle, dom, prot, pfn, num);
+
+ if (ret) {
+ for (i = 0; i < num; ++i)
+ switch (pfn[i] ^ arr[i]) {
+ case 0:
+ err[i] = 0;
+ break;
+ default:
+ err[i] = -EINVAL;
+ break;
+ }
+ }
+
free(pfn);
- return res;
+
+ return ret;
}
/*
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/xc_resume.c
--- a/tools/libxc/xc_resume.c Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/xc_resume.c Wed Jan 13 08:12:56 2010 +0000
@@ -158,7 +158,7 @@ static int xc_domain_resume_any(int xc_h
goto out;
}
- p2m_frame_list = xc_map_foreign_batch(xc_handle, domid, PROT_READ,
+ p2m_frame_list = xc_map_foreign_pages(xc_handle, domid, PROT_READ,
p2m_frame_list_list,
P2M_FLL_ENTRIES);
if ( p2m_frame_list == NULL )
@@ -171,7 +171,7 @@ static int xc_domain_resume_any(int xc_h
the guest must not change which frames are used for this purpose.
(its not clear why it would want to change them, and we'll be OK
from a safety POV anyhow. */
- p2m = xc_map_foreign_batch(xc_handle, domid, PROT_READ,
+ p2m = xc_map_foreign_pages(xc_handle, domid, PROT_READ,
p2m_frame_list,
P2M_FL_ENTRIES);
if ( p2m == NULL )
diff -r 0e3910f1de64 -r 0b138a019292 tools/libxc/xenctrl.h
--- a/tools/libxc/xenctrl.h Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/libxc/xenctrl.h Wed Jan 13 08:12:56 2010 +0000
@@ -749,12 +749,22 @@ void *xc_map_foreign_pages(int xc_handle
const xen_pfn_t *arr, int num );
/**
+ * DEPRECATED - use xc_map_foreign_bulk() instead.
+ *
* Like xc_map_foreign_pages(), except it can succeeed partially.
* When a page cannot be mapped, its PFN in @arr is or'ed with
* 0xF0000000 to indicate the error.
*/
void *xc_map_foreign_batch(int xc_handle, uint32_t dom, int prot,
xen_pfn_t *arr, int num );
+
+/**
+ * Like xc_map_foreign_pages(), except it can succeed partially.
+ * When a page cannot be mapped, its respective field in @err is
+ * set to the corresponding errno value.
+ */
+void *xc_map_foreign_bulk(int xc_handle, uint32_t dom, int prot,
+ const xen_pfn_t *arr, int *err, unsigned int num);
/**
* Translates a virtual address in the context of a given domain and
diff -r 0e3910f1de64 -r 0b138a019292 tools/xenpaging/xenpaging.c
--- a/tools/xenpaging/xenpaging.c Tue Jan 12 07:17:40 2010 +0000
+++ b/tools/xenpaging/xenpaging.c Wed Jan 13 08:12:56 2010 +0000
@@ -310,9 +310,9 @@ int xenpaging_evict_page(xenpaging_t *pa
/* Map page */
gfn = victim->gfn;
ret = -EFAULT;
- page = xc_map_foreign_batch(paging->xc_handle, victim->domain_id,
+ page = xc_map_foreign_pages(paging->xc_handle, victim->domain_id,
PROT_READ | PROT_WRITE, &gfn, 1);
- if ( (gfn & XEN_DOMCTL_PFINFO_LTAB_MASK) == XEN_DOMCTL_PFINFO_XTAB )
+ if ( page == NULL )
{
ERROR("Error mapping page");
goto out;
@@ -386,19 +386,12 @@ int xenpaging_populate_page(xenpaging_t
/* Map page */
ret = -EFAULT;
- page = xc_map_foreign_batch(paging->xc_handle, paging->mem_event.domain_id,
+ page = xc_map_foreign_pages(paging->xc_handle, paging->mem_event.domain_id,
PROT_READ | PROT_WRITE, gfn, 1);
if ( page == NULL )
{
ERROR("Error mapping page: page is null");
goto out_map;
- }
-
- /* Check that the page exists */
- if ( (*gfn & XEN_DOMCTL_PFINFO_LTAB_MASK) == XEN_DOMCTL_PFINFO_XTAB )
- {
- ERROR("Error mapping page: gfn is invalid");
- goto out;
}
/* Read page */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|