KVM: kvm_clear_guest_page(): fix empty_zero_page usage
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Fri Nov 22 17:59:05 EST 2013
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=8a3caa6d74597c2a083f7c87f866891a0b12540b
Commit: 8a3caa6d74597c2a083f7c87f866891a0b12540b
Parent: 521ee0cfb876dd31ce4e0878e1163fe0817a7acc
Author: Heiko Carstens <heiko.carstens at de.ibm.com>
AuthorDate: Mon Nov 18 10:35:55 2013 +0100
Committer: Gleb Natapov <gleb at redhat.com>
CommitDate: Thu Nov 21 11:19:32 2013 +0200
KVM: kvm_clear_guest_page(): fix empty_zero_page usage
Using the address of 'empty_zero_page' as source address in order to
clear a page is wrong. On some architectures empty_zero_page is only the
pointer to the struct page of the empty_zero_page. Therefore the clear
page operation would copy the contents of a couple of struct pages instead
of clearing a page. For kvm only arm/arm64 are affected by this bug.
To fix this use the ZERO_PAGE macro instead which will return the struct
page address of the empty_zero_page on all architectures.
Signed-off-by: Heiko Carstens <heiko.carstens at de.ibm.com>
Signed-off-by: Gleb Natapov <gleb at redhat.com>
---
virt/kvm/kvm_main.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 662f34c..a0aa84b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -1615,8 +1615,9 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
{
- return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page,
- offset, len);
+ const void *zero_page = (const void *) __va(page_to_phys(ZERO_PAGE(0)));
+
+ return kvm_write_guest_page(kvm, gfn, zero_page, offset, len);
}
EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
More information about the linux-mtd-cvs
mailing list