Commit 3e021bf5 authored by Izik Eidus's avatar Izik Eidus Committed by Avi Kivity

KVM: Simplify kvm_clear_guest_page()

Use kvm_write_guest_page() with empty_zero_page, instead of doing
kmap and memset.
Signed-off-by: default avatarIzik Eidus <izike@qumranet.com>
Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent ec8d4eae
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <asm/io.h> #include <asm/io.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/desc.h> #include <asm/desc.h>
#include <asm/pgtable.h>
MODULE_AUTHOR("Qumranet"); MODULE_AUTHOR("Qumranet");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -633,22 +634,7 @@ int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data, ...@@ -633,22 +634,7 @@ int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len) int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
{ {
void *page_virt; return kvm_write_guest_page(kvm, gfn, empty_zero_page, offset, len);
struct page *page;
page = gfn_to_page(kvm, gfn);
if (is_error_page(page)) {
kvm_release_page(page);
return -EFAULT;
}
page_virt = kmap_atomic(page, KM_USER0);
memset(page_virt + offset, 0, len);
kunmap_atomic(page_virt, KM_USER0);
kvm_release_page(page);
mark_page_dirty(kvm, gfn);
return 0;
} }
EXPORT_SYMBOL_GPL(kvm_clear_guest_page); EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment