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] Clean up the page allocator interface a little. In parti

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Clean up the page allocator interface a little. In particular
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Thu, 09 Jun 2005 15:25:29 +0000
Delivery-date: Thu, 09 Jun 2005 16:02:07 +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.1700, 2005/06/09 16:25:29+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Clean up the page allocator interface a little. In particular
        physical addresses are now passed as physaddr_t rather than unsigned
        long (required for 32-bit pae mode).
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 arch/ia64/domain.c                      |    8 +++++-
 arch/ia64/patch/linux-2.6.7/mm_contig.c |    1 
 arch/ia64/xenmem.c                      |    9 ++++---
 arch/x86/apic.c                         |   10 +++-----
 arch/x86/dom0_ops.c                     |    4 +--
 arch/x86/domain.c                       |   14 ++++++------
 arch/x86/mm.c                           |   37 ++++++++++++++------------------
 arch/x86/smpboot.c                      |    2 -
 arch/x86/vmx_vmcs.c                     |    6 ++---
 arch/x86/x86_32/mm.c                    |    8 +++---
 arch/x86/x86_64/mm.c                    |   10 ++++----
 common/domain.c                         |    2 -
 common/grant_table.c                    |   14 ++++++------
 common/page_alloc.c                     |   37 ++++++++++++++------------------
 common/trace.c                          |    2 -
 common/xmalloc.c                        |    8 +++---
 drivers/char/console.c                  |    2 -
 drivers/char/serial.c                   |    2 -
 include/asm-x86/mm.h                    |    1 
 include/asm-x86/page.h                  |    2 -
 include/asm-x86/x86_32/page-2level.h    |    2 -
 include/xen/mm.h                        |   21 +++++++++---------
 22 files changed, 99 insertions(+), 103 deletions(-)


diff -Nru a/xen/arch/ia64/domain.c b/xen/arch/ia64/domain.c
--- a/xen/arch/ia64/domain.c    2005-06-09 12:03:00 -04:00
+++ b/xen/arch/ia64/domain.c    2005-06-09 12:03:00 -04:00
@@ -680,7 +680,9 @@
       * Some old version linux, like 2.4, assumes physical memory existing
       * in 2nd 64M space.
       */
