diff options
author | Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> | 2014-04-17 05:06:12 -0400 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2014-04-23 16:49:48 -0400 |
commit | a086f6a1ebc9d8d2d028b99e779ce0dbd9691dea (patch) | |
tree | de33d7b00d27226d7b775dd038875f12d55c6e0a | |
parent | 42bf549f3c672006ba18e97152cbc563315ba4e6 (diff) |
Revert "KVM: Simplify kvm->tlbs_dirty handling"
This reverts commit 5befdc385ddb2d5ae8995ad89004529a3acf58fc.
Since we will allow flush tlb out of mmu-lock in the later
patch
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 7 | ||||
-rw-r--r-- | include/linux/kvm_host.h | 4 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 5 |
3 files changed, 8 insertions, 8 deletions
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index 123efd3ec29f..410776528265 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -913,8 +913,7 @@ static gpa_t FNAME(gva_to_gpa_nested)(struct kvm_vcpu *vcpu, gva_t vaddr, | |||
913 | * and kvm_mmu_notifier_invalidate_range_start detect the mapping page isn't | 913 | * and kvm_mmu_notifier_invalidate_range_start detect the mapping page isn't |
914 | * used by guest then tlbs are not flushed, so guest is allowed to access the | 914 | * used by guest then tlbs are not flushed, so guest is allowed to access the |
915 | * freed pages. | 915 | * freed pages. |
916 | * We set tlbs_dirty to let the notifier know this change and delay the flush | 916 | * And we increase kvm->tlbs_dirty to delay tlbs flush in this case. |
917 | * until such a case actually happens. | ||
918 | */ | 917 | */ |
919 | static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) | 918 | static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) |
920 | { | 919 | { |
@@ -943,7 +942,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) | |||
943 | return -EINVAL; | 942 | return -EINVAL; |
944 | 943 | ||
945 | if (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) { | 944 | if (FNAME(prefetch_invalid_gpte)(vcpu, sp, &sp->spt[i], gpte)) { |
946 | vcpu->kvm->tlbs_dirty = true; | 945 | vcpu->kvm->tlbs_dirty++; |
947 | continue; | 946 | continue; |
948 | } | 947 | } |
949 | 948 | ||
@@ -958,7 +957,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp) | |||
958 | 957 | ||
959 | if (gfn != sp->gfns[i]) { | 958 | if (gfn != sp->gfns[i]) { |
960 | drop_spte(vcpu->kvm, &sp->spt[i]); | 959 | drop_spte(vcpu->kvm, &sp->spt[i]); |
961 | vcpu->kvm->tlbs_dirty = true; | 960 | vcpu->kvm->tlbs_dirty++; |
962 | continue; | 961 | continue; |
963 | } | 962 | } |
964 | 963 | ||
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 32d263f683dc..820fc2e1d9df 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -411,9 +411,7 @@ struct kvm { | |||
411 | unsigned long mmu_notifier_seq; | 411 | unsigned long mmu_notifier_seq; |
412 | long mmu_notifier_count; | 412 | long mmu_notifier_count; |
413 | #endif | 413 | #endif |
414 | /* Protected by mmu_lock */ | 414 | long tlbs_dirty; |
415 | bool tlbs_dirty; | ||
416 | |||
417 | struct list_head devices; | 415 | struct list_head devices; |
418 | }; | 416 | }; |
419 | 417 | ||
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index ea46d64c8e75..fa70c6e642b4 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -186,9 +186,12 @@ static bool make_all_cpus_request(struct kvm *kvm, unsigned int req) | |||
186 | 186 | ||
187 | void kvm_flush_remote_tlbs(struct kvm *kvm) | 187 | void kvm_flush_remote_tlbs(struct kvm *kvm) |
188 | { | 188 | { |
189 | long dirty_count = kvm->tlbs_dirty; | ||
190 | |||
191 | smp_mb(); | ||
189 | if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) | 192 | if (make_all_cpus_request(kvm, KVM_REQ_TLB_FLUSH)) |
190 | ++kvm->stat.remote_tlb_flush; | 193 | ++kvm->stat.remote_tlb_flush; |
191 | kvm->tlbs_dirty = false; | 194 | cmpxchg(&kvm->tlbs_dirty, dirty_count, 0); |
192 | } | 195 | } |
193 | EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); | 196 | EXPORT_SYMBOL_GPL(kvm_flush_remote_tlbs); |
194 | 197 | ||