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

[Xen-devel] [PATCH v2 18/55] x86/mm: switch to new APIs in modify_xen_mappings



From: Wei Liu <wei.liu2@xxxxxxxxxx>

Page tables allocated in that function should be mapped and unmapped
now.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Signed-off-by: Hongyan Xia <hongyax@xxxxxxxxxx>

---
Changed since v1:
  * remove redundant lines
---
 xen/arch/x86/mm.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 08af71a261..a812ef0244 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5562,6 +5562,7 @@ int modify_xen_mappings(unsigned long s, unsigned long e, 
unsigned int nf)
         if ( l3e_get_flags(*pl3e) & _PAGE_PSE )
         {
             l2_pgentry_t *l2t;
+            mfn_t mfn;
 
             if ( l2_table_offset(v) == 0 &&
                  l1_table_offset(v) == 0 &&
@@ -5578,13 +5579,15 @@ int modify_xen_mappings(unsigned long s, unsigned long 
e, unsigned int nf)
             }
 
             /* PAGE1GB: shatter the superpage and fall through. */
-            l2t = alloc_xen_pagetable();
-            if ( !l2t )
+            mfn = alloc_xen_pagetable_new();
+            if ( mfn_eq(mfn, INVALID_MFN) )
             {
                 ASSERT(rc == -ENOMEM);
                 goto out;
             }
 
+            l2t = map_xen_pagetable_new(mfn);
+
             for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
                 l2e_write(l2t + i,
                           l2e_from_pfn(l3e_get_pfn(*pl3e) +
@@ -5595,14 +5598,16 @@ int modify_xen_mappings(unsigned long s, unsigned long 
e, unsigned int nf)
             if ( (l3e_get_flags(*pl3e) & _PAGE_PRESENT) &&
                  (l3e_get_flags(*pl3e) & _PAGE_PSE) )
             {
-                l3e_write_atomic(pl3e, l3e_from_mfn(virt_to_mfn(l2t),
-                                                    __PAGE_HYPERVISOR));
-                l2t = NULL;
+                l3e_write_atomic(pl3e, l3e_from_mfn(mfn, __PAGE_HYPERVISOR));
+                UNMAP_XEN_PAGETABLE_NEW(l2t);
             }
             if ( locking )
                 spin_unlock(&map_pgdir_lock);
             if ( l2t )
-                free_xen_pagetable(l2t);
+            {
+                UNMAP_XEN_PAGETABLE_NEW(l2t);
+                free_xen_pagetable_new(mfn);
+            }
         }
 
         /*
@@ -5637,15 +5642,18 @@ int modify_xen_mappings(unsigned long s, unsigned long 
e, unsigned int nf)
             else
             {
                 l1_pgentry_t *l1t;
+                mfn_t mfn;
 
                 /* PSE: shatter the superpage and try again. */
-                l1t = alloc_xen_pagetable();
-                if ( !l1t )
+                mfn = alloc_xen_pagetable_new();
+                if ( mfn_eq(mfn, INVALID_MFN) )
                 {
                     ASSERT(rc == -ENOMEM);
                     goto out;
                 }
 
+                l1t = map_xen_pagetable_new(mfn);
+
                 for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
                     l1e_write(&l1t[i],
                               l1e_from_pfn(l2e_get_pfn(*pl2e) + i,
@@ -5655,14 +5663,17 @@ int modify_xen_mappings(unsigned long s, unsigned long 
e, unsigned int nf)
                 if ( (l2e_get_flags(*pl2e) & _PAGE_PRESENT) &&
                      (l2e_get_flags(*pl2e) & _PAGE_PSE) )
                 {
-                    l2e_write_atomic(pl2e, l2e_from_mfn(virt_to_mfn(l1t),
+                    l2e_write_atomic(pl2e, l2e_from_mfn(mfn,
                                                         __PAGE_HYPERVISOR));
-                    l1t = NULL;
+                    UNMAP_XEN_PAGETABLE_NEW(l1t);
                 }
                 if ( locking )
                     spin_unlock(&map_pgdir_lock);
                 if ( l1t )
-                    free_xen_pagetable(l1t);
+                {
+                    UNMAP_XEN_PAGETABLE_NEW(l1t);
+                    free_xen_pagetable_new(mfn);
+                }
             }
         }
         else
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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