* [avpatel:riscv_iommu_irqbypass_v2 16/18] arch/riscv/kvm/aia_imsic.c:837:2: warning: variable 'vcpu' is used uninitialized whenever 'if' condition is false
@ 2026-04-30 14:27 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-04-30 14:27 UTC (permalink / raw)
To: Andrew Jones; +Cc: llvm, oe-kbuild-all, Anup Patel
tree: https://github.com/avpatel/linux.git riscv_iommu_irqbypass_v2
head: 0ba166d111b762ae8f37075ba1266e345ae5ef59
commit: 0ae68ded2664be53f2e34c2be7b639b6b2ef711f [16/18] RISC-V: KVM: Add guest file irqbypass support
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20260430/202604302258.1VWlHeHH-lkp@intel.com/config)
compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 5bac06718f502014fade905512f1d26d578a18f3)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260430/202604302258.1VWlHeHH-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202604302258.1VWlHeHH-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> arch/riscv/kvm/aia_imsic.c:837:2: warning: variable 'vcpu' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
837 | kvm_for_each_vcpu(tmp, vcpu, kvm) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/kvm_host.h:1012:6: note: expanded from macro 'kvm_for_each_vcpu'
1012 | if (atomic_read(&kvm->online_vcpus)) \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/riscv/kvm/aia_imsic.c:841:7: note: uninitialized use occurs here
841 | if (!vcpu)
| ^~~~
arch/riscv/kvm/aia_imsic.c:837:2: note: remove the 'if' if its condition is always true
837 | kvm_for_each_vcpu(tmp, vcpu, kvm) {
| ^
include/linux/kvm_host.h:1012:2: note: expanded from macro 'kvm_for_each_vcpu'
1012 | if (atomic_read(&kvm->online_vcpus)) \
| ^
arch/riscv/kvm/aia_imsic.c:804:23: note: initialize the variable 'vcpu' to silence this warning
804 | struct kvm_vcpu *vcpu;
| ^
| = NULL
1 warning generated.
vim +837 arch/riscv/kvm/aia_imsic.c
793
794 void kvm_arch_update_irqfd_routing(struct kvm_kernel_irqfd *irqfd,
795 struct kvm_kernel_irq_routing_entry *old,
796 struct kvm_kernel_irq_routing_entry *new)
797 {
798 struct riscv_iommu_ir_vcpu_info vcpu_info;
799 struct kvm *kvm = irqfd->kvm;
800 struct kvm_aia *aia = &kvm->arch.aia;
801 int host_irq = irqfd->producer->irq;
802 struct irq_data *irqdata = irq_get_irq_data(host_irq);
803 unsigned long tmp, flags;
804 struct kvm_vcpu *vcpu;
805 struct imsic *imsic;
806 struct msi_msg msg;
807 u64 msi_addr_mask;
808 gpa_t target;
809 int ret;
810
811 if (old && old->type == KVM_IRQ_ROUTING_MSI &&
812 new && new->type == KVM_IRQ_ROUTING_MSI &&
813 !memcmp(&old->msi, &new->msi, sizeof(new->msi)))
814 return;
815
816 if (!new) {
817 if (!WARN_ON_ONCE(!old) && old->type == KVM_IRQ_ROUTING_MSI) {
818 ret = irq_set_vcpu_affinity(host_irq, NULL);
819 WARN_ON_ONCE(ret && ret != -EOPNOTSUPP);
820 }
821 return;
822 }
823
824 if (new->type != KVM_IRQ_ROUTING_MSI)
825 return;
826
827 target = ((gpa_t)new->msi.address_hi << 32) | new->msi.address_lo;
828 if (WARN_ON_ONCE(target & (IMSIC_MMIO_PAGE_SZ - 1)))
829 return;
830
831 msg = (struct msi_msg){
832 .address_hi = new->msi.address_hi,
833 .address_lo = new->msi.address_lo,
834 .data = new->msi.data,
835 };
836
> 837 kvm_for_each_vcpu(tmp, vcpu, kvm) {
838 if (target == vcpu->arch.aia_context.imsic_addr)
839 break;
840 }
841 if (!vcpu)
842 return;
843
844 msi_addr_mask = kvm_riscv_aia_msi_addr_mask(aia);
845 vcpu_info = (struct riscv_iommu_ir_vcpu_info){
846 .gpa = target,
847 .msi_addr_mask = msi_addr_mask,
848 .msi_addr_pattern = (target >> IMSIC_MMIO_PAGE_SHIFT) & ~msi_addr_mask,
849 .group_index_bits = aia->nr_group_bits,
850 .group_index_shift = aia->nr_group_shift,
851 };
852
853 imsic = vcpu->arch.aia_context.imsic_state;
854
855 read_lock_irqsave(&imsic->vsfile_lock, flags);
856
857 if (WARN_ON_ONCE(imsic->vsfile_cpu < 0))
858 goto out;
859
860 vcpu_info.hpa = imsic->vsfile_pa;
861
862 ret = irq_set_vcpu_affinity(host_irq, &vcpu_info);
863 WARN_ON_ONCE(ret && ret != -EOPNOTSUPP);
864 if (ret)
865 goto out;
866
867 irq_data_get_irq_chip(irqdata)->irq_write_msi_msg(irqdata, &msg);
868
869 out:
870 read_unlock_irqrestore(&imsic->vsfile_lock, flags);
871 }
872
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-04-30 14:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 14:27 [avpatel:riscv_iommu_irqbypass_v2 16/18] arch/riscv/kvm/aia_imsic.c:837:2: warning: variable 'vcpu' is used uninitialized whenever 'if' condition is false kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox