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

[Xen-changelog] [xen-unstable] Create P2M map during Mini-OS boot (fixes 'xm dump-core').



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1172751824 0
# Node ID bdebca505d8e608c58ada65c25d925e620ebb77c
# Parent  afed0aeff629c7844cba7b29ec0501faa3946cc2
Create P2M map during Mini-OS boot (fixes 'xm dump-core').
Signed-off-by: Grzegorz Milos <gm281@xxxxxxxxx>
---
 extras/mini-os/arch/ia64/mm.c |    4 +++
 extras/mini-os/arch/x86/mm.c  |   43 ++++++++++++++++++++++++++++++++++++++++++
 extras/mini-os/include/mm.h   |    1 
 extras/mini-os/mm.c           |    2 +
 4 files changed, 50 insertions(+)

diff -r afed0aeff629 -r bdebca505d8e extras/mini-os/arch/ia64/mm.c
--- a/extras/mini-os/arch/ia64/mm.c     Thu Mar 01 12:23:04 2007 +0000
+++ b/extras/mini-os/arch/ia64/mm.c     Thu Mar 01 12:23:44 2007 +0000
@@ -130,3 +130,7 @@ map_frames(unsigned long* frames, unsign
        return (void*) __va(frames[0] << PAGE_SHIFT);
 }
 
+void arch_init_p2m(unsigned long max_pfn)
+{
+    printk("Warn: p2m map not implemented.\n");
+}
diff -r afed0aeff629 -r bdebca505d8e extras/mini-os/arch/x86/mm.c
--- a/extras/mini-os/arch/x86/mm.c      Thu Mar 01 12:23:04 2007 +0000
+++ b/extras/mini-os/arch/x86/mm.c      Thu Mar 01 12:23:44 2007 +0000
@@ -402,6 +402,49 @@ void *map_frames(unsigned long *f, unsig
     }
 }
 
+
+void arch_init_p2m(unsigned long max_pfn)
+{
+#define L1_P2M_SHIFT    10
+#define L2_P2M_SHIFT    20    
+#define L3_P2M_SHIFT    30    
+#define L1_P2M_ENTRIES  (1 << L1_P2M_SHIFT)    
+#define L2_P2M_ENTRIES  (1 << (L2_P2M_SHIFT - L1_P2M_SHIFT))    
+#define L3_P2M_ENTRIES  (1 << (L3_P2M_SHIFT - L2_P2M_SHIFT))    
+#define L1_P2M_MASK     (L1_P2M_ENTRIES - 1)    
+#define L2_P2M_MASK     (L2_P2M_ENTRIES - 1)    
+#define L3_P2M_MASK     (L3_P2M_ENTRIES - 1)    
+    
+    unsigned long *l1_list, *l2_list, *l3_list;
+    unsigned long pfn;
+    
+    l3_list = (unsigned long *)alloc_page(); 
+    for(pfn=0; pfn<max_pfn; pfn++)
+    {
+        if(!(pfn % (L1_P2M_ENTRIES * L2_P2M_ENTRIES)))
+        {
+            l2_list = (unsigned long*)alloc_page();
+            if((pfn >> L3_P2M_SHIFT) > 0)
+            {
+                printk("Error: Too many pfns.\n");
+                do_exit();
+            }
+            l3_list[(pfn >> L2_P2M_SHIFT)] = virt_to_mfn(l2_list);  
+        }
+        if(!(pfn % (L1_P2M_ENTRIES)))
+        {
+            l1_list = (unsigned long*)alloc_page();
+            l2_list[(pfn >> L1_P2M_SHIFT) & L2_P2M_MASK] = 
+                virt_to_mfn(l1_list); 
+        }
+
+        l1_list[pfn & L1_P2M_MASK] = pfn_to_mfn(pfn); 
+    }
+    HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = 
+        virt_to_mfn(l3_list);
+    HYPERVISOR_shared_info->arch.max_pfn = max_pfn;
+}
+
 void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p)
 {
 
diff -r afed0aeff629 -r bdebca505d8e extras/mini-os/include/mm.h
--- a/extras/mini-os/include/mm.h       Thu Mar 01 12:23:04 2007 +0000
+++ b/extras/mini-os/include/mm.h       Thu Mar 01 12:23:44 2007 +0000
@@ -55,6 +55,7 @@ static __inline__ int get_order(unsigned
 
 void arch_init_demand_mapping_area(unsigned long max_pfn);
 void arch_init_mm(unsigned long* start_pfn_p, unsigned long* max_pfn_p);
+void arch_init_p2m(unsigned long max_pfn_p);
 
 void *map_frames(unsigned long *f, unsigned long n);
 
diff -r afed0aeff629 -r bdebca505d8e extras/mini-os/mm.c
--- a/extras/mini-os/mm.c       Thu Mar 01 12:23:04 2007 +0000
+++ b/extras/mini-os/mm.c       Thu Mar 01 12:23:44 2007 +0000
@@ -379,6 +379,8 @@ void init_mm(void)
     init_page_allocator(PFN_PHYS(start_pfn), PFN_PHYS(max_pfn));
     printk("MM: done\n");
 
+    arch_init_p2m(max_pfn);
+    
     arch_init_demand_mapping_area(max_pfn);
 }
 

_______________________________________________
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®.