-     dom0_start = alloc_boot_pages(dom0_size,dom0_align);
+     dom0_start = alloc_boot_pages(
+         dom0_size >> PAGE_SHIFT, dom0_align >> PAGE_SHIFT);
+     dom0_start <<= PAGE_SHIFT;
        if (!dom0_start) {
        printf("construct_dom0: can't allocate contiguous memory size=%p\n",
                dom0_size);
@@ -698,7 +700,9 @@
 {
        domU_staging_size = 32*1024*1024; //FIXME: Should be configurable
        printf("alloc_domU_staging: starting (initializing %d 
MB...)\n",domU_staging_size/(1024*1024));
-       domU_staging_start= 
alloc_boot_pages(domU_staging_size,domU_staging_align);
+       domU_staging_start = alloc_boot_pages(
+            domU_staging_size >> PAGE_SHIFT, domU_staging_align >> PAGE_SHIFT);
+        domU_staging_start <<= PAGE_SHIFT;
        if (!domU_staging_size) {
                printf("alloc_domU_staging: can't allocate, spinning...\n");
                while(1);
diff -Nru a/xen/arch/ia64/patch/linux-2.6.7/mm_contig.c 
b/xen/arch/ia64/patch/linux-2.6.7/mm_contig.c
--- a/xen/arch/ia64/patch/linux-2.6.7/mm_contig.c       2005-06-09 12:03:00 
-04:00
+++ b/xen/arch/ia64/patch/linux-2.6.7/mm_contig.c       2005-06-09 12:03:00 
-04:00
@@ -204,7 +204,7 @@
 +
 +      /* Request continuous trunk from boot allocator, since HV
 +       * address is identity mapped */
-+      p = alloc_boot_pages(frame_table_size, FT_ALIGN_SIZE);
++      p = alloc_boot_pages(frame_table_size>>PAGE_SHIFT, 
FT_ALIGN_SIZE>>PAGE_SHIFT) << PAGE_SHIFT;
 +      if (p == 0)
 +              panic("Not enough memory for frame table.\n");
 +
diff -Nru a/xen/arch/ia64/xenmem.c b/xen/arch/ia64/xenmem.c
--- a/xen/arch/ia64/xenmem.c    2005-06-09 12:03:00 -04:00
+++ b/xen/arch/ia64/xenmem.c    2005-06-09 12:03:00 -04:00
@@ -82,17 +82,18 @@
 #define FT_ALIGN_SIZE  (16UL << 20)
 void __init init_frametable(void)
 {
-       unsigned long i, p;
+       unsigned long i, pfn;
        frame_table_size = max_page * sizeof(struct pfn_info);
        frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
 
        /* Request continuous trunk from boot allocator, since HV
         * address is identity mapped */
-       p = alloc_boot_pages(frame_table_size, FT_ALIGN_SIZE);
-       if (p == 0)
+       pfn = alloc_boot_pages(
+            frame_table_size >> PAGE_SHIFT, FT_ALIGN_SIZE >> PAGE_SHIFT);
+       if (pfn == 0)
                panic("Not enough memory for frame table.\n");
 
-       frame_table = __va(p);
+       frame_table = __va(pfn << PAGE_SHIFT);
        memset(frame_table, 0, frame_table_size);
        printk("size of frame_table: %lukB\n",
                frame_table_size >> 10);
diff -Nru a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
--- a/xen/arch/x86/apic.c       2005-06-09 12:03:03 -04:00
+++ b/xen/arch/x86/apic.c       2005-06-09 12:03:03 -04:00
@@ -580,10 +580,9 @@
      * zeroes page to simulate the local APIC and another
      * one for the IO-APIC.
      */
-    if (!smp_found_config && detect_init_APIC()) {
-        apic_phys = alloc_xenheap_page();
-        apic_phys = __pa(apic_phys);
-    } else
+    if (!smp_found_config && detect_init_APIC())
+        apic_phys = __pa(alloc_xenheap_page());
+    else
         apic_phys = mp_lapic_addr;
 
     set_fixmap_nocache(FIX_APIC_BASE, apic_phys);
@@ -616,8 +615,7 @@
                 }
             } else {
 fake_ioapic_page:
-                ioapic_phys = alloc_xenheap_page();
-                ioapic_phys = __pa(ioapic_phys);
+                ioapic_phys = __pa(alloc_xenheap_page());
             }
             set_fixmap_nocache(idx, ioapic_phys);
             apic_printk(APIC_VERBOSE, "mapped IOAPIC to %08lx (%08lx)\n",
diff -Nru a/xen/arch/x86/dom0_ops.c b/xen/arch/x86/dom0_ops.c
--- a/xen/arch/x86/dom0_ops.c   2005-06-09 12:03:01 -04:00
+++ b/xen/arch/x86/dom0_ops.c   2005-06-09 12:03:01 -04:00
@@ -259,7 +259,7 @@
             break;
         }
 
-        l_arr = (unsigned long *)alloc_xenheap_page();
+        l_arr = alloc_xenheap_page();
  
         ret = 0;
         for( n = 0; n < num; )
@@ -324,7 +324,7 @@
             n += j;
         }
 
-        free_xenheap_page((unsigned long)l_arr);
+        free_xenheap_page(l_arr);
 
         put_domain(d);
     }
diff -Nru a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     2005-06-09 12:03:01 -04:00
+++ b/xen/arch/x86/domain.c     2005-06-09 12:03:01 -04:00
@@ -222,10 +222,10 @@
 
 void free_perdomain_pt(struct domain *d)
 {
-    free_xenheap_page((unsigned long)d->arch.mm_perdomain_pt);
+    free_xenheap_page(d->arch.mm_perdomain_pt);
 #ifdef __x86_64__
-    free_xenheap_page((unsigned long)d->arch.mm_perdomain_l2);
-    free_xenheap_page((unsigned long)d->arch.mm_perdomain_l3);
+    free_xenheap_page(d->arch.mm_perdomain_l2);
+    free_xenheap_page(d->arch.mm_perdomain_l3);
 #endif
 }
 
@@ -240,7 +240,7 @@
 
     v->arch.schedule_tail = continue_nonidle_task;
     
-    d->shared_info = (void *)alloc_xenheap_page();
+    d->shared_info = alloc_xenheap_page();
     memset(d->shared_info, 0, PAGE_SIZE);
     v->vcpu_info = &d->shared_info->vcpu_data[v->vcpu_id];
     v->cpumap = CPUMAP_RUNANYWHERE;
@@ -248,7 +248,7 @@
     machine_to_phys_mapping[virt_to_phys(d->shared_info) >> 
                            PAGE_SHIFT] = INVALID_M2P_ENTRY;
     
-    d->arch.mm_perdomain_pt = (l1_pgentry_t *)alloc_xenheap_page();
+    d->arch.mm_perdomain_pt = alloc_xenheap_page();
     memset(d->arch.mm_perdomain_pt, 0, PAGE_SIZE);
     machine_to_phys_mapping[virt_to_phys(d->arch.mm_perdomain_pt) >> 
                            PAGE_SHIFT] = INVALID_M2P_ENTRY;
@@ -263,12 +263,12 @@
     v->arch.guest_vl3table = __linear_l3_table;
     v->arch.guest_vl4table = __linear_l4_table;
     
