Skip to content

Commit e193149

Browse files
Like Xusean-jc
authored andcommitted
KVM: x86/mmu: Move the lockdep_assert of mmu_lock to inside clear_dirty_pt_masked()
Move the lockdep_assert_held_write(&kvm->mmu_lock) from the only one caller kvm_tdp_mmu_clear_dirty_pt_masked() to inside clear_dirty_pt_masked(). This change makes it more obvious why it's safe for clear_dirty_pt_masked() to use the non-atomic (for non-volatile SPTEs) tdp_mmu_clear_spte_bits() helper. for_each_tdp_mmu_root() does its own lockdep, so the only "loss" in lockdep coverage is if the list is completely empty. Suggested-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Like Xu <likexu@tencent.com> Link: https://lore.kernel.org/r/20230627042639.12636-1-likexu@tencent.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent fdf0eaf commit e193149

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,8 @@ static void clear_dirty_pt_masked(struct kvm *kvm, struct kvm_mmu_page *root,
16001600
shadow_dirty_mask;
16011601
struct tdp_iter iter;
16021602

1603+
lockdep_assert_held_write(&kvm->mmu_lock);
1604+
16031605
rcu_read_lock();
16041606

16051607
tdp_root_for_each_leaf_pte(iter, root, gfn + __ffs(mask),
@@ -1646,7 +1648,6 @@ void kvm_tdp_mmu_clear_dirty_pt_masked(struct kvm *kvm,
16461648
{
16471649
struct kvm_mmu_page *root;
16481650

1649-
lockdep_assert_held_write(&kvm->mmu_lock);
16501651
for_each_tdp_mmu_root(kvm, root, slot->as_id)
16511652
clear_dirty_pt_masked(kvm, root, gfn, mask, wrprot);
16521653
}

0 commit comments

Comments
 (0)