All of lore.kernel.org
 help / color / mirror / Atom feed
* [avpatel:riscv_trace_support_v5 62/108] arch/riscv/kvm/aia_imsic.c:919:2: warning: variable 'vcpu' is used uninitialized whenever 'if' condition is false
@ 2026-08-20  7:29 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-08-20  7:29 UTC (permalink / raw)
  To: Andrew Jones; +Cc: oe-kbuild-all, Anup Patel

tree:   https://github.com/avpatel/linux.git riscv_trace_support_v5
head:   e58ea3f194d326370813c549a76ecdfa211a4768
commit: ccdd3c493dc8ce3acb64600af8437ebb28775ceb [62/108] RISC-V: KVM: Add guest file irqbypass support
config: riscv-randconfig-r061-20260820 (https://download.01.org/0day-ci/archive/20260820/202608201527.Z1qup2jT-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 935bfc708590c60147a79c7df145bb6e68b1d388)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260820/202608201527.Z1qup2jT-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/202608201527.Z1qup2jT-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> arch/riscv/kvm/aia_imsic.c:919:2: warning: variable 'vcpu' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
     919 |         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:923:7: note: uninitialized use occurs here
     923 |         if (!vcpu)
         |              ^~~~
   arch/riscv/kvm/aia_imsic.c:919:2: note: remove the 'if' if its condition is always true
     919 |         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:883:23: note: initialize the variable 'vcpu' to silence this warning
     883 |         struct kvm_vcpu *vcpu;
         |                              ^
         |                               = NULL
   1 warning generated.


vim +919 arch/riscv/kvm/aia_imsic.c

   872	
   873	void kvm_arch_update_irqfd_routing(struct kvm_kernel_irqfd *irqfd,
   874					   struct kvm_kernel_irq_routing_entry *old,
   875					   struct kvm_kernel_irq_routing_entry *new)
   876	{
   877		struct riscv_iommu_ir_vcpu_info vcpu_info;
   878		struct kvm *kvm = irqfd->kvm;
   879		struct kvm_aia *aia = &kvm->arch.aia;
   880		int host_irq;
   881		struct irq_data *irqdata;
   882		unsigned long tmp, flags;
   883		struct kvm_vcpu *vcpu;
   884		struct imsic *imsic;
   885		struct msi_msg msg;
   886		u64 msi_addr_mask;
   887		gpa_t target;
   888		int ret;
   889	
   890		host_irq = irqfd->producer->irq;
   891		irqdata = irq_get_irq_data(host_irq);
   892	
   893		if (old && old->type == KVM_IRQ_ROUTING_MSI &&
   894		    new && new->type == KVM_IRQ_ROUTING_MSI &&
   895		    !memcmp(&old->msi, &new->msi, sizeof(new->msi)))
   896			return;
   897	
   898		if (!new) {
   899			if (!WARN_ON_ONCE(!old) && old->type == KVM_IRQ_ROUTING_MSI) {
   900				ret = irq_set_vcpu_affinity(host_irq, NULL);
   901				WARN_ON_ONCE(ret && ret != -EOPNOTSUPP);
   902			}
   903			return;
   904		}
   905	
   906		if (new->type != KVM_IRQ_ROUTING_MSI)
   907			return;
   908	
   909		target = ((gpa_t)new->msi.address_hi << 32) | new->msi.address_lo;
   910		if (WARN_ON_ONCE(target & (IMSIC_MMIO_PAGE_SZ - 1)))
   911			return;
   912	
   913		msg = (struct msi_msg){
   914			.address_hi = new->msi.address_hi,
   915			.address_lo = new->msi.address_lo,
   916			.data = new->msi.data,
   917		};
   918	
 > 919		kvm_for_each_vcpu(tmp, vcpu, kvm) {
   920			if (target == vcpu->arch.aia_context.imsic_addr)
   921				break;
   922		}
   923		if (!vcpu)
   924			return;
   925	
   926		msi_addr_mask = kvm_riscv_aia_msi_addr_mask(aia);
   927		vcpu_info = (struct riscv_iommu_ir_vcpu_info){
   928			.gpa = target,
   929			.msi_addr_mask = msi_addr_mask,
   930			.msi_addr_pattern = (target >> IMSIC_MMIO_PAGE_SHIFT) & ~msi_addr_mask,
   931			.group_index_bits = aia->nr_group_bits,
   932			.group_index_shift = aia->nr_group_shift,
   933		};
   934	
   935		imsic = vcpu->arch.aia_context.imsic_state;
   936	
   937		read_lock_irqsave(&imsic->vsfile_lock, flags);
   938	
   939		if (imsic->vsfile_cpu < 0)
   940			goto out;
   941	
   942		vcpu_info.hpa = imsic->vsfile_pa;
   943	
   944		ret = irq_set_vcpu_affinity(host_irq, &vcpu_info);
   945		WARN_ON_ONCE(ret && ret != -EOPNOTSUPP);
   946		if (ret)
   947			goto out;
   948	
   949		/*
   950		 * Unlike x86 (which updates the IRTE) and arm64 (which updates
   951		 * the ITS ITTE), RISC-V reprograms the device MSI target address
   952		 * to the guest IMSIC GPA. The device writes to the guest GPA;
   953		 * the IOMMU MSI table maps guest GPA -> host VS-file HPA.
   954		 */
   955		irq_data_get_irq_chip(irqdata)->irq_write_msi_msg(irqdata, &msg);
   956	
   957	out:
   958		read_unlock_irqrestore(&imsic->vsfile_lock, flags);
   959	}
   960	

--
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-08-20  7:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20  7:29 [avpatel:riscv_trace_support_v5 62/108] arch/riscv/kvm/aia_imsic.c:919:2: warning: variable 'vcpu' is used uninitialized whenever 'if' condition is false kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.