Skip to content

Commit 1912c5d

Browse files
committed
KVM: WARN if *any* MMU invalidation sequence doesn't add a range
Tweak the assertion in kvm_mmu_invalidate_end() to unconditionally require a range to be added between start() and end(). Asserting if and only if kvm->mmu_invalidate_in_progress is non-zero makes the assertion all but useless as it would fire only when there are multiple invalidations in flight, which is not common and would also get a false negative if one or more sequences, but not all, added a range. Reported-by: Binbin Wu <binbin.wu@linux.intel.com> Fixes: 145725d1542a ("KVM: Use gfn instead of hva for mmu_notifier_retry") Link: https://lore.kernel.org/r/20230921203331.3746712-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 9361444 commit 1912c5d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

virt/kvm/kvm_main.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,11 +873,10 @@ void kvm_mmu_invalidate_end(struct kvm *kvm)
873873
KVM_BUG_ON(kvm->mmu_invalidate_in_progress < 0, kvm);
874874

875875
/*
876-
* Assert that at least one range must be added between start() and
877-
* end(). Not adding a range isn't fatal, but it is a KVM bug.
876+
* Assert that at least one range was added between start() and end().
877+
* Not adding a range isn't fatal, but it is a KVM bug.
878878
*/
879-
WARN_ON_ONCE(kvm->mmu_invalidate_in_progress &&
880-
kvm->mmu_invalidate_range_start == INVALID_GPA);
879+
WARN_ON_ONCE(kvm->mmu_invalidate_range_start == INVALID_GPA);
881880
}
882881

883882
static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn,

0 commit comments

Comments
 (0)