All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/soc/mediatek/mtk-devapc.c:133:13: warning: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult]
@ 2021-08-23 15:44 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-08-23 15:44 UTC (permalink / raw)
  To: kbuild

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

CC: clang-built-linux(a)googlegroups.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Neal Liu <neal.liu@mediatek.com>
CC: Matthias Brugger <matthias.bgg@gmail.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e22ce8eb631bdc47a4a4ea7ecf4e4ba499db4f93
commit: 0890beb22618c0359f1e2652fc1e49bb5c5e876d soc: mediatek: add mt6779 devapc driver
date:   9 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 9 months ago
config: riscv-randconfig-c006-20210822 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 9e9d70591e72fc6762b4b9a226b68ed1307419bf)
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 riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0890beb22618c0359f1e2652fc1e49bb5c5e876d
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 0890beb22618c0359f1e2652fc1e49bb5c5e876d
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 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 >>)
           list_for_each_entry_safe(page, n, list, slab_list) {
           ^
   include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:319:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:307:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:299:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   mm/slab.c:1643:2: note: Loop condition is false.  Exiting loop
           list_for_each_entry_safe(page, n, list, slab_list) {
           ^
   include/linux/list.h:715:13: note: expanded from macro 'list_for_each_entry_safe'
           for (pos = list_first_entry(head, typeof(*pos), member),        \
                      ^
   include/linux/list.h:522:2: note: expanded from macro 'list_first_entry'
           list_entry((ptr)->next, type, member)
           ^
   include/linux/list.h:511:2: note: expanded from macro 'list_entry'
           container_of(ptr, type, member)
           ^
   note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
   include/linux/compiler_types.h:319:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:307:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:297:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   mm/slab.c:1643:2: note: Assigned value is garbage or undefined
           list_for_each_entry_safe(page, n, list, slab_list) {
           ^
   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:852:2: note: expanded from macro 'container_of'
           void *__mptr = (void *)(ptr);                                   \
           ^              ~~~~~~~~~~~~~
   mm/slab.c:2501:3: warning: Value stored to 'objp' is never read [clang-analyzer-deadcode.DeadStores]
                   objp = kasan_init_slab_obj(cachep, objp);
                   ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   mm/slab.c:2501:3: note: Value stored to 'objp' is never read
                   objp = kasan_init_slab_obj(cachep, objp);
                   ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   Suppressed 20 warnings (11 in non-user code, 9 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.
   6 warnings generated.
   drivers/leds/led-triggers.c:276: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((char *)trig->name, name);
           ^~~~~~
   drivers/leds/led-triggers.c:276: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((char *)trig->name, name);
           ^~~~~~
   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.
   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.
   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.
   12 warnings generated.
   Suppressed 12 warnings (5 in non-user code, 7 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.
   13 warnings generated.
   drivers/soc/aspeed/aspeed-lpc-ctrl.c:67:17: warning: Value stored to 'dev' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct device *dev = file->private_data;
                          ^~~   ~~~~~~~~~~~~~~~~~~
   drivers/soc/aspeed/aspeed-lpc-ctrl.c:67:17: note: Value stored to 'dev' during its initialization is never read
           struct device *dev = file->private_data;
                          ^~~   ~~~~~~~~~~~~~~~~~~
   Suppressed 12 warnings (5 in non-user code, 7 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.
   12 warnings generated.
   Suppressed 12 warnings (5 in non-user code, 7 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.
   44 warnings generated.
>> drivers/soc/mediatek/mtk-devapc.c:133:13: warning: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult]
           writel(0x1 << min_shift_group, pd_vio_shift_sel_reg);
                      ^
   drivers/soc/mediatek/mtk-devapc.c:190:9: note: Calling 'devapc_sync_vio_dbg'
           while (devapc_sync_vio_dbg(ctx))
                  ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/soc/mediatek/mtk-devapc.c:126:8: note: Loop condition is false.  Exiting loop
           val = readl(pd_vio_shift_sta_reg);
                 ^
   arch/riscv/include/asm/mmio.h:140:30: note: expanded from macro 'readl'
   #define readl(c)        ({ u32 __v; __io_br(); __v = readl_cpu(c); __io_ar(__v); __v; })
                                       ^
   arch/riscv/include/asm/mmio.h:133:19: note: expanded from macro '__io_br'
   #define __io_br()       do {} while (0)
                           ^
   drivers/soc/mediatek/mtk-devapc.c:127:6: note: Assuming 'val' is not equal to 0
           if (!val)
               ^~~~
   drivers/soc/mediatek/mtk-devapc.c:127:2: note: Taking false branch
           if (!val)
           ^
   drivers/soc/mediatek/mtk-devapc.c:130:20: note: Calling '__ffs'
           min_shift_group = __ffs(val);
                             ^~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:18:6: note: Assuming the condition is true
           if ((word & 0xffffffff) == 0) {
               ^~~~~~~~~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:18:2: note: Taking true branch
           if ((word & 0xffffffff) == 0) {
           ^
   include/asm-generic/bitops/__ffs.h:19:3: note: The value 32 is assigned to 'num'
                   num += 32;
                   ^~~~~~~~~
   include/asm-generic/bitops/__ffs.h:23:6: note: Assuming the condition is false
           if ((word & 0xffff) == 0) {
               ^~~~~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:23:2: note: Taking false branch
           if ((word & 0xffff) == 0) {
           ^
   include/asm-generic/bitops/__ffs.h:27:6: note: Assuming the condition is false
           if ((word & 0xff) == 0) {
               ^~~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:27:2: note: Taking false branch
           if ((word & 0xff) == 0) {
           ^
   include/asm-generic/bitops/__ffs.h:31:6: note: Assuming the condition is false
           if ((word & 0xf) == 0) {
               ^~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:31:2: note: Taking false branch
           if ((word & 0xf) == 0) {
           ^
   include/asm-generic/bitops/__ffs.h:35:6: note: Assuming the condition is false
           if ((word & 0x3) == 0) {
               ^~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:35:2: note: Taking false branch
           if ((word & 0x3) == 0) {
           ^
   include/asm-generic/bitops/__ffs.h:39:6: note: Assuming the condition is false
           if ((word & 0x1) == 0)
               ^~~~~~~~~~~~~~~~~
   include/asm-generic/bitops/__ffs.h:39:2: note: Taking false branch
           if ((word & 0x1) == 0)
           ^
   include/asm-generic/bitops/__ffs.h:41:2: note: Returning the value 32 (loaded from 'num')
           return num;
           ^~~~~~~~~~
   drivers/soc/mediatek/mtk-devapc.c:130:20: note: Returning from '__ffs'
           min_shift_group = __ffs(val);
                             ^~~~~~~~~~
   drivers/soc/mediatek/mtk-devapc.c:130:2: note: The value 32 is assigned to 'min_shift_group'
           min_shift_group = __ffs(val);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/soc/mediatek/mtk-devapc.c:133:13: note: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'int'
           writel(0x1 << min_shift_group, pd_vio_shift_sel_reg);
                      ^
   arch/riscv/include/asm/mmio.h:144:48: note: expanded from macro 'writel'
   #define writel(v, c)    ({ __io_bw(); writel_cpu((v), (c)); __io_aw(); })
                                                     ^
   arch/riscv/include/asm/mmio.h:93:71: note: expanded from macro 'writel_cpu'
   #define writel_cpu(v, c)        ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
                                                                                ^
   include/uapi/linux/byteorder/little_endian.h:33:51: note: expanded from macro '__cpu_to_le32'
   #define __cpu_to_le32(x) ((__force __le32)(__u32)(x))
                                                     ^
   drivers/soc/mediatek/mtk-devapc.c:133:13: warning: The result of the left shift is undefined due to shifting by '33', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult]
           writel(0x1 << min_shift_group, pd_vio_shift_sel_reg);
                      ^
   drivers/soc/mediatek/mtk-devapc.c:190:9: note: Calling 'devapc_sync_vio_dbg'
           while (devapc_sync_vio_dbg(ctx))
                  ^~~~~~~~~~~~~~~~~~~~~~~~
   drivers/soc/mediatek/mtk-devapc.c:126:8: note: Loop condition is false.  Exiting loop
           val = readl(pd_vio_shift_sta_reg);
                 ^
   arch/riscv/include/asm/mmio.h:140:30: note: expanded from macro 'readl'
   #define readl(c)        ({ u32 __v; __io_br(); __v = readl_cpu(c); __io_ar(__v); __v; })
                                       ^
   arch/riscv/include/asm/mmio.h:133:19: note: expanded from macro '__io_br'
   #define __io_br()       do {} while (0)
                           ^
   drivers/soc/mediatek/mtk-devapc.c:127:6: note: Assuming 'val' is not equal to 0
           if (!val)

vim +133 drivers/soc/mediatek/mtk-devapc.c

0890beb22618c0 Neal Liu 2020-10-15   98  
0890beb22618c0 Neal Liu 2020-10-15   99  /*
0890beb22618c0 Neal Liu 2020-10-15  100   * devapc_sync_vio_dbg - do "shift" mechansim" to get full violation information.
0890beb22618c0 Neal Liu 2020-10-15  101   *                       shift mechanism is depends on devapc hardware design.
0890beb22618c0 Neal Liu 2020-10-15  102   *                       Mediatek devapc set multiple slaves as a group.
0890beb22618c0 Neal Liu 2020-10-15  103   *                       When violation is triggered, violation info is kept
0890beb22618c0 Neal Liu 2020-10-15  104   *                       inside devapc hardware.
0890beb22618c0 Neal Liu 2020-10-15  105   *                       Driver should do shift mechansim to sync full violation
0890beb22618c0 Neal Liu 2020-10-15  106   *                       info to VIO_DBGs registers.
0890beb22618c0 Neal Liu 2020-10-15  107   *
0890beb22618c0 Neal Liu 2020-10-15  108   */
0890beb22618c0 Neal Liu 2020-10-15  109  static int devapc_sync_vio_dbg(struct mtk_devapc_context *ctx)
0890beb22618c0 Neal Liu 2020-10-15  110  {
0890beb22618c0 Neal Liu 2020-10-15  111  	void __iomem *pd_vio_shift_sta_reg;
0890beb22618c0 Neal Liu 2020-10-15  112  	void __iomem *pd_vio_shift_sel_reg;
0890beb22618c0 Neal Liu 2020-10-15  113  	void __iomem *pd_vio_shift_con_reg;
0890beb22618c0 Neal Liu 2020-10-15  114  	int min_shift_group;
0890beb22618c0 Neal Liu 2020-10-15  115  	int ret;
0890beb22618c0 Neal Liu 2020-10-15  116  	u32 val;
0890beb22618c0 Neal Liu 2020-10-15  117  
0890beb22618c0 Neal Liu 2020-10-15  118  	pd_vio_shift_sta_reg = ctx->infra_base +
0890beb22618c0 Neal Liu 2020-10-15  119  			       ctx->data->vio_shift_sta_offset;
0890beb22618c0 Neal Liu 2020-10-15  120  	pd_vio_shift_sel_reg = ctx->infra_base +
0890beb22618c0 Neal Liu 2020-10-15  121  			       ctx->data->vio_shift_sel_offset;
0890beb22618c0 Neal Liu 2020-10-15  122  	pd_vio_shift_con_reg = ctx->infra_base +
0890beb22618c0 Neal Liu 2020-10-15  123  			       ctx->data->vio_shift_con_offset;
0890beb22618c0 Neal Liu 2020-10-15  124  
0890beb22618c0 Neal Liu 2020-10-15  125  	/* Find the minimum shift group which has violation */
0890beb22618c0 Neal Liu 2020-10-15  126  	val = readl(pd_vio_shift_sta_reg);
0890beb22618c0 Neal Liu 2020-10-15  127  	if (!val)
0890beb22618c0 Neal Liu 2020-10-15  128  		return false;
0890beb22618c0 Neal Liu 2020-10-15  129  
0890beb22618c0 Neal Liu 2020-10-15  130  	min_shift_group = __ffs(val);
0890beb22618c0 Neal Liu 2020-10-15  131  
0890beb22618c0 Neal Liu 2020-10-15  132  	/* Assign the group to sync */
0890beb22618c0 Neal Liu 2020-10-15 @133  	writel(0x1 << min_shift_group, pd_vio_shift_sel_reg);
0890beb22618c0 Neal Liu 2020-10-15  134  
0890beb22618c0 Neal Liu 2020-10-15  135  	/* Start syncing */
0890beb22618c0 Neal Liu 2020-10-15  136  	writel(0x1, pd_vio_shift_con_reg);
0890beb22618c0 Neal Liu 2020-10-15  137  
0890beb22618c0 Neal Liu 2020-10-15  138  	ret = readl_poll_timeout(pd_vio_shift_con_reg, val, val == 0x3, 0,
0890beb22618c0 Neal Liu 2020-10-15  139  				 PHY_DEVAPC_TIMEOUT);
0890beb22618c0 Neal Liu 2020-10-15  140  	if (ret) {
0890beb22618c0 Neal Liu 2020-10-15  141  		dev_err(ctx->dev, "%s: Shift violation info failed\n", __func__);
0890beb22618c0 Neal Liu 2020-10-15  142  		return false;
0890beb22618c0 Neal Liu 2020-10-15  143  	}
0890beb22618c0 Neal Liu 2020-10-15  144  
0890beb22618c0 Neal Liu 2020-10-15  145  	/* Stop syncing */
0890beb22618c0 Neal Liu 2020-10-15  146  	writel(0x0, pd_vio_shift_con_reg);
0890beb22618c0 Neal Liu 2020-10-15  147  
0890beb22618c0 Neal Liu 2020-10-15  148  	/* Write clear */
0890beb22618c0 Neal Liu 2020-10-15  149  	writel(0x1 << min_shift_group, pd_vio_shift_sta_reg);
0890beb22618c0 Neal Liu 2020-10-15  150  
0890beb22618c0 Neal Liu 2020-10-15  151  	return true;
0890beb22618c0 Neal Liu 2020-10-15  152  }
0890beb22618c0 Neal Liu 2020-10-15  153  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 31940 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-23 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-23 15:44 drivers/soc/mediatek/mtk-devapc.c:133:13: warning: The result of the left shift is undefined due to shifting by '32', which is greater or equal to the width of type 'int' [clang-analyzer-core.UndefinedBinaryOperatorResult] 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.