All of lore.kernel.org
 help / color / mirror / Atom feed
* [jgunthorpe:iommu_pt_all 41/56] drivers/iommu/generic_pt/fmt/../iommu_pt.h:735 __cut_mapping() warn: continue to end of do { ... } while(0); loop
@ 2025-09-01 10:59 ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-08-30  5:35 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Jason Gunthorpe <jgg@nvidia.com>

tree:   https://github.com/jgunthorpe/linux iommu_pt_all
head:   451e6e58d3fc7e3c1eb9a6d5bfb5d5da4b088133
commit: e3440a4e2ef96292c91a870405399bfcc197e973 [41/56] iommupt: Add cut_mapping op
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
config: powerpc-randconfig-r072-20250830 (https://download.01.org/0day-ci/archive/20250830/202508301321.c3GXwQnF-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project ac23f7465eedd0dd565ffb201f573e7a69695fa3)

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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202508301321.c3GXwQnF-lkp@intel.com/

New smatch warnings:
drivers/iommu/generic_pt/fmt/../iommu_pt.h:735 __cut_mapping() warn: continue to end of do { ... } while(0); loop

Old smatch warnings:
drivers/iommu/generic_pt/fmt/../pt_defs.h:224 pt_feature() warn: bitwise AND condition is false here
drivers/iommu/generic_pt/fmt/../iommu_pt.h:180 pt_iommu_armv7s_iova_to_phys() warn: sizeof(NUMBER)?
drivers/iommu/generic_pt/fmt/../iommu_pt.h:321 armv7s_set_dirty() warn: sizeof(NUMBER)?
drivers/iommu/generic_pt/fmt/../iommu_pt.h:745 __cut_mapping() warn: continue to end of do { ... } while(0); loop
drivers/iommu/generic_pt/fmt/../iommu_pt.h:771 armv7s_cut_mapping() warn: sizeof(NUMBER)?
drivers/iommu/generic_pt/fmt/../iommu_pt.h:1054 increase_top() error: uninitialized symbol 'table_mem'.
drivers/iommu/generic_pt/fmt/../iommu_pt.h:1054 increase_top() error: uninitialized symbol 'new_level'.
drivers/iommu/generic_pt/fmt/../iommu_pt.h:1003 increase_top() warn: missing unwind goto?
drivers/iommu/generic_pt/fmt/../iommu_pt.h:1414 pt_init_common() warn: bitwise AND condition is false here

vim +735 drivers/iommu/generic_pt/fmt/../iommu_pt.h

e3440a4e2ef962 Jason Gunthorpe 2025-04-03  710  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  711  static int __cut_mapping(struct pt_range *range, void *arg, unsigned int level,
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  712  			 struct pt_table_p *table)
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  713  {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  714  	struct pt_state pts = pt_init(range, level, table);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  715  	const struct pt_write_attrs *cut_attrs = arg;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  716  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  717  	do {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  718  		switch (pt_load_single_entry(&pts)) {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  719  		case PT_ENTRY_EMPTY:
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  720  			return -ENOENT;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  721  		case PT_ENTRY_TABLE:
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  722  			return pt_descend(&pts, arg, __cut_mapping);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  723  		case PT_ENTRY_OA: {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  724  			int ret;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  725  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  726  			/* This entry's OA starts at the cut point, all done */
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  727  			if (!log2_mod(range->va, pt_entry_oa_lg2sz(&pts)))
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  728  				return 0;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  729  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  730  			/* This is a contiguous entry, split it down */
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  731  			if (pt_entry_num_contig_lg2(&pts) != ilog2(1)) {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  732  				if (!pts_feature(&pts, PT_FEAT_OA_SIZE_CHANGE))
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  733  					return -EOPNOTSUPP;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  734  				replace_contiguous_entry(&pts);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03 @735  				continue;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  736  			}
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  737  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  738  			/*
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  739  			 * Need to replace an OA with a table. The new table
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  740  			 * will map the same OA as the table item, just with
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  741  			 * smaller granularity.
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  742  			 */
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  743  			ret = replace_cut_table(&pts, cut_attrs);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  744  			if (ret == -EAGAIN)
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  745  				continue;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  746  			return ret;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  747  		}
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  748  		}
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  749  	} while (false);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  750  	return -ENOENT;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  751  }
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  752  

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [jgunthorpe:iommu_pt_all 41/56] drivers/iommu/generic_pt/fmt/../iommu_pt.h:735 __cut_mapping() warn: continue to end of do { ... } while(0); loop
@ 2025-09-01 10:59 ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-09-01 10:59 UTC (permalink / raw)
  To: oe-kbuild, Jason Gunthorpe; +Cc: lkp, oe-kbuild-all

tree:   https://github.com/jgunthorpe/linux iommu_pt_all
head:   451e6e58d3fc7e3c1eb9a6d5bfb5d5da4b088133
commit: e3440a4e2ef96292c91a870405399bfcc197e973 [41/56] iommupt: Add cut_mapping op
config: powerpc-randconfig-r072-20250830 (https://download.01.org/0day-ci/archive/20250830/202508301321.c3GXwQnF-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project ac23f7465eedd0dd565ffb201f573e7a69695fa3)

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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202508301321.c3GXwQnF-lkp@intel.com/

New smatch warnings:
drivers/iommu/generic_pt/fmt/../iommu_pt.h:735 __cut_mapping() warn: continue to end of do { ... } while(0); loop

vim +735 drivers/iommu/generic_pt/fmt/../iommu_pt.h

e3440a4e2ef962 Jason Gunthorpe 2025-04-03  711  static int __cut_mapping(struct pt_range *range, void *arg, unsigned int level,
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  712  			 struct pt_table_p *table)
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  713  {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  714  	struct pt_state pts = pt_init(range, level, table);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  715  	const struct pt_write_attrs *cut_attrs = arg;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  716  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  717  	do {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  718  		switch (pt_load_single_entry(&pts)) {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  719  		case PT_ENTRY_EMPTY:
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  720  			return -ENOENT;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  721  		case PT_ENTRY_TABLE:
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  722  			return pt_descend(&pts, arg, __cut_mapping);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  723  		case PT_ENTRY_OA: {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  724  			int ret;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  725  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  726  			/* This entry's OA starts at the cut point, all done */
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  727  			if (!log2_mod(range->va, pt_entry_oa_lg2sz(&pts)))
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  728  				return 0;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  729  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  730  			/* This is a contiguous entry, split it down */
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  731  			if (pt_entry_num_contig_lg2(&pts) != ilog2(1)) {
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  732  				if (!pts_feature(&pts, PT_FEAT_OA_SIZE_CHANGE))
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  733  					return -EOPNOTSUPP;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  734  				replace_contiguous_entry(&pts);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03 @735  				continue;

This continue would be more readable as a return -ENOENT;

e3440a4e2ef962 Jason Gunthorpe 2025-04-03  736  			}
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  737  
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  738  			/*
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  739  			 * Need to replace an OA with a table. The new table
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  740  			 * will map the same OA as the table item, just with
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  741  			 * smaller granularity.
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  742  			 */
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  743  			ret = replace_cut_table(&pts, cut_attrs);
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  744  			if (ret == -EAGAIN)
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  745  				continue;

Yeah.  continue wasn't intended...  

e3440a4e2ef962 Jason Gunthorpe 2025-04-03  746  			return ret;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  747  		}
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  748  		}
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  749  	} while (false);
                                                          ^^^^^^^^^^^^^^

e3440a4e2ef962 Jason Gunthorpe 2025-04-03  750  	return -ENOENT;
e3440a4e2ef962 Jason Gunthorpe 2025-04-03  751  }

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [jgunthorpe:iommu_pt_all 41/56] drivers/iommu/generic_pt/fmt/../iommu_pt.h:735 __cut_mapping() warn: continue to end of do { ... } while(0); loop
  2025-09-01 10:59 ` Dan Carpenter
  (?)
@ 2025-09-02 16:46 ` Jason Gunthorpe
  -1 siblings, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2025-09-02 16:46 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all

On Mon, Sep 01, 2025 at 01:59:13PM +0300, Dan Carpenter wrote:
> 
> e3440a4e2ef962 Jason Gunthorpe 2025-04-03  746  			return ret;
> e3440a4e2ef962 Jason Gunthorpe 2025-04-03  747  		}
> e3440a4e2ef962 Jason Gunthorpe 2025-04-03  748  		}
> e3440a4e2ef962 Jason Gunthorpe 2025-04-03  749  	} while (false);
>                                                           ^^^^^^^^^^^^^^

The false was supposed to be true :\ All the continues mark cases
where the structure was changed and we need to rewalk.

Thanks,
Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-02 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-30  5:35 [jgunthorpe:iommu_pt_all 41/56] drivers/iommu/generic_pt/fmt/../iommu_pt.h:735 __cut_mapping() warn: continue to end of do { ... } while(0); loop kernel test robot
2025-09-01 10:59 ` Dan Carpenter
2025-09-02 16:46 ` Jason Gunthorpe

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.