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

[Xen-changelog] Calling alloc_boot_pages() after end_boot_allocator() can result in



ChangeSet 1.1343, 2005/03/22 09:38:46+00:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Calling alloc_boot_pages() after end_boot_allocator() can result in
        double allocation of the same page.
        Signed-off-by: Chengyuan Li <chengyuan.li@xxxxxxxxx>
        Signed-off-by: Arun Sharma <arun.sharma@xxxxxxxxx>
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 mm.c |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)


diff -Nru a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  2005-03-22 05:03:59 -05:00
+++ b/xen/arch/x86/x86_64/mm.c  2005-03-22 05:03:59 -05:00
@@ -28,12 +28,26 @@
 #include <asm/fixmap.h>
 #include <asm/msr.h>
 
-void *safe_page_alloc(void)
+static void *safe_page_alloc(void)
 {
     extern int early_boot;
     if ( early_boot )
-        return __va(alloc_boot_pages(PAGE_SIZE, PAGE_SIZE));
-    return (void *)alloc_xenheap_page();
+    {
+        unsigned long p = alloc_boot_pages(PAGE_SIZE, PAGE_SIZE);
+        if ( p == 0 )
+            goto oom;
+        return phys_to_virt(p);
+    }
+    else
+    {
+        struct pfn_info *pg = alloc_domheap_page(NULL);
+        if ( pg == NULL )
+            goto oom;
+        return page_to_virt(pg);
+    }
+ oom:
+    panic("Out of memory");
+    return NULL;
 }
 
 /* Map physical byte range (@p, @p+@s) at virt address @v in pagetable @pt. */
@@ -118,6 +132,7 @@
 {
     unsigned long i, p, max;
     l3_pgentry_t *l3rw, *l3ro;
+    struct pfn_info *pg;
 
     /* Map all of physical memory. */
     max = ((max_page + L1_PAGETABLE_ENTRIES - 1) & 
@@ -130,10 +145,11 @@
      */
     for ( i = 0; i < max_page; i += ((1UL << L2_PAGETABLE_SHIFT) / 8) )
     {
-        p = alloc_boot_pages(1UL << L2_PAGETABLE_SHIFT,
-                             1UL << L2_PAGETABLE_SHIFT);
-        if ( p == 0 )
+        pg = alloc_domheap_pages(
+            NULL, L2_PAGETABLE_SHIFT - L1_PAGETABLE_SHIFT);
+        if ( pg == NULL )
             panic("Not enough memory for m2p table\n");
+        p = page_to_phys(pg);
         map_pages(idle_pg_table, RDWR_MPT_VIRT_START + i*8, p, 
                   1UL << L2_PAGETABLE_SHIFT, PAGE_HYPERVISOR | _PAGE_USER);
         memset((void *)(RDWR_MPT_VIRT_START + i*8), 0x55,


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-changelog


 


Rackspace

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