-    d->arch.mm_perdomain_l2 = (l2_pgentry_t *)alloc_xenheap_page();
+    d->arch.mm_perdomain_l2 = alloc_xenheap_page();
     memset(d->arch.mm_perdomain_l2, 0, PAGE_SIZE);
     d->arch.mm_perdomain_l2[l2_table_offset(PERDOMAIN_VIRT_START)] = 
         l2e_from_page(virt_to_page(d->arch.mm_perdomain_pt),
                         __PAGE_HYPERVISOR);
-    d->arch.mm_perdomain_l3 = (l3_pgentry_t *)alloc_xenheap_page();
+    d->arch.mm_perdomain_l3 = alloc_xenheap_page();
     memset(d->arch.mm_perdomain_l3, 0, PAGE_SIZE);
     d->arch.mm_perdomain_l3[l3_table_offset(PERDOMAIN_VIRT_START)] = 
         l3e_from_page(virt_to_page(d->arch.mm_perdomain_l2),
diff -Nru a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c 2005-06-09 12:03:00 -04:00
+++ b/xen/arch/x86/mm.c 2005-06-09 12:03:00 -04:00
@@ -145,31 +145,28 @@
 
 /* Frame table and its size in pages. */
 struct pfn_info *frame_table;
-unsigned long frame_table_size;
 unsigned long max_page;
 
 void __init init_frametable(void)
 {
-    unsigned long i, p, step;
+    unsigned long nr_pages, page_step, i, pfn;
 
-    frame_table      = (struct pfn_info *)FRAMETABLE_VIRT_START;
-    frame_table_size = max_page * sizeof(struct pfn_info);
-    frame_table_size = (frame_table_size + PAGE_SIZE - 1) & PAGE_MASK;
+    frame_table = (struct pfn_info *)FRAMETABLE_VIRT_START;
 
-    step = (1 << L2_PAGETABLE_SHIFT);
-    for ( i = 0; i < frame_table_size; i += step )
+    nr_pages  = PFN_UP(max_page * sizeof(*frame_table));
+    page_step = (1 << L2_PAGETABLE_SHIFT) >> PAGE_SHIFT;
+
+    for ( i = 0; i < nr_pages; i += page_step )
     {
-        p = alloc_boot_pages(min(frame_table_size - i, step), step);
-        if ( p == 0 )
+        pfn = alloc_boot_pages(min(nr_pages - i, page_step), page_step);
+        if ( pfn == 0 )
             panic("Not enough memory for frame table\n");
         map_pages_to_xen(
-            FRAMETABLE_VIRT_START + i,
-            p >> PAGE_SHIFT,
-            step >> PAGE_SHIFT,
-            PAGE_HYPERVISOR);
+            FRAMETABLE_VIRT_START + (i << PAGE_SHIFT),
+            pfn, page_step, PAGE_HYPERVISOR);
     }
 
-    memset(frame_table, 0, frame_table_size);
+    memset(frame_table, 0, nr_pages << PAGE_SHIFT);
 }
 
 void arch_init_memory(void)
@@ -2954,15 +2951,15 @@
 
 int ptwr_init(struct domain *d)
 {
-    void *x = (void *)alloc_xenheap_page();
-    void *y = (void *)alloc_xenheap_page();
+    void *x = alloc_xenheap_page();
+    void *y = alloc_xenheap_page();
 
     if ( (x == NULL) || (y == NULL) )
     {
         if ( x != NULL )
-            free_xenheap_page((unsigned long)x);
+            free_xenheap_page(x);
         if ( y != NULL )
-            free_xenheap_page((unsigned long)y);
+            free_xenheap_page(y);
         return -ENOMEM;
     }
 
@@ -2975,8 +2972,8 @@
 void ptwr_destroy(struct domain *d)
 {
     cleanup_writable_pagetable(d);
-    free_xenheap_page((unsigned long)d->arch.ptwr[PTWR_PT_ACTIVE].page);
-    free_xenheap_page((unsigned long)d->arch.ptwr[PTWR_PT_INACTIVE].page);
+    free_xenheap_page(d->arch.ptwr[PTWR_PT_ACTIVE].page);
+    free_xenheap_page(d->arch.ptwr[PTWR_PT_INACTIVE].page);
 }
 
 void cleanup_writable_pagetable(struct domain *d)
diff -Nru a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c    2005-06-09 12:03:01 -04:00
+++ b/xen/arch/x86/smpboot.c    2005-06-09 12:03:01 -04:00
@@ -781,7 +781,7 @@
        /* So we see what's up   */
        printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
 
-       stack = (void *)alloc_xenheap_pages(STACK_ORDER);
+       stack = alloc_xenheap_pages(STACK_ORDER);
 #if defined(__i386__)
        stack_start.esp = (void *)__pa(stack);
 #elif defined(__x86_64__)

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Clean up the page allocator interface a little. In particular, BitKeeper Bot <=