aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxc/xc_dom_boot.c
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2008-07-23 16:39:46 +0100
committerKeir Fraser <keir.fraser@citrix.com>2008-07-23 16:39:46 +0100
commitce29ad450cc37e90052059118c075f80f79c9838 (patch)
tree944bbb8f868a5cf632d14cfcc1280233cf2b33e5 /tools/libxc/xc_dom_boot.c
parent6de959a1f6dd5ef22036f1a1d74cdcfce25d327c (diff)
downloadxen-ce29ad450cc37e90052059118c075f80f79c9838.tar.gz
xen-ce29ad450cc37e90052059118c075f80f79c9838.tar.bz2
xen-ce29ad450cc37e90052059118c075f80f79c9838.zip
libxc: Clean up xc_map_foreign_ranges() interface to hide the
underlying mmap() invocation. From: Christoph Egger <Christoph.Egger@amd.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
Diffstat (limited to 'tools/libxc/xc_dom_boot.c')
-rw-r--r--tools/libxc/xc_dom_boot.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index 30906ee993..7f37321ef7 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -153,7 +153,7 @@ void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn,
int page_shift = XC_DOM_PAGE_SHIFT(dom);
privcmd_mmap_entry_t *entries;
void *ptr;
- int i, rc;
+ int i;
int err;
entries = xc_dom_malloc(dom, count * sizeof(privcmd_mmap_entry_t));
@@ -165,9 +165,13 @@ void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn,
return NULL;
}
- ptr = mmap(NULL, count << page_shift, PROT_READ | PROT_WRITE,
- MAP_SHARED, dom->guest_xc, 0);
- if ( ptr == MAP_FAILED )
+ for ( i = 0; i < count; i++ )
+ entries[i].mfn = xc_dom_p2m_host(dom, pfn + i);
+
+ ptr = xc_map_foreign_ranges(dom->guest_xc, dom->guest_domid,
+ count << page_shift, PROT_READ | PROT_WRITE, 1 << page_shift,
+ entries, count);
+ if ( ptr == NULL )
{
err = errno;
xc_dom_panic(XC_INTERNAL_ERROR,
@@ -177,22 +181,6 @@ void *xc_dom_boot_domU_map(struct xc_dom_image *dom, xen_pfn_t pfn,
return NULL;
}
- for ( i = 0; i < count; i++ )
- {
- entries[i].va = (uintptr_t) ptr + (i << page_shift);
- entries[i].mfn = xc_dom_p2m_host(dom, pfn + i);
- entries[i].npages = 1;
- }
-
- rc = xc_map_foreign_ranges(dom->guest_xc, dom->guest_domid,
- entries, count);
- if ( rc < 0 )
- {
- xc_dom_panic(XC_INTERNAL_ERROR,
- "%s: failed to mmap domU pages 0x%" PRIpfn "+0x%" PRIpfn
- " [xenctl, rc=%d]\n", __FUNCTION__, pfn, count, rc);
- return NULL;
- }
return ptr;
}