aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-05-01 07:16:52 -0400
committerAvi Kivity <avi@qumranet.com>2007-07-16 05:05:38 -0400
commit09072daf37abbfe8e2d5018dd913f229c76190f7 (patch)
treedbccbe493a9412cb89bd48b7c0c8ec21f70cf091 /drivers/kvm/kvm_main.c
parent621358455ae043ab39bc3481f13b101bd6016c8d (diff)
KVM: Unify kvm_mmu_pre_write() and kvm_mmu_post_write()
Instead of calling two functions and repeating expensive checks, call one function and provide it with before/after information. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 7d682586423b..b6ad9c6f2efe 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1071,18 +1071,18 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa,
1071{ 1071{
1072 struct page *page; 1072 struct page *page;
1073 void *virt; 1073 void *virt;
1074 unsigned offset = offset_in_page(gpa);
1074 1075
1075 if (((gpa + bytes - 1) >> PAGE_SHIFT) != (gpa >> PAGE_SHIFT)) 1076 if (((gpa + bytes - 1) >> PAGE_SHIFT) != (gpa >> PAGE_SHIFT))
1076 return 0; 1077 return 0;
1077 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT); 1078 page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
1078 if (!page) 1079 if (!page)
1079 return 0; 1080 return 0;
1080 kvm_mmu_pre_write(vcpu, gpa, bytes);
1081 mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT); 1081 mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT);
1082 virt = kmap_atomic(page, KM_USER0); 1082 virt = kmap_atomic(page, KM_USER0);
1083 kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes);
1083 memcpy(virt + offset_in_page(gpa), val, bytes); 1084 memcpy(virt + offset_in_page(gpa), val, bytes);
1084 kunmap_atomic(virt, KM_USER0); 1085 kunmap_atomic(virt, KM_USER0);
1085 kvm_mmu_post_write(vcpu, gpa, bytes);
1086 return 1; 1086 return 1;
1087} 1087}
1088 1088