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

[Xen-devel] [PATCH 1/2] x86/p2m: simplify p2m_next_level()



Calculate entry PFN and flags just once, making the respective
variables (and also pg) function wide. Take the opportunity and also
make the induction variable unsigned.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -195,7 +195,9 @@ p2m_next_level(struct p2m_domain *p2m, v
     l1_pgentry_t *p2m_entry;
     l1_pgentry_t new_entry;
     void *next;
-    int i;
+    struct page_info *pg;
+    unsigned int i, flags;
+    unsigned long pfn;
 
     if ( !(p2m_entry = p2m_find_entry(*table, gfn_remainder, gfn,
                                       shift, max)) )
@@ -204,8 +206,6 @@ p2m_next_level(struct p2m_domain *p2m, v
     /* PoD/paging: Not present doesn't imply empty. */
     if ( !l1e_get_flags(*p2m_entry) )
     {
-        struct page_info *pg;
-
         pg = p2m_alloc_ptp(p2m, type);
         if ( pg == NULL )
             return -ENOMEM;
@@ -232,21 +232,17 @@ p2m_next_level(struct p2m_domain *p2m, v
         }
     }
 
-    ASSERT(l1e_get_flags(*p2m_entry) & (_PAGE_PRESENT|_PAGE_PSE));
+    flags = l1e_get_flags(*p2m_entry);
+    pfn = l1e_get_pfn(*p2m_entry);
+    ASSERT(flags & (_PAGE_PRESENT|_PAGE_PSE));
 
     /* split 1GB pages into 2MB pages */
-    if ( type == PGT_l2_page_table && (l1e_get_flags(*p2m_entry) & _PAGE_PSE) )
+    if ( type == PGT_l2_page_table && (flags & _PAGE_PSE) )
     {
-        unsigned long flags, pfn;
-        struct page_info *pg;
-
         pg = p2m_alloc_ptp(p2m, PGT_l2_page_table);
         if ( pg == NULL )
             return -ENOMEM;
 
-        flags = l1e_get_flags(*p2m_entry);
-        pfn = l1e_get_pfn(*p2m_entry);
-
         l1_entry = __map_domain_page(pg);
         for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
         {
@@ -263,19 +259,14 @@ p2m_next_level(struct p2m_domain *p2m, v
 
 
     /* split single 2MB large page into 4KB page in P2M table */
-    if ( type == PGT_l1_page_table && (l1e_get_flags(*p2m_entry) & _PAGE_PSE) )
+    if ( type == PGT_l1_page_table && (flags & _PAGE_PSE) )
     {
-        unsigned long flags, pfn;
-        struct page_info *pg;
-
         pg = p2m_alloc_ptp(p2m, PGT_l1_page_table);
         if ( pg == NULL )
             return -ENOMEM;
 
         /* New splintered mappings inherit the flags of the old superpage, 
          * with a little reorganisation for the _PAGE_PSE_PAT bit. */
-        flags = l1e_get_flags(*p2m_entry);
-        pfn = l1e_get_pfn(*p2m_entry);
         if ( pfn & 1 )           /* ==> _PAGE_PSE_PAT was set */
             pfn -= 1;            /* Clear it; _PAGE_PSE becomes _PAGE_PAT */
         else



Attachment: x86-p2m-pt-simplify.patch
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

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