Skip to contentSkip to conversation

PoD: Scrub pages before adding to the cache

PATCH In review George Dunlap 1 participant 3 messages Sep 11, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PoD: Scrub pages before adding to the cache

Neither memory from the allocator nor memory from the balloon driver is guaranteed to be zero. Scrub it before adding to the cache.

#1 lore raw

attaching the patch this time...

Quoted 6 lines · George Dunlap

Neither memory from the allocator nor memory from the balloon driver is guaranteed to be zero.  Scrub it before adding to the cache.

xen/arch/x86/mm/p2m.c +11 -0
diff -r fe15a885f9f9 xen/arch/x86/mm/p2m.c
@@ -257,6 +257,17 @@
     }
 #endif
 
+    /* Pages from domain_alloc and returned by the balloon driver aren't
+     * guaranteed to be zero; but by reclaiming zero pages, we implicitly promise
+     * to provide zero pages.  So we scrub pages before using */
+    for ( i=0; i< 1 << order ; i++)
+    {
+        char * b;
+        b = map_domain_page(page_to_mfn(page) + i);
+        clear_page(b);
+        unmap_domain_page(b);
+    }
+
     spin_lock(&d->page_alloc_lock);
 
     /* First, take all pages off the domain list */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#2 lore raw

Sorry, noticed that this patch doesn't build with debug=y. Attached patch is a replacement.
-George

Quoted 11 lines · George Dunlap

attaching the patch this time...

Quoted 6 lines · George Dunlap

Neither memory from the allocator nor memory from the balloon driver is guaranteed to be zero.  Scrub it before adding to the cache.

xen/arch/x86/mm/p2m.c +11 -0
diff -r d2a32e24fe50 xen/arch/x86/mm/p2m.c
@@ -307,6 +307,17 @@
     }
 #endif
 
+    /* Pages from domain_alloc and returned by the balloon driver aren't
+     * guaranteed to be zero; but by reclaiming zero pages, we implicitly promise
+     * to provide zero pages.  So we scrub pages before using */
+    for ( i=0; i< 1 << order ; i++)
+    {
+        char * b;
+        b = map_domain_page(mfn_x(page_to_mfn(page)) + i);
+        clear_page(b);
+        unmap_domain_page(b);
+    }
+
     spin_lock(&d->page_alloc_lock);
 
     /* First, take all pages off the domain list */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel