From: Olaf Hering Date: Tue, 11 Oct 2011 09:46:28 +0000 (+0100) Subject: xenpaging: clear page content after evict X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=62530296c71a6572e6ae82ffe3a309ab6540d53a;p=xen.git xenpaging: clear page content after evict 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 Acked-by: Ian Jackson Acked-by: Tim Deegan Committed-by: Tim Deegan --- diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c index e2cbc614d0..1ab756efb2 100644 --- a/tools/xenpaging/xenpaging.c +++ b/tools/xenpaging/xenpaging.c @@ -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 */ diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 473816c9f9..004cd9b5b1 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -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);