]> xenbits.xensource.com Git - people/pauldu/mini-os.git/commitdiff
mini-os: don't allocate new pages for level 1 p2m tree
authorJuergen Gross <jgross@suse.com>
Mon, 1 Aug 2016 06:51:26 +0000 (08:51 +0200)
committerJuergen Gross <jgross@suse.com>
Thu, 11 Aug 2016 11:04:06 +0000 (13:04 +0200)
When constructing the 3 level p2m tree there is no need to allocate
new pages for the level 1 containing the p2m info for all pages. The
pages from the linear p2m list constructed by the hypervisor can be
used for that purpose.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
arch/x86/mm.c

index 12f7fe48eb4013b2684f75baa2146ed26e8b101a..e10c2c518af52952b8a19a999f5cd6feb3d8c6c8 100644 (file)
@@ -625,11 +625,11 @@ void arch_init_p2m(unsigned long max_pfn)
 #define L2_P2M_MASK     (L2_P2M_ENTRIES - 1)    
 #define L3_P2M_MASK     (L3_P2M_ENTRIES - 1)    
     
-    unsigned long *l1_list = NULL, *l2_list = NULL, *l3_list;
+    unsigned long *l2_list = NULL, *l3_list;
     unsigned long pfn;
     
     l3_list = (unsigned long *)alloc_page(); 
-    for ( pfn=0; pfn<max_pfn; pfn++ )
+    for ( pfn = 0; pfn < max_pfn; pfn += L1_P2M_ENTRIES )
     {
         if ( !(pfn % (L1_P2M_ENTRIES * L2_P2M_ENTRIES)) )
         {
@@ -641,14 +641,8 @@ void arch_init_p2m(unsigned long max_pfn)
             }
             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); 
+        l2_list[(pfn >> L1_P2M_SHIFT) & L2_P2M_MASK] =
+            virt_to_mfn(phys_to_machine_mapping + pfn);
     }
     HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list = 
         virt_to_mfn(l3_list);