WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxc: Fix after xc_map_foreign_ranges() patch.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 24 Jul 2008 07:40:08 -0700
Delivery-date: Thu, 24 Jul 2008 07:39:53 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxc: Fix after xc_map_foreign_ranges() patch., Xen patchbot-unstable <=