* [bug report] KVM: x86/mmu: Skip rmap operations if rmaps not allocated
@ 2021-06-25 9:50 Dan Carpenter
2021-07-01 16:33 ` Ben Gardon
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-06-25 9:50 UTC (permalink / raw)
To: bgardon; +Cc: kvm
Hello Ben Gardon,
The patch e2209710ccc5: "KVM: x86/mmu: Skip rmap operations if rmaps
not allocated" from May 18, 2021, leads to the following static
checker warning:
arch/x86/kvm/mmu/mmu.c:5704 kvm_mmu_zap_collapsible_sptes()
error: uninitialized symbol 'flush'.
arch/x86/kvm/mmu/mmu.c
5687 void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
5688 const struct kvm_memory_slot *memslot)
5689 {
5690 /* FIXME: const-ify all uses of struct kvm_memory_slot. */
5691 struct kvm_memory_slot *slot = (struct kvm_memory_slot *)memslot;
5692 bool flush;
^^^^^^^^^^
needs to be "bool flush = false;"
5693
5694 if (kvm_memslots_have_rmaps(kvm)) {
5695 write_lock(&kvm->mmu_lock);
5696 flush = slot_handle_leaf(kvm, slot, kvm_mmu_zap_collapsible_spte, true);
5697 if (flush)
5698 kvm_arch_flush_remote_tlbs_memslot(kvm, slot);
5699 write_unlock(&kvm->mmu_lock);
5700 }
5701
5702 if (is_tdp_mmu_enabled(kvm)) {
5703 read_lock(&kvm->mmu_lock);
5704 flush = kvm_tdp_mmu_zap_collapsible_sptes(kvm, slot, flush);
^^^^^
Unintialized.
5705 if (flush)
5706 kvm_arch_flush_remote_tlbs_memslot(kvm, slot);
5707 read_unlock(&kvm->mmu_lock);
5708 }
5709 }
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] KVM: x86/mmu: Skip rmap operations if rmaps not allocated
2021-06-25 9:50 [bug report] KVM: x86/mmu: Skip rmap operations if rmaps not allocated Dan Carpenter
@ 2021-07-01 16:33 ` Ben Gardon
0 siblings, 0 replies; 2+ messages in thread
From: Ben Gardon @ 2021-07-01 16:33 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kvm
Hi Dan,
Thanks for reporting this. I believe it's already been fixed by "KVM:
x86/mmu: Fix uninitialized boolean variable flush" from Colin King.
On Fri, Jun 25, 2021 at 2:50 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> Hello Ben Gardon,
>
> The patch e2209710ccc5: "KVM: x86/mmu: Skip rmap operations if rmaps
> not allocated" from May 18, 2021, leads to the following static
> checker warning:
>
> arch/x86/kvm/mmu/mmu.c:5704 kvm_mmu_zap_collapsible_sptes()
> error: uninitialized symbol 'flush'.
>
> arch/x86/kvm/mmu/mmu.c
> 5687 void kvm_mmu_zap_collapsible_sptes(struct kvm *kvm,
> 5688 const struct kvm_memory_slot *memslot)
> 5689 {
> 5690 /* FIXME: const-ify all uses of struct kvm_memory_slot. */
> 5691 struct kvm_memory_slot *slot = (struct kvm_memory_slot *)memslot;
> 5692 bool flush;
> ^^^^^^^^^^
> needs to be "bool flush = false;"
>
> 5693
> 5694 if (kvm_memslots_have_rmaps(kvm)) {
> 5695 write_lock(&kvm->mmu_lock);
> 5696 flush = slot_handle_leaf(kvm, slot, kvm_mmu_zap_collapsible_spte, true);
> 5697 if (flush)
> 5698 kvm_arch_flush_remote_tlbs_memslot(kvm, slot);
> 5699 write_unlock(&kvm->mmu_lock);
> 5700 }
> 5701
> 5702 if (is_tdp_mmu_enabled(kvm)) {
> 5703 read_lock(&kvm->mmu_lock);
> 5704 flush = kvm_tdp_mmu_zap_collapsible_sptes(kvm, slot, flush);
> ^^^^^
> Unintialized.
>
> 5705 if (flush)
> 5706 kvm_arch_flush_remote_tlbs_memslot(kvm, slot);
> 5707 read_unlock(&kvm->mmu_lock);
> 5708 }
> 5709 }
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-01 16:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-25 9:50 [bug report] KVM: x86/mmu: Skip rmap operations if rmaps not allocated Dan Carpenter
2021-07-01 16:33 ` Ben Gardon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).