summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu/page_track.c
diff options
context:
space:
mode:
authorMadhuparna Bhowmik <madhuparnabhowmik10@gmail.com>2020-07-12 18:40:03 +0530
committerPaul E. McKenney <paulmck@kernel.org>2020-08-24 18:36:23 -0700
commitdf9a30fd1f70a757df193acd7396622eee23e527 (patch)
tree01430941a1caf102c13e3aa3d8ccffa0c9808446 /arch/x86/kvm/mmu/page_track.c
parentae2212a7216b674633bdc3bd2e24947a0665efb8 (diff)
downloadlinux-df9a30fd1f70a757df193acd7396622eee23e527.tar.gz
linux-df9a30fd1f70a757df193acd7396622eee23e527.tar.bz2
linux-df9a30fd1f70a757df193acd7396622eee23e527.zip
kvm: mmu: page_track: Fix RCU list API usage
Use hlist_for_each_entry_srcu() instead of hlist_for_each_entry_rcu() as it also checkes if the right lock is held. Using hlist_for_each_entry_rcu() with a condition argument will not report the cases where a SRCU protected list is traversed using rcu_read_lock(). Hence, use hlist_for_each_entry_srcu(). Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Cc: <kvm@vger.kernel.org>
Diffstat (limited to 'arch/x86/kvm/mmu/page_track.c')
-rw-r--r--arch/x86/kvm/mmu/page_track.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu/page_track.c b/arch/x86/kvm/mmu/page_track.c
index a84a141a2ad2..8443a675715b 100644
--- a/arch/x86/kvm/mmu/page_track.c
+++ b/arch/x86/kvm/mmu/page_track.c
@@ -229,7 +229,8 @@ void kvm_page_track_write(struct kvm_vcpu *vcpu, gpa_t gpa, const u8 *new,
return;
idx = srcu_read_lock(&head->track_srcu);
- hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
+ hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
+ srcu_read_lock_held(&head->track_srcu))
if (n->track_write)
n->track_write(vcpu, gpa, new, bytes, n);
srcu_read_unlock(&head->track_srcu, idx);
@@ -254,7 +255,8 @@ void kvm_page_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot)
return;
idx = srcu_read_lock(&head->track_srcu);
- hlist_for_each_entry_rcu(n, &head->track_notifier_list, node)
+ hlist_for_each_entry_srcu(n, &head->track_notifier_list, node,
+ srcu_read_lock_held(&head->track_srcu))
if (n->track_flush_slot)
n->track_flush_slot(kvm, slot, n);
srcu_read_unlock(&head->track_srcu, idx);