Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Andrew Jones <ajones@ventanamicro.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	Anup Patel <anup@brainfault.org>
Subject: [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
Date: Thu, 30 Apr 2026 22:27:25 +0800	[thread overview]
Message-ID: <202604302258.1VWlHeHH-lkp@intel.com> (raw)

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

                 reply	other threads:[~2026-04-30 14:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202604302258.1VWlHeHH-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=ajones@ventanamicro.com \
    --cc=anup@brainfault.org \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox