CC: l...@lists.linux.dev CC: kbuild-...@lists.01.org BCC: l...@intel.com CC: linux-ker...@vger.kernel.org TO: Christoph Hellwig <h...@lst.de> CC: Konrad Rzeszutek Wilk <konrad.w...@oracle.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: aad611a868d16cdc16a7d4a764cef955293e47e3 commit: cbce99527ca7c4e98db9890651d5e9dfc2fb89ac xen-swiotlb: remove xen_io_tlb_start and xen_io_tlb_nslabs date: 12 months ago :::::: branch date: 8 hours ago :::::: commit date: 12 months ago config: x86_64-randconfig-c007-20220307 (https://download.01.org/0day-ci/archive/20220313/202203131004.v1tji5ps-...@intel.com/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d271fc04d5b97b12e6b797c6067d3c96a8d7470e) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cbce99527ca7c4e98db9890651d5e9dfc2fb89ac git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git fetch --no-tags linus master git checkout cbce99527ca7c4e98db9890651d5e9dfc2fb89ac # save the config file to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <l...@intel.com> clang-analyzer warnings: (new ones prefixed by >>) ^ include/trace/events/ext4.h:22:24: note: expanded from macro 'EXT4_I' #define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) ^ include/linux/kernel.h:709:2: note: expanded from macro 'container_of' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^ include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^ include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) ^ include/linux/compiler_types.h:300:3: note: expanded from macro '__compiletime_assert' if (!(condition)) \ ^ fs/ext4/extents_status.c:1181:36: note: Loop condition is false. Exiting loop struct ext4_pending_tree *tree = &EXT4_I(inode)->i_pending_tree; ^ include/trace/events/ext4.h:22:24: note: expanded from macro 'EXT4_I' #define EXT4_I(inode) (container_of(inode, struct ext4_inode_info, vfs_inode)) ^ include/linux/kernel.h:709:2: note: expanded from macro 'container_of' BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) && \ ^ include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^ include/linux/compiler_types.h:320:2: note: expanded from macro 'compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^ include/linux/compiler_types.h:308:2: note: expanded from macro '_compiletime_assert' __compiletime_assert(condition, msg, prefix, suffix) ^ include/linux/compiler_types.h:298:2: note: expanded from macro '__compiletime_assert' do { \ ^ fs/ext4/extents_status.c:1187:6: note: Assuming field 's_cluster_ratio' is > 1 if (sbi->s_cluster_ratio > 1) { ^~~~~~~~~~~~~~~~~~~~~~~~ fs/ext4/extents_status.c:1187:2: note: Taking true branch if (sbi->s_cluster_ratio > 1) { ^ fs/ext4/extents_status.c:1189:7: note: Branch condition evaluates to a garbage value if (rc->partial) ^~~~~~~~~~~ Suppressed 6 warnings (6 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. arch/x86/include/asm/xen/hypercall.h:364:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] return _hypercall2(int, xen_version, cmd, arg); ^ arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2' __HYPERCALL_DECLS; \ ^ arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS' register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \ ^ drivers/xen/sys-hypervisor.c:361:8: note: Calling 'HYPERVISOR_xen_version' ret = HYPERVISOR_xen_version(XENVER_build_id, NULL); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/include/asm/xen/hypercall.h:364:9: note: Assigned value is garbage or undefined return _hypercall2(int, xen_version, cmd, arg); ^ arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2' __HYPERCALL_DECLS; \ ^~~~~~~~~~~~~~~~~ arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS' register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \ ^ ~~~~~~ arch/x86/include/asm/xen/hypercall.h:435:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] return _hypercall2(int, xenpmu_op, op, arg); ^ arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2' __HYPERCALL_DECLS; \ ^ arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS' register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \ ^ drivers/xen/sys-hypervisor.c:493:8: note: Calling 'HYPERVISOR_xenpmu_op' ret = HYPERVISOR_xenpmu_op(XENPMU_feature_get, &xp); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arch/x86/include/asm/xen/hypercall.h:435:9: note: Assigned value is garbage or undefined return _hypercall2(int, xenpmu_op, op, arg); ^ arch/x86/include/asm/xen/hypercall.h:169:2: note: expanded from macro '_hypercall2' __HYPERCALL_DECLS; \ ^~~~~~~~~~~~~~~~~ arch/x86/include/asm/xen/hypercall.h:113:2: note: expanded from macro '__HYPERCALL_DECLS' register unsigned long __arg1 asm(__HYPERCALL_ARG1REG) = __arg1; \ ^ ~~~~~~ Suppressed 3 warnings (3 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (3 in non-user code, 2 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 7 warnings generated. >> drivers/xen/swiotlb-xen.c:206:6: warning: Branch condition evaluates to a >> garbage value [clang-analyzer-core.uninitialized.Branch] if (!start) { ^~~~~~ drivers/xen/swiotlb-xen.c:165:2: note: 'start' declared without an initial value char *start; ^~~~~~~~~~~ drivers/xen/swiotlb-xen.c:170:6: note: Assuming 'nslabs' is not equal to 0 if (!nslabs) ^~~~~~~ drivers/xen/swiotlb-xen.c:170:2: note: Taking false branch if (!nslabs) ^ drivers/xen/swiotlb-xen.c:178:6: note: Assuming 'io_tlb_start' is equal to 0 if (io_tlb_start != 0) ^~~~~~~~~~~~~~~~~ drivers/xen/swiotlb-xen.c:178:2: note: Taking false branch if (io_tlb_start != 0) ^ drivers/xen/swiotlb-xen.c:184:6: note: Assuming 'early' is false if (early) { ^~~~~ drivers/xen/swiotlb-xen.c:184:2: note: Taking false branch if (early) { ^ drivers/xen/swiotlb-xen.c:193:10: note: Assuming the condition is false while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/xen/swiotlb-xen.c:193:3: note: Loop condition is false. Execution continues on line 199 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) { ^ drivers/xen/swiotlb-xen.c:199:7: note: Assuming the condition is false if (order != get_order(bytes)) { ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/xen/swiotlb-xen.c:199:3: note: Taking false branch if (order != get_order(bytes)) { ^ drivers/xen/swiotlb-xen.c:206:6: note: Branch condition evaluates to a garbage value if (!start) { ^~~~~~ include/linux/dma-direct.h:81:6: warning: Access to field 'dma_range_map' results in a dereference of a null pointer (loaded from variable 'dev') [clang-analyzer-core.NullDereference] if (dev->dma_range_map) ^ drivers/xen/swiotlb-xen.c:319:17: note: 32 is not equal to 64 u64 dma_mask = DMA_BIT_MASK(32); ^ include/linux/dma-mapping.h:76:27: note: expanded from macro 'DMA_BIT_MASK' #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) ^~~ drivers/xen/swiotlb-xen.c:319:17: note: '?' condition is false u64 dma_mask = DMA_BIT_MASK(32); ^ include/linux/dma-mapping.h:76:26: note: expanded from macro 'DMA_BIT_MASK' #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) ^ drivers/xen/swiotlb-xen.c:322:6: note: Assuming 'hwdev' is null if (hwdev && hwdev->coherent_dma_mask) ^~~~~ drivers/xen/swiotlb-xen.c:322:12: note: Left side of '&&' is false if (hwdev && hwdev->coherent_dma_mask) ^ drivers/xen/swiotlb-xen.c:327:25: note: Passing null pointer value via 1st parameter 'dev' phys = xen_dma_to_phys(hwdev, dev_addr); ^~~~~ drivers/xen/swiotlb-xen.c:327:9: note: Calling 'xen_dma_to_phys' phys = xen_dma_to_phys(hwdev, dev_addr); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/xen/swiotlb-xen.c:75:42: note: Passing null pointer value via 1st parameter 'dev' return xen_bus_to_phys(dev, dma_to_phys(dev, dma_addr)); ^~~ drivers/xen/swiotlb-xen.c:75:30: note: Calling 'dma_to_phys' return xen_bus_to_phys(dev, dma_to_phys(dev, dma_addr)); ^~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/dma-direct.h:81:6: note: Access to field 'dma_range_map' results in a dereference of a null pointer (loaded from variable 'dev') if (dev->dma_range_map) ^~~ Suppressed 5 warnings (3 in non-user code, 2 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 3 warnings generated. drivers/acpi/acpica/dbutils.c:298:3: warning: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 [clang-analyzer-security.insecureAPI.strcpy] strcpy(buffer, "0"); ^~~~~~ drivers/acpi/acpica/dbutils.c:298:3: note: Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119 strcpy(buffer, "0"); ^~~~~~ Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 4 warnings generated. Suppressed 4 warnings (4 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. arch/x86/include/asm/paravirt.h:648:9: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign] return PVOP_CALLEE0(unsigned long, irq.save_fl); ^ arch/x86/include/asm/paravirt_types.h:553:2: note: expanded from macro 'PVOP_CALLEE0' __PVOP_CALLEESAVE(rettype, op, "", "") vim +206 drivers/xen/swiotlb-xen.c 4035b43da6daa5 Christoph Hellwig 2021-03-01 158 b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 159 int __ref xen_swiotlb_init(int verbose, bool early) b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 160 { b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 161 unsigned long bytes, order; f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 162 int rc = -ENOMEM; 5bab7864b1167f Konrad Rzeszutek Wilk 2012-08-23 163 enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN; f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 164 unsigned int repeat = 3; cbce99527ca7c4 Christoph Hellwig 2021-03-01 165 char *start; cbce99527ca7c4 Christoph Hellwig 2021-03-01 166 unsigned long nslabs; b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 167 cbce99527ca7c4 Christoph Hellwig 2021-03-01 168 nslabs = swiotlb_nr_tbl(); f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 169 retry: cbce99527ca7c4 Christoph Hellwig 2021-03-01 170 if (!nslabs) cbce99527ca7c4 Christoph Hellwig 2021-03-01 171 nslabs = DEFAULT_NSLABS; cbce99527ca7c4 Christoph Hellwig 2021-03-01 172 bytes = nslabs << IO_TLB_SHIFT; 4035b43da6daa5 Christoph Hellwig 2021-03-01 173 order = get_order(bytes); 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 174 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 175 /* 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 176 * IO TLB memory already allocated. Just use it. 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 177 */ cbce99527ca7c4 Christoph Hellwig 2021-03-01 178 if (io_tlb_start != 0) 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 179 goto end; 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 180 b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 181 /* b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 182 * Get IO TLB memory from any location. b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 183 */ 8a7f97b902f4fb Mike Rapoport 2019-03-11 184 if (early) { cbce99527ca7c4 Christoph Hellwig 2021-03-01 185 start = memblock_alloc(PAGE_ALIGN(bytes), 15c3c114ed144e Mike Rapoport 2018-10-30 186 PAGE_SIZE); cbce99527ca7c4 Christoph Hellwig 2021-03-01 187 if (!start) 8a7f97b902f4fb Mike Rapoport 2019-03-11 188 panic("%s: Failed to allocate %lu bytes align=0x%lx\n", 8a7f97b902f4fb Mike Rapoport 2019-03-11 189 __func__, PAGE_ALIGN(bytes), PAGE_SIZE); 8a7f97b902f4fb Mike Rapoport 2019-03-11 190 } else { b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 191 #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT)) b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 192 #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT) b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 193 while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) { cbce99527ca7c4 Christoph Hellwig 2021-03-01 194 start = (void *)xen_get_swiotlb_free_pages(order); cbce99527ca7c4 Christoph Hellwig 2021-03-01 195 if (start) b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 196 break; b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 197 order--; b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 198 } b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 199 if (order != get_order(bytes)) { 283c0972d53769 Joe Perches 2013-06-28 200 pr_warn("Warning: only able to allocate %ld MB for software IO TLB\n", 283c0972d53769 Joe Perches 2013-06-28 201 (PAGE_SIZE << order) >> 20); cbce99527ca7c4 Christoph Hellwig 2021-03-01 202 nslabs = SLABS_PER_PAGE << order; cbce99527ca7c4 Christoph Hellwig 2021-03-01 203 bytes = nslabs << IO_TLB_SHIFT; b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 204 } b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 205 } cbce99527ca7c4 Christoph Hellwig 2021-03-01 @206 if (!start) { 5bab7864b1167f Konrad Rzeszutek Wilk 2012-08-23 207 m_ret = XEN_SWIOTLB_ENOMEM; f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 208 goto error; f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 209 } b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 210 /* b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 211 * And replace that memory with pages under 4GB. b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 212 */ cbce99527ca7c4 Christoph Hellwig 2021-03-01 213 rc = xen_swiotlb_fixup(start, b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 214 bytes, cbce99527ca7c4 Christoph Hellwig 2021-03-01 215 nslabs); f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 216 if (rc) { b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 217 if (early) cbce99527ca7c4 Christoph Hellwig 2021-03-01 218 memblock_free(__pa(start), 2013288f723887 Mike Rapoport 2018-10-30 219 PAGE_ALIGN(bytes)); b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 220 else { cbce99527ca7c4 Christoph Hellwig 2021-03-01 221 free_pages((unsigned long)start, order); cbce99527ca7c4 Christoph Hellwig 2021-03-01 222 start = NULL; b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 223 } 5bab7864b1167f Konrad Rzeszutek Wilk 2012-08-23 224 m_ret = XEN_SWIOTLB_EFIXUP; b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 225 goto error; f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 226 } c468bdee28a1cb Konrad Rzeszutek Wilk 2012-09-17 227 if (early) { cbce99527ca7c4 Christoph Hellwig 2021-03-01 228 if (swiotlb_init_with_tbl(start, nslabs, ac2cbab21f318e Yinghai Lu 2013-01-24 229 verbose)) ac2cbab21f318e Yinghai Lu 2013-01-24 230 panic("Cannot allocate SWIOTLB buffer"); c468bdee28a1cb Konrad Rzeszutek Wilk 2012-09-17 231 rc = 0; c468bdee28a1cb Konrad Rzeszutek Wilk 2012-09-17 232 } else cbce99527ca7c4 Christoph Hellwig 2021-03-01 233 rc = swiotlb_late_init_with_tbl(start, nslabs); 7453c549f5f648 Konrad Rzeszutek Wilk 2016-12-20 234 4e7372e0dc5d7d Stefano Stabellini 2019-05-28 235 end: 7453c549f5f648 Konrad Rzeszutek Wilk 2016-12-20 236 if (!rc) 7453c549f5f648 Konrad Rzeszutek Wilk 2016-12-20 237 swiotlb_set_max_segment(PAGE_SIZE); 7453c549f5f648 Konrad Rzeszutek Wilk 2016-12-20 238 b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 239 return rc; b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 240 error: f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 241 if (repeat--) { cbce99527ca7c4 Christoph Hellwig 2021-03-01 242 nslabs = max(1024UL, /* Min is 2MB */ cbce99527ca7c4 Christoph Hellwig 2021-03-01 243 (nslabs >> 1)); 283c0972d53769 Joe Perches 2013-06-28 244 pr_info("Lowering to %luMB\n", cbce99527ca7c4 Christoph Hellwig 2021-03-01 245 (nslabs << IO_TLB_SHIFT) >> 20); f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 246 goto retry; f4b2f07b2ed9b4 Konrad Rzeszutek Wilk 2011-07-22 247 } 283c0972d53769 Joe Perches 2013-06-28 248 pr_err("%s (rc:%d)\n", xen_swiotlb_error(m_ret), rc); b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 249 if (early) 5bab7864b1167f Konrad Rzeszutek Wilk 2012-08-23 250 panic("%s (rc:%d)", xen_swiotlb_error(m_ret), rc); b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 251 else cbce99527ca7c4 Christoph Hellwig 2021-03-01 252 free_pages((unsigned long)start, order); b8277600536989 Konrad Rzeszutek Wilk 2012-08-23 253 return rc; b097186fd29d5b Konrad Rzeszutek Wilk 2010-05-11 254 } dceb1a6819ab2c Christoph Hellwig 2017-05-21 255 --- 0-DAY CI Kernel Test Service https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org _______________________________________________ kbuild mailing list -- kbuild@lists.01.org To unsubscribe send an email to kbuild-le...@lists.01.org