arch/arm64/kvm/vgic/vgic-v5.c:231 vgic_v5_sync_ppi_priorities() warn: subtract is higher precedence than shift

kernel test robot <[email protected]> Tue, 21 Jul 2026 17:14:00 +0800
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Sascha Bischoff <[email protected]>
CC: Marc Zyngier <[email protected]>
CC: Joey Gouly <[email protected]>
CC: Jonathan Cameron <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b95f03f04d475aa6719d15a636ddf32222d55657
commit: 933e5288fa9714085e384a3d6ad6dcce8089a6b9 KVM: arm64: gic-v5: Check for pending PPIs
date:   4 months ago
:::::: branch date: 13 hours ago
:::::: commit date: 4 months ago
config: arm64-randconfig-r073-20260721 (https://download.01.org/0day-ci/archive/20260721/[email protected]/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
smatch: v0.5.0-9187-g5189e3fb

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
| Fixes: 933e5288fa97 ("KVM: arm64: gic-v5: Check for pending PPIs")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
arch/arm64/kvm/vgic/vgic-v5.c:231 vgic_v5_sync_ppi_priorities() warn: subtract is higher precedence than shift
arch/arm64/kvm/vgic/vgic-v5.c:231 vgic_v5_sync_ppi_priorities() warn: subtract is higher precedence than shift
arch/arm64/kvm/vgic/vgic-v5.c:231 vgic_v5_sync_ppi_priorities() warn: subtract is higher precedence than shift
arch/arm64/kvm/vgic/vgic-v5.c:231 vgic_v5_sync_ppi_priorities() warn: subtract is higher precedence than shift

vim +231 arch/arm64/kvm/vgic/vgic-v5.c

4d591252bacb2d Sascha Bischoff 2026-03-19  199  
933e5288fa9714 Sascha Bischoff 2026-03-19  200  /*
933e5288fa9714 Sascha Bischoff 2026-03-19  201   * Sync back the PPI priorities to the vgic_irq shadow state for any interrupts
933e5288fa9714 Sascha Bischoff 2026-03-19  202   * exposed to the guest (skipping all others).
933e5288fa9714 Sascha Bischoff 2026-03-19  203   */
933e5288fa9714 Sascha Bischoff 2026-03-19  204  static void vgic_v5_sync_ppi_priorities(struct kvm_vcpu *vcpu)
933e5288fa9714 Sascha Bischoff 2026-03-19  205  {
933e5288fa9714 Sascha Bischoff 2026-03-19  206  	struct vgic_v5_cpu_if *cpu_if = &vcpu->arch.vgic_cpu.vgic_v5;
933e5288fa9714 Sascha Bischoff 2026-03-19  207  	u64 priorityr;
933e5288fa9714 Sascha Bischoff 2026-03-19  208  	int i;
933e5288fa9714 Sascha Bischoff 2026-03-19  209  
933e5288fa9714 Sascha Bischoff 2026-03-19  210  	/*
933e5288fa9714 Sascha Bischoff 2026-03-19  211  	 * We have up to 16 PPI Priority regs, but only have a few interrupts
933e5288fa9714 Sascha Bischoff 2026-03-19  212  	 * that the guest is allowed to use. Limit our sync of PPI priorities to
933e5288fa9714 Sascha Bischoff 2026-03-19  213  	 * those actually exposed to the guest by first iterating over the mask
933e5288fa9714 Sascha Bischoff 2026-03-19  214  	 * of exposed PPIs.
933e5288fa9714 Sascha Bischoff 2026-03-19  215  	 */
933e5288fa9714 Sascha Bischoff 2026-03-19  216  	for_each_set_bit(i, vcpu->kvm->arch.vgic.gicv5_vm.vgic_ppi_mask, VGIC_V5_NR_PRIVATE_IRQS) {
933e5288fa9714 Sascha Bischoff 2026-03-19  217  		u32 intid = vgic_v5_make_ppi(i);
933e5288fa9714 Sascha Bischoff 2026-03-19  218  		struct vgic_irq *irq;
933e5288fa9714 Sascha Bischoff 2026-03-19  219  		int pri_idx, pri_reg, pri_bit;
933e5288fa9714 Sascha Bischoff 2026-03-19  220  		u8 priority;
933e5288fa9714 Sascha Bischoff 2026-03-19  221  
933e5288fa9714 Sascha Bischoff 2026-03-19  222  		/*
933e5288fa9714 Sascha Bischoff 2026-03-19  223  		 * Determine which priority register and the field within it to
933e5288fa9714 Sascha Bischoff 2026-03-19  224  		 * extract.
933e5288fa9714 Sascha Bischoff 2026-03-19  225  		 */
933e5288fa9714 Sascha Bischoff 2026-03-19  226  		pri_reg = i / 8;
933e5288fa9714 Sascha Bischoff 2026-03-19  227  		pri_idx = i % 8;
933e5288fa9714 Sascha Bischoff 2026-03-19  228  		pri_bit = pri_idx * 8;
933e5288fa9714 Sascha Bischoff 2026-03-19  229  
933e5288fa9714 Sascha Bischoff 2026-03-19  230  		priorityr = cpu_if->vgic_ppi_priorityr[pri_reg];
933e5288fa9714 Sascha Bischoff 2026-03-19 @231  		priority = field_get(GENMASK(pri_bit + 4, pri_bit), priorityr);
933e5288fa9714 Sascha Bischoff 2026-03-19  232  
933e5288fa9714 Sascha Bischoff 2026-03-19  233  		irq = vgic_get_vcpu_irq(vcpu, intid);
933e5288fa9714 Sascha Bischoff 2026-03-19  234  
933e5288fa9714 Sascha Bischoff 2026-03-19  235  		scoped_guard(raw_spinlock_irqsave, &irq->irq_lock)
933e5288fa9714 Sascha Bischoff 2026-03-19  236  			irq->priority = priority;
933e5288fa9714 Sascha Bischoff 2026-03-19  237  
933e5288fa9714 Sascha Bischoff 2026-03-19  238  		vgic_put_irq(vcpu->kvm, irq);
933e5288fa9714 Sascha Bischoff 2026-03-19  239  	}
933e5288fa9714 Sascha Bischoff 2026-03-19  240  }
933e5288fa9714 Sascha Bischoff 2026-03-19  241  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki