All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/xen/swiotlb-xen.c:206:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
@ 2022-03-14 20:38 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-03-14 20:38 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 21567 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Christoph Hellwig <hch@lst.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   09688c0166e76ce2fb85e86b9d99be8b0084cdf9
commit: cbce99527ca7c4e98db9890651d5e9dfc2fb89ac xen-swiotlb: remove xen_io_tlb_start and xen_io_tlb_nslabs
date:   12 months ago
:::::: branch date: 24 hours ago
:::::: commit date: 12 months ago
config: x86_64-randconfig-c007-20220307 (https://download.01.org/0day-ci/archive/20220315/202203150407.KzSq020Z-lkp(a)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 <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/lis3lv02d/lis3lv02d.c:315:2: note: Taking true branch
           if (lis3->whoami == WAI_8B) {
           ^
   drivers/misc/lis3lv02d/lis3lv02d.c:318:3: note: 3rd function call argument is an uninitialized value
                   lis3->write(lis3, CTRL_REG3, ctrl_reg_data);
                   ^                            ~~~~~~~~~~~~~
   drivers/misc/lis3lv02d/lis3lv02d.c:798:9: warning: 4th function call argument is an uninitialized value [clang-analyzer-core.CallAndMessage]
           return sprintf(buf, "%s %d %d %d\n", res,
                  ^
   drivers/misc/lis3lv02d/lis3lv02d.c:786:10: note: Calling 'lis3lv02d_selftest'
           switch (lis3lv02d_selftest(lis3, values)) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/lis3lv02d/lis3lv02d.c:268:6: note: Assuming field 'whoami' is not equal to WAI_8B
           if (lis3->whoami == WAI_8B) {
               ^~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/lis3lv02d/lis3lv02d.c:268:2: note: Taking false branch
           if (lis3->whoami == WAI_8B) {
           ^
   drivers/misc/lis3lv02d/lis3lv02d.c:281:7: note: Assuming field 'whoami' is equal to WAI_3DC
           if ((lis3->whoami == WAI_3DC) || (lis3->whoami == WAI_3DLH)) {
                ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/lis3lv02d/lis3lv02d.c:281:32: note: Left side of '||' is true
           if ((lis3->whoami == WAI_3DC) || (lis3->whoami == WAI_3DLH)) {
                                         ^
   drivers/misc/lis3lv02d/lis3lv02d.c:295:6: note: 'ret' is -6
           if (ret)
               ^~~
   drivers/misc/lis3lv02d/lis3lv02d.c:295:2: note: Taking true branch
           if (ret)
           ^
   drivers/misc/lis3lv02d/lis3lv02d.c:296:3: note: Control jumps to line 348
                   goto fail;
                   ^
   drivers/misc/lis3lv02d/lis3lv02d.c:349:2: note: Returning without writing to '*results'
           return ret;
           ^
   drivers/misc/lis3lv02d/lis3lv02d.c:786:10: note: Returning from 'lis3lv02d_selftest'
           switch (lis3lv02d_selftest(lis3, values)) {
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/misc/lis3lv02d/lis3lv02d.c:786:2: note: Control jumps to the 'default' case at line 794
           switch (lis3lv02d_selftest(lis3, values)) {
           ^
   drivers/misc/lis3lv02d/lis3lv02d.c:796:3: note:  Execution continues on line 798
                   break;
                   ^
   drivers/misc/lis3lv02d/lis3lv02d.c:798:9: note: 4th function call argument is an uninitialized value
           return sprintf(buf, "%s %d %d %d\n", res,
                  ^
   Suppressed 5 warnings (5 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.
   5 warnings generated.
   drivers/pinctrl/pinctrl-single.c:1410:3: warning: Value stored to 'mask' is never read [clang-analyzer-deadcode.DeadStores]
                   mask = pcs->read(pcswi->reg);
                   ^      ~~~~~~~~~~~~~~~~~~~~~
   drivers/pinctrl/pinctrl-single.c:1410:3: note: Value stored to 'mask' is never read
                   mask = pcs->read(pcswi->reg);
                   ^      ~~~~~~~~~~~~~~~~~~~~~
   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.
   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.
   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.
   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.
   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.

vim +206 drivers/xen/swiotlb-xen.c

4035b43da6daa51 Christoph Hellwig     2021-03-01  158  
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  159  int __ref xen_swiotlb_init(int verbose, bool early)
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  160  {
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  161  	unsigned long bytes, order;
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  162  	int rc = -ENOMEM;
5bab7864b1167f9 Konrad Rzeszutek Wilk 2012-08-23  163  	enum xen_swiotlb_err m_ret = XEN_SWIOTLB_UNKNOWN;
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  164  	unsigned int repeat = 3;
cbce99527ca7c4e Christoph Hellwig     2021-03-01  165  	char *start;
cbce99527ca7c4e Christoph Hellwig     2021-03-01  166  	unsigned long nslabs;
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  167  
cbce99527ca7c4e Christoph Hellwig     2021-03-01  168  	nslabs = swiotlb_nr_tbl();
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  169  retry:
cbce99527ca7c4e Christoph Hellwig     2021-03-01  170  	if (!nslabs)
cbce99527ca7c4e Christoph Hellwig     2021-03-01  171  		nslabs = DEFAULT_NSLABS;
cbce99527ca7c4e Christoph Hellwig     2021-03-01  172  	bytes = nslabs << IO_TLB_SHIFT;
4035b43da6daa51 Christoph Hellwig     2021-03-01  173  	order = get_order(bytes);
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  174  
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  175  	/*
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  176  	 * IO TLB memory already allocated. Just use it.
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  177  	 */
cbce99527ca7c4e Christoph Hellwig     2021-03-01  178  	if (io_tlb_start != 0)
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  179  		goto end;
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  180  
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  181  	/*
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  182  	 * Get IO TLB memory from any location.
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  183  	 */
8a7f97b902f4fb0 Mike Rapoport         2019-03-11  184  	if (early) {
cbce99527ca7c4e Christoph Hellwig     2021-03-01  185  		start = memblock_alloc(PAGE_ALIGN(bytes),
15c3c114ed144e5 Mike Rapoport         2018-10-30  186  						  PAGE_SIZE);
cbce99527ca7c4e Christoph Hellwig     2021-03-01  187  		if (!start)
8a7f97b902f4fb0 Mike Rapoport         2019-03-11  188  			panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
8a7f97b902f4fb0 Mike Rapoport         2019-03-11  189  			      __func__, PAGE_ALIGN(bytes), PAGE_SIZE);
8a7f97b902f4fb0 Mike Rapoport         2019-03-11  190  	} else {
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  191  #define SLABS_PER_PAGE (1 << (PAGE_SHIFT - IO_TLB_SHIFT))
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  192  #define IO_TLB_MIN_SLABS ((1<<20) >> IO_TLB_SHIFT)
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  193  		while ((SLABS_PER_PAGE << order) > IO_TLB_MIN_SLABS) {
cbce99527ca7c4e Christoph Hellwig     2021-03-01  194  			start = (void *)xen_get_swiotlb_free_pages(order);
cbce99527ca7c4e Christoph Hellwig     2021-03-01  195  			if (start)
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  196  				break;
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  197  			order--;
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  198  		}
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  199  		if (order != get_order(bytes)) {
283c0972d53769e Joe Perches           2013-06-28  200  			pr_warn("Warning: only able to allocate %ld MB for software IO TLB\n",
283c0972d53769e Joe Perches           2013-06-28  201  				(PAGE_SIZE << order) >> 20);
cbce99527ca7c4e Christoph Hellwig     2021-03-01  202  			nslabs = SLABS_PER_PAGE << order;
cbce99527ca7c4e Christoph Hellwig     2021-03-01  203  			bytes = nslabs << IO_TLB_SHIFT;
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  204  		}
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  205  	}
cbce99527ca7c4e Christoph Hellwig     2021-03-01 @206  	if (!start) {
5bab7864b1167f9 Konrad Rzeszutek Wilk 2012-08-23  207  		m_ret = XEN_SWIOTLB_ENOMEM;
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  208  		goto error;
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  209  	}
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  210  	/*
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  211  	 * And replace that memory with pages under 4GB.
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  212  	 */
cbce99527ca7c4e Christoph Hellwig     2021-03-01  213  	rc = xen_swiotlb_fixup(start,
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  214  			       bytes,
cbce99527ca7c4e Christoph Hellwig     2021-03-01  215  			       nslabs);
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  216  	if (rc) {
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  217  		if (early)
cbce99527ca7c4e Christoph Hellwig     2021-03-01  218  			memblock_free(__pa(start),
2013288f7238878 Mike Rapoport         2018-10-30  219  				      PAGE_ALIGN(bytes));
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  220  		else {
cbce99527ca7c4e Christoph Hellwig     2021-03-01  221  			free_pages((unsigned long)start, order);
cbce99527ca7c4e Christoph Hellwig     2021-03-01  222  			start = NULL;
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  223  		}
5bab7864b1167f9 Konrad Rzeszutek Wilk 2012-08-23  224  		m_ret = XEN_SWIOTLB_EFIXUP;
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  225  		goto error;
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  226  	}
c468bdee28a1cb6 Konrad Rzeszutek Wilk 2012-09-17  227  	if (early) {
cbce99527ca7c4e Christoph Hellwig     2021-03-01  228  		if (swiotlb_init_with_tbl(start, nslabs,
ac2cbab21f318e1 Yinghai Lu            2013-01-24  229  			 verbose))
ac2cbab21f318e1 Yinghai Lu            2013-01-24  230  			panic("Cannot allocate SWIOTLB buffer");
c468bdee28a1cb6 Konrad Rzeszutek Wilk 2012-09-17  231  		rc = 0;
c468bdee28a1cb6 Konrad Rzeszutek Wilk 2012-09-17  232  	} else
cbce99527ca7c4e Christoph Hellwig     2021-03-01  233  		rc = swiotlb_late_init_with_tbl(start, nslabs);
7453c549f5f6485 Konrad Rzeszutek Wilk 2016-12-20  234  
4e7372e0dc5d7d2 Stefano Stabellini    2019-05-28  235  end:
7453c549f5f6485 Konrad Rzeszutek Wilk 2016-12-20  236  	if (!rc)
7453c549f5f6485 Konrad Rzeszutek Wilk 2016-12-20  237  		swiotlb_set_max_segment(PAGE_SIZE);
7453c549f5f6485 Konrad Rzeszutek Wilk 2016-12-20  238  
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  239  	return rc;
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  240  error:
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  241  	if (repeat--) {
cbce99527ca7c4e Christoph Hellwig     2021-03-01  242  		nslabs = max(1024UL, /* Min is 2MB */
cbce99527ca7c4e Christoph Hellwig     2021-03-01  243  					(nslabs >> 1));
283c0972d53769e Joe Perches           2013-06-28  244  		pr_info("Lowering to %luMB\n",
cbce99527ca7c4e Christoph Hellwig     2021-03-01  245  			(nslabs << IO_TLB_SHIFT) >> 20);
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  246  		goto retry;
f4b2f07b2ed9b46 Konrad Rzeszutek Wilk 2011-07-22  247  	}
283c0972d53769e Joe Perches           2013-06-28  248  	pr_err("%s (rc:%d)\n", xen_swiotlb_error(m_ret), rc);
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  249  	if (early)
5bab7864b1167f9 Konrad Rzeszutek Wilk 2012-08-23  250  		panic("%s (rc:%d)", xen_swiotlb_error(m_ret), rc);
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  251  	else
cbce99527ca7c4e Christoph Hellwig     2021-03-01  252  		free_pages((unsigned long)start, order);
b82776005369899 Konrad Rzeszutek Wilk 2012-08-23  253  	return rc;
b097186fd29d5bc Konrad Rzeszutek Wilk 2010-05-11  254  }
dceb1a6819ab2c8 Christoph Hellwig     2017-05-21  255  

---
0-DAY CI Kernel Test Service
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* drivers/xen/swiotlb-xen.c:206:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
@ 2022-03-13  2:40 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-03-13  2:40 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 21911 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Christoph Hellwig <hch@lst.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@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-lkp(a)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 <lkp@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-all(a)lists.01.org

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

* drivers/xen/swiotlb-xen.c:206:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
@ 2022-03-09 14:31 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2022-03-09 14:31 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 22750 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Christoph Hellwig <hch@lst.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   330f4c53d3c2d8b11d86ec03a964b86dc81452f5
commit: cbce99527ca7c4e98db9890651d5e9dfc2fb89ac xen-swiotlb: remove xen_io_tlb_start and xen_io_tlb_nslabs
date:   12 months ago
:::::: branch date: 17 hours ago
:::::: commit date: 12 months ago
config: x86_64-randconfig-c007-20220307 (https://download.01.org/0day-ci/archive/20220309/202203092203.wHzVanBZ-lkp(a)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 <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/acpi/ec.c:777:2: note: Taking true branch
           if (!acpi_ec_submit_flushable_request(ec)) {
           ^
   drivers/acpi/ec.c:779:3: note: Control jumps to line 799
                   goto unlock;
                   ^
   drivers/acpi/ec.c:799:2: note: Calling 'spin_unlock_irqrestore'
           spin_unlock_irqrestore(&ec->lock, tmp);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:409:2: note: Value assigned to field 'global_lock', which participates in a condition later
           raw_spin_unlock_irqrestore(&lock->rlock, flags);
           ^
   include/linux/spinlock.h:290:3: note: expanded from macro 'raw_spin_unlock_irqrestore'
                   _raw_spin_unlock_irqrestore(lock, flags);       \
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:409:2: note: Loop condition is false.  Exiting loop
           raw_spin_unlock_irqrestore(&lock->rlock, flags);
           ^
   include/linux/spinlock.h:288:2: note: expanded from macro 'raw_spin_unlock_irqrestore'
           do {                                                    \
           ^
   drivers/acpi/ec.c:799:2: note: Returning from 'spin_unlock_irqrestore'
           spin_unlock_irqrestore(&ec->lock, tmp);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/acpi/ec.c:822:11: note: Returning from 'acpi_ec_transaction_unlocked'
           status = acpi_ec_transaction_unlocked(ec, t);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/acpi/ec.c:824:6: note: Assuming field 'global_lock' is true
           if (ec->global_lock)
               ^~~~~~~~~~~~~~~
   drivers/acpi/ec.c:824:2: note: Taking true branch
           if (ec->global_lock)
           ^
   drivers/acpi/ec.c:825:3: note: 1st function call argument is an uninitialized value
                   acpi_release_global_lock(glk);
                   ^                        ~~~
   drivers/acpi/ec.c:1575:2: 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(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
           ^~~~~~
   drivers/acpi/ec.c:1575:2: 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(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
           ^~~~~~
   drivers/acpi/ec.c:1576:2: 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(acpi_device_class(device), ACPI_EC_CLASS);
           ^~~~~~
   drivers/acpi/ec.c:1576:2: 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(acpi_device_class(device), ACPI_EC_CLASS);
           ^~~~~~
   Suppressed 5 warnings (5 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.
   5 warnings generated.
   Suppressed 5 warnings (5 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.
   6 warnings generated.
   drivers/acpi/bus.c:1265:2: warning: Value stored to 'status' is never read [clang-analyzer-deadcode.DeadStores]
           status = acpi_install_table_handler(acpi_bus_table_handler, NULL);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/acpi/bus.c:1265:2: note: Value stored to 'status' is never read
           status = acpi_install_table_handler(acpi_bus_table_handler, NULL);
           ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 5 warnings (5 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.
   drivers/acpi/glue.c:171: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(buf, PHYSICAL_NODE_STRING);
                   ^~~~~~
   drivers/acpi/glue.c:171: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(buf, PHYSICAL_NODE_STRING);
                   ^~~~~~
   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.
   12 warnings generated.
   drivers/acpi/scan.c:1072: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(device->pnp.bus_id, "ACPI");

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, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

* drivers/xen/swiotlb-xen.c:206:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch]
@ 2021-12-29 19:32 kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2021-12-29 19:32 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 19508 bytes --]

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Christoph Hellwig <hch@lst.de>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e7c124bd04631973a3cc0df19ab881b56d8a2d50
commit: cbce99527ca7c4e98db9890651d5e9dfc2fb89ac xen-swiotlb: remove xen_io_tlb_start and xen_io_tlb_nslabs
date:   10 months ago
:::::: branch date: 22 hours ago
:::::: commit date: 10 months ago
config: arm-randconfig-c002-20211228 (https://download.01.org/0day-ci/archive/20211230/202112300339.Mdr4nwDf-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 7171af744543433ac75b232eb7dfdaef7efd4d7a)
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
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # 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=arm clang-analyzer 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
           if (timeout)
               ^~~~~~~
   fs/io_uring.c:6125:2: note: Taking true branch
           if (timeout)
           ^
   fs/io_uring.c:6128:6: note: Assuming the condition is false
           if (work->flags & IO_WQ_WORK_CANCEL)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/io_uring.c:6128:2: note: Taking false branch
           if (work->flags & IO_WQ_WORK_CANCEL)
           ^
   fs/io_uring.c:6131:7: note: 'ret' is 0
           if (!ret) {
                ^~~
   fs/io_uring.c:6131:2: note: Taking true branch
           if (!ret) {
           ^
   fs/io_uring.c:6133:10: note: Calling 'io_issue_sqe'
                           ret = io_issue_sqe(req, 0);
                                 ^~~~~~~~~~~~~~~~~~~~
   fs/io_uring.c:5986:6: note: Assuming field 'creds' is null
           if (req->work.creds && req->work.creds != current_cred())
               ^~~~~~~~~~~~~~~
   fs/io_uring.c:5986:22: note: Left side of '&&' is false
           if (req->work.creds && req->work.creds != current_cred())
                               ^
   fs/io_uring.c:5989:2: note: Control jumps to 'case IORING_OP_WRITEV:'  at line 5998
           switch (req->opcode) {
           ^
   fs/io_uring.c:6001:9: note: Calling 'io_write'
                   ret = io_write(req, issue_flags);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/io_uring.c:3337:6: note: Assuming 'rw' is null
           if (rw) {
               ^~
   fs/io_uring.c:3337:2: note: Taking false branch
           if (rw) {
           ^
   fs/io_uring.c:3341:9: note: Calling 'io_import_iovec'
                   ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/io_uring.c:2961:6: note: 'opcode' is not equal to IORING_OP_READ_FIXED
           if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) {
               ^~~~~~
   fs/io_uring.c:2961:6: note: Left side of '||' is false
   fs/io_uring.c:2961:40: note: 'opcode' is not equal to IORING_OP_WRITE_FIXED
           if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) {
                                                 ^~~~~~
   fs/io_uring.c:2961:2: note: Taking false branch
           if (opcode == IORING_OP_READ_FIXED || opcode == IORING_OP_WRITE_FIXED) {
           ^
   fs/io_uring.c:2967:6: note: Assuming field 'buf_index' is 0
           if (req->buf_index && !(req->flags & REQ_F_BUFFER_SELECT))
               ^~~~~~~~~~~~~~
   fs/io_uring.c:2967:21: note: Left side of '&&' is false
           if (req->buf_index && !(req->flags & REQ_F_BUFFER_SELECT))
                              ^
   fs/io_uring.c:2970:6: note: 'opcode' is not equal to IORING_OP_READ
           if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
               ^~~~~~
   fs/io_uring.c:2970:6: note: Left side of '||' is false
   fs/io_uring.c:2970:34: note: 'opcode' is not equal to IORING_OP_WRITE
           if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
                                           ^~~~~~
   fs/io_uring.c:2970:2: note: Taking false branch
           if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
           ^
   fs/io_uring.c:2983:6: note: Assuming the condition is true
           if (req->flags & REQ_F_BUFFER_SELECT) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/io_uring.c:2983:2: note: Taking true branch
           if (req->flags & REQ_F_BUFFER_SELECT) {
           ^
   fs/io_uring.c:2985:7: note: Assuming 'ret' is not equal to 0
                   if (!ret)
                       ^~~~
   fs/io_uring.c:2985:3: note: Taking false branch
                   if (!ret)
                   ^
   fs/io_uring.c:2988:3: note: Returning without writing to 'iter->count'
                   return ret;
                   ^
   fs/io_uring.c:3341:9: note: Returning from 'io_import_iovec'
                   ret = io_import_iovec(WRITE, req, &iovec, iter, !force_nonblock);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   fs/io_uring.c:3342:7: note: Assuming 'ret' is >= 0
                   if (ret < 0)
                       ^~~~~~~
   fs/io_uring.c:3342:3: note: Taking false branch
                   if (ret < 0)
                   ^
   fs/io_uring.c:3345:12: note: Calling 'iov_iter_count'
           io_size = iov_iter_count(iter);
                     ^~~~~~~~~~~~~~~~~~~~
   include/linux/uio.h:234:2: note: Undefined or garbage value returned to caller
           return i->count;
           ^      ~~~~~~~~
   Suppressed 16 warnings (16 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.
   18 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 0
           if (!nslabs)
               ^~~~~~~
   drivers/xen/swiotlb-xen.c:170:2: note: Taking true 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) {
               ^~~~~~
   Suppressed 17 warnings (15 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.
   19 warnings generated.
   drivers/xen/privcmd.c:94:2: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
           list_for_each_entry_safe(p, n, pages, lru)
           ^
   include/linux/list.h:716:7: note: expanded from macro 'list_for_each_entry_safe'
                   n = list_next_entry(pos, member);                       \
                       ^
   include/linux/list.h:555:2: note: expanded from macro 'list_next_entry'
           list_entry((pos)->member.next, typeof(*(pos)), member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   include/linux/kernel.h:708:2: note: expanded from macro 'container_of'
           void *__mptr = (void *)(ptr);                                   \
           ^
   drivers/xen/privcmd.c:841:2: note: Control jumps to 'case 806914:'  at line 846
           switch (cmd) {
           ^
   drivers/xen/privcmd.c:847:9: note: Calling 'privcmd_ioctl_mmap'
                   ret = privcmd_ioctl_mmap(file, udata);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/xen/privcmd.c:261:6: note: Assuming the condition is false
           if (xen_feature(XENFEAT_auto_translated_physmap))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/xen/privcmd.c:261:2: note: Taking false branch
           if (xen_feature(XENFEAT_auto_translated_physmap))
           ^
   drivers/xen/privcmd.c:264:2: note: Taking false branch
           if (copy_from_user(&mmapcmd, udata, sizeof(mmapcmd)))
           ^
   drivers/xen/privcmd.c:268:6: note: Assuming field 'domid' is equal to DOMID_INVALID
           if (data->domid != DOMID_INVALID && data->domid != mmapcmd.dom)
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/xen/privcmd.c:268:35: note: Left side of '&&' is false
           if (data->domid != DOMID_INVALID && data->domid != mmapcmd.dom)
                                            ^
   drivers/xen/privcmd.c:271:7: note: Calling 'gather_array'
           rc = gather_array(&pagelist,
                ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/xen/privcmd.c:114:2: note: Taking false branch
           if (size > PAGE_SIZE)
           ^
   drivers/xen/privcmd.c:119:2: note: Loop condition is false. Execution continues on line 141
           while (nelem--) {
           ^
   drivers/xen/privcmd.c:271:7: note: Returning from 'gather_array'
           rc = gather_array(&pagelist,
                ^~~~~~~~~~~~~~~~~~~~~~~
   drivers/xen/privcmd.c:275:6: note: 'rc' is 0
           if (rc || list_empty(&pagelist))
               ^~
   drivers/xen/privcmd.c:275:6: note: Left side of '||' is false
   drivers/xen/privcmd.c:275:2: note: Taking true branch
           if (rc || list_empty(&pagelist))
           ^
   drivers/xen/privcmd.c:276:3: note: Control jumps to line 306
                   goto out;
                   ^
   drivers/xen/privcmd.c:306:2: note: Calling 'free_page_list'

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, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

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

end of thread, other threads:[~2022-03-14 20:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14 20:38 drivers/xen/swiotlb-xen.c:206:6: warning: Branch condition evaluates to a garbage value [clang-analyzer-core.uninitialized.Branch] kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-03-13  2:40 kernel test robot
2022-03-09 14:31 kernel test robot
2021-12-29 19:32 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.