All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] KVM: MMU: don't drop spte if overwrite it from W to RO
@ 2010-11-12 10:30 Xiao Guangrong
  2010-11-12 10:33 ` [PATCH 2/4] KVM: MMU: rename 'reset_host_protection' to 'host_writeable' Xiao Guangrong
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Xiao Guangrong @ 2010-11-12 10:30 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, LKML, KVM

We just need flush tlb if overwrite a writable spte with a read-only one

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
---
 arch/x86/kvm/mmu.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 4b6d54c..1a93ab4 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -2044,6 +2044,15 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
 	if (pte_access & ACC_WRITE_MASK)
 		mark_page_dirty(vcpu->kvm, gfn);
 
+	/*
+	 * If we overwrite a writable spte with a read-only one,
+	 * flush remote TLBs. Otherwise rmap_write_protect will
+	 * find a read-only spte, even though the writable spte
+	 * might be cached on a CPU's TLB.
+	 */
+	else if (is_writable_pte(*sptep))
+		ret = 1;
+
 set_pte:
 	update_spte(sptep, spte);
 done:
@@ -2084,16 +2093,6 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep,
 				 spte_to_pfn(*sptep), pfn);
 			drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte);
 			kvm_flush_remote_tlbs(vcpu->kvm);
-		/*
-		 * If we overwrite a writable spte with a read-only one,
-		 * drop it and flush remote TLBs. Otherwise rmap_write_protect
-		 * will find a read-only spte, even though the writable spte
-		 * might be cached on a CPU's TLB.
-		 */
-		} else if (is_writable_pte(*sptep) &&
-			  (!(pte_access & ACC_WRITE_MASK) || !dirty)) {
-			drop_spte(vcpu->kvm, sptep, shadow_trap_nonpresent_pte);
-			kvm_flush_remote_tlbs(vcpu->kvm);
 		} else
 			was_rmapped = 1;
 	}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-11-17  1:54 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-12 10:30 [PATCH 1/4] KVM: MMU: don't drop spte if overwrite it from W to RO Xiao Guangrong
2010-11-12 10:33 ` [PATCH 2/4] KVM: MMU: rename 'reset_host_protection' to 'host_writeable' Xiao Guangrong
2010-11-12 10:37   ` Xiao Guangrong
2010-11-12 10:34 ` [PATCH 3/4] KVM: MMU: notrap it if gpte's reserved is set Xiao Guangrong
2010-11-14 10:56   ` Avi Kivity
2010-11-15  5:41     ` Xiao Guangrong
2010-11-15  9:17       ` Avi Kivity
2010-11-17  1:45         ` Xiao Guangrong
2010-11-12 10:35 ` [PATCH 4/4] KVM: MMU: cleanup update_pte, pte_prefetch and sync_page functions Xiao Guangrong
2010-11-16 20:52   ` Marcelo Tosatti
2010-11-17  1:58     ` Xiao Guangrong
2010-11-14 10:52 ` [PATCH 1/4] KVM: MMU: don't drop spte if overwrite it from W to RO Avi Kivity
2010-11-15  5:34   ` Xiao Guangrong
2010-11-16 20:24 ` Marcelo Tosatti
2010-11-17  1:42   ` Xiao Guangrong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.