From 77689d0214b2b32c2798e50781486932a849d2f2 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Mon, 12 Dec 2011 12:37:21 +0000 Subject: [PATCH] --- yaml --- r: 297103 b: refs/heads/master c: a355aa54f1d25dff83c0feef8863d83a76988fdb h: refs/heads/master i: 297101: fb50862f257afe8e38f024d937050bd8e879b883 297099: e0bb8831a16a08b45014e9f8b14db8bd87fe71aa 297095: b5d177265ffcf3eb4c1214a52e1deb59af33b462 297087: 5cf3a848a82306a4da37981f3bc5dfe5be85c242 v: v3 --- [refs] | 2 +- trunk/include/linux/kvm_host.h | 14 +++++++++----- trunk/virt/kvm/kvm_main.c | 6 +++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 45361ce07d21..a4ce8ee4a083 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 342d3db763f2621ed4546ebf8f6c61cb29d7fbdb +refs/heads/master: a355aa54f1d25dff83c0feef8863d83a76988fdb diff --git a/trunk/include/linux/kvm_host.h b/trunk/include/linux/kvm_host.h index d4d4d7092110..eada8e69fe58 100644 --- a/trunk/include/linux/kvm_host.h +++ b/trunk/include/linux/kvm_host.h @@ -702,12 +702,16 @@ static inline int mmu_notifier_retry(struct kvm_vcpu *vcpu, unsigned long mmu_se if (unlikely(vcpu->kvm->mmu_notifier_count)) return 1; /* - * Both reads happen under the mmu_lock and both values are - * modified under mmu_lock, so there's no need of smb_rmb() - * here in between, otherwise mmu_notifier_count should be - * read before mmu_notifier_seq, see - * mmu_notifier_invalidate_range_end write side. + * Ensure the read of mmu_notifier_count happens before the read + * of mmu_notifier_seq. This interacts with the smp_wmb() in + * mmu_notifier_invalidate_range_end to make sure that the caller + * either sees the old (non-zero) value of mmu_notifier_count or + * the new (incremented) value of mmu_notifier_seq. + * PowerPC Book3s HV KVM calls this under a per-page lock + * rather than under kvm->mmu_lock, for scalability, so + * can't rely on kvm->mmu_lock to keep things ordered. */ + smp_rmb(); if (vcpu->kvm->mmu_notifier_seq != mmu_seq) return 1; return 0; diff --git a/trunk/virt/kvm/kvm_main.c b/trunk/virt/kvm/kvm_main.c index 64be836f3348..9f32bffd37c0 100644 --- a/trunk/virt/kvm/kvm_main.c +++ b/trunk/virt/kvm/kvm_main.c @@ -357,11 +357,11 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn, * been freed. */ kvm->mmu_notifier_seq++; + smp_wmb(); /* * The above sequence increase must be visible before the - * below count decrease but both values are read by the kvm - * page fault under mmu_lock spinlock so we don't need to add - * a smb_wmb() here in between the two. + * below count decrease, which is ensured by the smp_wmb above + * in conjunction with the smp_rmb in mmu_notifier_retry(). */ kvm->mmu_notifier_count--; spin_unlock(&kvm->mmu_lock);