[xlnx:master 271/274] drivers/misc/xilinx-ai-engine/ai-engine-part.c:302:32: warning: passing argument 2 of 'copy_from_user' makes pointer from integer without a cast

kernel test robot lkp at intel.com
Sat Apr 10 09:19:33 BST 2021


Hi Tejus,

FYI, the error/warning still remains.

tree:   https://github.com/Xilinx/linux-xlnx master
head:   11fb963a44f50af56ff7017fe808ff83b3ae4716
commit: d3774573d5a9700273bd0c3ff82af157107f7fa6 [271/274] misc: xilinx-ai-engine: transaction mode ioctl
config: arm64-allyesconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
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://github.com/Xilinx/linux-xlnx/commit/d3774573d5a9700273bd0c3ff82af157107f7fa6
        git remote add xlnx https://github.com/Xilinx/linux-xlnx
        git fetch --no-tags xlnx master
        git checkout d3774573d5a9700273bd0c3ff82af157107f7fa6
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm64 

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

All warnings (new ones prefixed by >>):

   drivers/misc/xilinx-ai-engine/ai-engine-part.c: In function 'aie_part_access_regs':
>> drivers/misc/xilinx-ai-engine/ai-engine-part.c:302:32: warning: passing argument 2 of 'copy_from_user' makes pointer from integer without a cast [-Wint-conversion]
     302 |    if (copy_from_user(tmp, args->dataptr, sizeof(u32) *
         |                            ~~~~^~~~~~~~~
         |                                |
         |                                __u64 {aka long long unsigned int}
   In file included from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/ptrace.h:7,
                    from arch/arm64/include/asm/kgdb.h:14,
                    from include/linux/kgdb.h:20,
                    from arch/arm64/include/asm/cacheflush.h:11,
                    from arch/arm64/include/asm/mmu_context.h:18,
                    from include/linux/mmu_context.h:5,
                    from drivers/misc/xilinx-ai-engine/ai-engine-part.c:17:
   include/linux/uaccess.h:141:45: note: expected 'const void *' but argument is of type '__u64' {aka 'long long unsigned int'}
     141 | copy_from_user(void *to, const void __user *from, unsigned long n)
         |                          ~~~~~~~~~~~~~~~~~~~^~~~
   drivers/misc/xilinx-ai-engine/ai-engine-part.c: In function 'aie_part_execute_transaction_from_user':
   drivers/misc/xilinx-ai-engine/ai-engine-part.c:365:35: warning: passing argument 2 of 'copy_from_user' makes pointer from integer without a cast [-Wint-conversion]
     365 |  if (copy_from_user(cmds, txn_inst.cmdsptr,
         |                           ~~~~~~~~^~~~~~~~
         |                                   |
         |                                   __u64 {aka long long unsigned int}
   In file included from include/linux/sched/task.h:11,
                    from include/linux/sched/signal.h:9,
                    from include/linux/ptrace.h:7,
                    from arch/arm64/include/asm/kgdb.h:14,
                    from include/linux/kgdb.h:20,
                    from arch/arm64/include/asm/cacheflush.h:11,
                    from arch/arm64/include/asm/mmu_context.h:18,
                    from include/linux/mmu_context.h:5,
                    from drivers/misc/xilinx-ai-engine/ai-engine-part.c:17:
   include/linux/uaccess.h:141:45: note: expected 'const void *' but argument is of type '__u64' {aka 'long long unsigned int'}
     141 | copy_from_user(void *to, const void __user *from, unsigned long n)
         |                          ~~~~~~~~~~~~~~~~~~~^~~~


vim +/copy_from_user +302 drivers/misc/xilinx-ai-engine/ai-engine-part.c

   262	
   263	/**
   264	 * aie_part_access_regs() - AI engine partition registers access
   265	 * @apart: AI engine partition
   266	 * @num_reqs: number of access requests
   267	 * @reqs: array of registers access
   268	 * @return: 0 for success, and negative value for failure.
   269	 *
   270	 * This function executes AI engine partition register access requests.
   271	 */
   272	static int aie_part_access_regs(struct aie_partition *apart, u32 num_reqs,
   273					struct aie_reg_args *reqs)
   274	{
   275		u32 i;
   276	
   277		for (i = 0; i < num_reqs; i++) {
   278			struct aie_reg_args *args = &reqs[i];
   279			int ret;
   280	
   281			switch (args->op) {
   282			case AIE_REG_WRITE:
   283			{
   284				ret = aie_part_write_register(apart,
   285							      (size_t)args->offset,
   286							      sizeof(args->val),
   287							      &args->val, args->mask);
   288				break;
   289			}
   290			case AIE_REG_BLOCKWRITE:
   291			{
   292				u32 *tmp;
   293	
   294				/*
   295				 * TODO: replace copy_from_user by pinning the user
   296				 * page for performance improvement.
   297				 */
   298				tmp = kcalloc(args->len, sizeof(u32), GFP_KERNEL);
   299				if (!tmp)
   300					return -ENOMEM;
   301	
 > 302				if (copy_from_user(tmp, args->dataptr, sizeof(u32) *
   303							args->len)) {
   304					kfree(tmp);
   305					return -EFAULT;
   306				}
   307	
   308				ret = aie_part_write_register(apart,
   309							      (size_t)args->offset,
   310							      sizeof(u32) * args->len,
   311							      tmp, args->mask);
   312				kfree(tmp);
   313				break;
   314			}
   315			case AIE_REG_BLOCKSET:
   316			{
   317				ret = aie_part_block_set(apart, args);
   318				break;
   319			}
   320			default:
   321				dev_err(&apart->dev,
   322					"Invalid register command type: %u.\n",
   323					args->op);
   324				return -EINVAL;
   325			}
   326	
   327			if (ret < 0) {
   328				dev_err(&apart->dev, "reg op %u failed: 0x%llx.\n",
   329					args->op, args->offset);
   330				return ret;
   331			}
   332		}
   333	
   334		return 0;
   335	}
   336	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 68674 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20210410/4fcabb01/attachment-0001.gz>


More information about the linux-arm-kernel mailing list