[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxc: Fix after xc_map_foreign_ranges() patch.



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216894733 -3600
# Node ID 45adcd9d5cf6e8e8e40063596651cf304c68cb32
# Parent  7299346111fb1ea9de59c01ac73636618a559fe5
libxc: Fix after xc_map_foreign_ranges() patch.
Must munmap() region after loading elf image.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/libxc/xc_hvm_build.c |   14 ++++++++------
 tools/libxc/xc_linux.c     |   12 ++++++------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff -r 7299346111fb -r 45adcd9d5cf6 tools/libxc/xc_hvm_build.c
--- a/tools/libxc/xc_hvm_build.c        Wed Jul 23 16:39:46 2008 +0100
+++ b/tools/libxc/xc_hvm_build.c        Thu Jul 24 11:18:53 2008 +0100
@@ -126,19 +126,21 @@ static int loadelfimage(
     for ( i = 0; i < pages; i++ )
         entries[i].mfn = parray[(elf->pstart >> PAGE_SHIFT) + i];
 
-    elf->dest = xc_map_foreign_ranges(xch, dom, pages << PAGE_SHIFT,
-                       PROT_READ | PROT_WRITE, 1 << PAGE_SHIFT,
-                       entries, pages);
-    if (elf->dest == NULL)
+    elf->dest = xc_map_foreign_ranges(
+        xch, dom, pages << PAGE_SHIFT, PROT_READ | PROT_WRITE, 1 << PAGE_SHIFT,
+        entries, pages);
+    if ( elf->dest == NULL )
         goto err;
 
     /* Load the initial elf image. */
     elf_load_binary(elf);
     rc = 0;
 
+    munmap(elf->dest, pages << PAGE_SHIFT);
+    elf->dest = NULL;
+
  err:
-    if ( entries )
-        free(entries);
+    free(entries);
 
     return rc;
 }
diff -r 7299346111fb -r 45adcd9d5cf6 tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Wed Jul 23 16:39:46 2008 +0100
+++ b/tools/libxc/xc_linux.c    Thu Jul 24 11:18:53 2008 +0100
@@ -123,16 +123,16 @@ void *xc_map_foreign_ranges(int xc_handl
                             privcmd_mmap_entry_t entries[], int nentries)
 {
     privcmd_mmap_t ioctlx;
-
     int i, rc;
     void *addr;
 
     addr = mmap(NULL, size, prot, MAP_SHARED, xc_handle, 0);
-    if (addr == MAP_FAILED)
+    if ( addr == MAP_FAILED )
         goto mmap_failed;
 
-    for (i = 0; i < nentries; i++) {
-        entries[i].va = (uintptr_t)addr + (i * chunksize);
+    for ( i = 0; i < nentries; i++ )
+    {
+        entries[i].va = (unsigned long)addr + (i * chunksize);
         entries[i].npages = chunksize >> PAGE_SHIFT;
     }
 
@@ -141,14 +141,14 @@ void *xc_map_foreign_ranges(int xc_handl
     ioctlx.entry = entries;
 
     rc = ioctl(xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx);
-    if (rc)
+    if ( rc )
         goto ioctl_failed;
 
     return addr;
 
 ioctl_failed:
     rc = munmap(addr, size);
-    if (rc == -1)
+    if ( rc == -1 )
         ERROR("%s: error in error path\n", __FUNCTION__);
 
 mmap_failed:

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.