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] Some more mmap() error-return fixes.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Some more mmap() error-return fixes.
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Thu, 12 May 2005 10:39:43 +0000
Delivery-date: Thu, 12 May 2005 11:03:09 +0000
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
ChangeSet 1.1454, 2005/05/12 11:39:43+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Some more mmap() error-return fixes.
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 xc_ptrace_core.c |   23 ++++++++++++++++-------
 1 files changed, 16 insertions(+), 7 deletions(-)


diff -Nru a/tools/libxc/xc_ptrace_core.c b/tools/libxc/xc_ptrace_core.c
--- a/tools/libxc/xc_ptrace_core.c      2005-05-12 07:03:44 -04:00
+++ b/tools/libxc/xc_ptrace_core.c      2005-05-12 07:03:44 -04:00
@@ -107,6 +107,7 @@
 {
     unsigned long pde, page;
     unsigned long va = (unsigned long)guest_va;
+    void *v;
 
     static unsigned long  cr3_phys[MAX_VIRT_CPUS];
     static unsigned long *cr3_virt[MAX_VIRT_CPUS];
@@ -120,13 +121,15 @@
        cr3_phys[cpu] = cr3[cpu];
        if (cr3_virt[cpu])
            munmap(cr3_virt[cpu], PAGE_SIZE);
-       if ((cr3_virt[cpu] = mmap(NULL, PAGE_SIZE, PROT_READ, 
-                                 MAP_PRIVATE, domfd, 
map_mtop_offset(cr3_phys[cpu]))) == 
-           (unsigned long*)0xffffffff)
+       v = mmap(
+            NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, domfd,
+            map_mtop_offset(cr3_phys[cpu]));
+        if (v == MAP_FAILED)
        {
            perror("mmap failed");
            goto error_out;
        }
+        cr3_virt[cpu] = v;
     } 
     if ((pde = cr3_virt[cpu][vtopdi(va)]) == 0) /* logical address */
        goto error_out;
@@ -137,9 +140,12 @@
        pde_phys[cpu] = pde;
        if (pde_virt[cpu])
            munmap(pde_virt[cpu], PAGE_SIZE);
-       if ((pde_virt[cpu] =  mmap(NULL, PAGE_SIZE, PROT_READ, 
-                                 MAP_PRIVATE, domfd, 
map_mtop_offset(pde_phys[cpu]))) == NULL)
+       v = mmap(
+            NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, domfd,
+            map_mtop_offset(pde_phys[cpu]));
+        if (v == MAP_FAILED)
            goto error_out;
+        pde_virt[cpu] = v;
     }
     if ((page = pde_virt[cpu][vtopti(va)]) == 0) /* logical address */
        goto error_out;
@@ -150,12 +156,15 @@
        page_phys[cpu] = page;
        if (page_virt[cpu])
            munmap(page_virt[cpu], PAGE_SIZE);
-       if ((page_virt[cpu] = mmap(NULL, PAGE_SIZE, PROT_READ, 
-                                 MAP_PRIVATE, domfd, 
map_mtop_offset(page_phys[cpu]))) == NULL) {
+       v = mmap(
+            NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE, domfd,
+            map_mtop_offset(page_phys[cpu]));
+        if (v == MAP_FAILED) {
            printf("cr3 %lx pde %lx page %lx pti %lx\n", cr3[cpu], pde, page, 
vtopti(va));
            page_phys[cpu] = 0;
            goto error_out;
        }
+        page_virt[cpu] = v;
     }  
     return (void *)(((unsigned long)page_virt[cpu]) | (va & BSD_PAGE_MASK));
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Some more mmap() error-return fixes., BitKeeper Bot <=