]> xenbits.xensource.com Git - xen.git/commitdiff
xenpaging: clear page content after evict
authorOlaf Hering <olaf@aepfle.de>
Tue, 11 Oct 2011 09:46:28 +0000 (10:46 +0100)
committerOlaf Hering <olaf@aepfle.de>
Tue, 11 Oct 2011 09:46:28 +0000 (10:46 +0100)
If the guest happens to read from the gfn while xenpaging is in the process of
evicting the page, the guest may read zeros instead of actual data.
Also if eviction fails the page content will be corrupted and xenpaging wont
attempt to restore the page.

Remove page scrubbing from pager and do it after successful eviction.

Signed-off-by: Olaf Hering <olaf@aepfle.de>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
tools/xenpaging/xenpaging.c
xen/arch/x86/mm/p2m.c

index e2cbc614d0d7edd51bf8300ceb7470b44e55e006..1ab756efb285b1c41109a79c56f11f0a1608f0e3 100644 (file)
@@ -455,9 +455,6 @@ static int xenpaging_evict_page(xenpaging_t *paging,
         goto out;
     }
 
-    /* Clear page */
-    memset(page, 0, PAGE_SIZE);
-
     munmap(page, PAGE_SIZE);
 
     /* Tell Xen to evict page */
index 473816c9f9f33daecb462281aa6234aa36697d02..004cd9b5b1afbeb9566f92e1a00132e60a0e0deb 100644 (file)
@@ -748,6 +748,9 @@ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn)
     set_p2m_entry(p2m, gfn, _mfn(INVALID_MFN), 0, p2m_ram_paged, a);
     audit_p2m(p2m, 1);
 
+    /* Clear content before returning the page to Xen */
+    scrub_one_page(page);
+
     /* Put the page back so it gets freed */
     put_page(page);