Skip to content

Commit eddd9e8

Browse files
committed
KVM: x86/mmu: Replace comment with an actual lockdep assertion on mmu_lock
Assert that mmu_lock is held for write in __walk_slot_rmaps() instead of hoping the function comment will magically prevent introducing bugs. Signed-off-by: Ben Gardon <bgardon@google.com> Link: https://lore.kernel.org/r/20230202182809.1929122-3-bgardon@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 727ae37 commit eddd9e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/mmu/mmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5906,7 +5906,6 @@ typedef bool (*slot_rmaps_handler) (struct kvm *kvm,
59065906
struct kvm_rmap_head *rmap_head,
59075907
const struct kvm_memory_slot *slot);
59085908

5909-
/* The caller should hold mmu-lock before calling this function. */
59105909
static __always_inline bool __walk_slot_rmaps(struct kvm *kvm,
59115910
const struct kvm_memory_slot *slot,
59125911
slot_rmaps_handler fn,
@@ -5916,6 +5915,8 @@ static __always_inline bool __walk_slot_rmaps(struct kvm *kvm,
59165915
{
59175916
struct slot_rmap_walk_iterator iterator;
59185917

5918+
lockdep_assert_held_write(&kvm->mmu_lock);
5919+
59195920
for_each_slot_rmap_range(slot, start_level, end_level, start_gfn,
59205921
end_gfn, &iterator) {
59215922
if (iterator.rmap)

0 commit comments

Comments
 (0)