diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2024-03-11 17:23:03 +0300 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2024-03-11 17:23:03 +0300 |
commit | 507e72f899bd5968b6d3bc4f29cc534ada9ee509 (patch) | |
tree | 7b226347f3339082e78a2f7a0b732c250e6cf5f2 /virt | |
parent | a81d95ae8c805cd137d3385ad669b5200b739d0f (diff) | |
parent | ea3689d9df50c283cb5d647a74aa45e2cc3f8064 (diff) | |
download | linux-507e72f899bd5968b6d3bc4f29cc534ada9ee509.tar.xz |
Merge tag 'kvm-x86-generic-6.9' of https://github.com/kvm-x86/linux into HEAD
KVM common MMU changes for 6.9:
- Harden KVM against underflowing the active mmu_notifier invalidation
count, so that "bad" invalidations (usually due to bugs elsehwere in the
kernel) are detected earlier and are less likely to hang the kernel.
- Fix a benign bug in __kvm_mmu_topup_memory_cache() where the object size
and number of objects parameters to kvmalloc_array() were swapped.
Diffstat (limited to 'virt')
-rw-r--r-- | virt/kvm/kvm_main.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 801671150314..741d86ca06a1 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -421,7 +421,7 @@ int __kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int capacity, if (WARN_ON_ONCE(!capacity)) return -EIO; - mc->objects = kvmalloc_array(sizeof(void *), capacity, gfp); + mc->objects = kvmalloc_array(capacity, sizeof(void *), gfp); if (!mc->objects) return -ENOMEM; @@ -890,7 +890,9 @@ static void kvm_mmu_notifier_invalidate_range_end(struct mmu_notifier *mn, /* Pairs with the increment in range_start(). */ spin_lock(&kvm->mn_invalidate_lock); - wake = (--kvm->mn_active_invalidate_count == 0); + if (!WARN_ON_ONCE(!kvm->mn_active_invalidate_count)) + --kvm->mn_active_invalidate_count; + wake = !kvm->mn_active_invalidate_count; spin_unlock(&kvm->mn_invalidate_lock); /* |