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

[Xen-devel] [PATCH 1/8] x86/p2m: make p2m_change_type() behavior match p2m_change_entry_type_global()'s



- don't reset access permissions
- don't shatter super pages

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Should p2m_change_type() also behave consistently?

--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -693,8 +693,7 @@ p2m_type_t p2m_change_type(struct domain
     return pt;
 }
 
-/* Modify the p2m type of a range of gfns from ot to nt.
- * Resets the access permissions. */
+/* Modify the p2m type of a range of gfns from ot to nt. */
 void p2m_change_type_range(struct domain *d, 
                            unsigned long start, unsigned long end,
                            p2m_type_t ot, p2m_type_t nt)
@@ -710,11 +709,29 @@ void p2m_change_type_range(struct domain
     p2m_lock(p2m);
     p2m->defer_nested_flush = 1;
 
-    for ( gfn = start; gfn < end; gfn++ )
+    for ( gfn = start; gfn < end; )
     {
-        mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, NULL);
+        unsigned int order;
+
+        mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, &order);
+        while ( order > PAGE_ORDER_4K )
+        {
+            if ( pt != ot )
+                break;
+            if ( !(gfn & ((1UL << order) - 1)) &&
+                 end > (gfn | ((1UL << order) - 1)) )
+                break;
+            if ( order == PAGE_ORDER_1G )
+                order = PAGE_ORDER_2M;
+            else
+                order = PAGE_ORDER_4K;
+        }
         if ( pt == ot )
-            set_p2m_entry(p2m, gfn, mfn, PAGE_ORDER_4K, nt, 
p2m->default_access);
+            set_p2m_entry(p2m, gfn, mfn, order, nt, a);
+        gfn += 1UL << order;
+        gfn &= -1UL << order;
+        if ( !gfn )
+            break;
     }
 
     p2m->defer_nested_flush = 0;



Attachment: x86-p2m-consistent-type-change.patch
Description: Text document

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

 


Rackspace

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