drivers/vhost/vdpa.c:361:13: sparse: sparse: incorrect type in argument 1 (different address spaces)

From: kernel test robot
Date: Fri Jan 15 2021 - 04:46:24 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5ee88057889bbca5f5bb96031b62b3756b33e164
commit: e5fc436f06eef54ef512ea55a9db8eb9f2e76959 sparse: use static inline for __chk_{user,io}_ptr()
date: 5 months ago
config: sh-randconfig-s032-20210115 (attached as .config)
compiler: sh4-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-208-g46a52ca4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e5fc436f06eef54ef512ea55a9db8eb9f2e76959
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout e5fc436f06eef54ef512ea55a9db8eb9f2e76959
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=sh

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


"sparse warnings: (new ones prefixed by >>)"
drivers/vhost/vdpa.c:361:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned int const *__gu_addr @@ got unsigned int [noderef] [usertype] __user * @@
drivers/vhost/vdpa.c:361:13: sparse: expected unsigned int const *__gu_addr
drivers/vhost/vdpa.c:361:13: sparse: got unsigned int [noderef] [usertype] __user *
>> drivers/vhost/vdpa.c:361:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned int const *__gu_addr @@
drivers/vhost/vdpa.c:361:13: sparse: expected void const volatile [noderef] __user *ptr
drivers/vhost/vdpa.c:361:13: sparse: got unsigned int const *__gu_addr
--
drivers/net/ppp/pppoe.c:765:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user * @@
drivers/net/ppp/pppoe.c:765:21: sparse: expected int const *__gu_addr
drivers/net/ppp/pppoe.c:765:21: sparse: got int [noderef] __user *
>> drivers/net/ppp/pppoe.c:765:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/pppoe.c:765:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/pppoe.c:765:21: sparse: got int const *__gu_addr
drivers/net/ppp/pppoe.c:778:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user * @@
drivers/net/ppp/pppoe.c:778:21: sparse: expected int const *__gu_addr
drivers/net/ppp/pppoe.c:778:21: sparse: got int [noderef] __user *
drivers/net/ppp/pppoe.c:778:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/pppoe.c:778:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/pppoe.c:778:21: sparse: got int const *__gu_addr
--
drivers/net/ppp/ppp_generic.c:925:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:925:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:925:21: sparse: got int [noderef] __user *p
>> drivers/net/ppp/ppp_generic.c:925:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:925:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:925:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:939:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:939:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:939:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:939:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:939:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:939:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:954:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:954:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:954:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:954:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:954:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:954:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:651:29: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:651:29: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:651:29: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:651:29: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:651:29: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:651:29: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:681:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:681:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:681:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:681:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:681:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:681:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:688:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:688:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:688:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:688:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:688:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:688:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:726:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:726:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:726:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:726:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:726:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:726:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:755:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:755:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:755:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:755:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:755:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:755:21: sparse: got int const *__gu_addr
drivers/net/ppp/ppp_generic.c:823:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *p @@
drivers/net/ppp/ppp_generic.c:823:21: sparse: expected int const *__gu_addr
drivers/net/ppp/ppp_generic.c:823:21: sparse: got int [noderef] __user *p
drivers/net/ppp/ppp_generic.c:823:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
drivers/net/ppp/ppp_generic.c:823:21: sparse: expected void const volatile [noderef] __user *ptr
drivers/net/ppp/ppp_generic.c:823:21: sparse: got int const *__gu_addr
--
net/atm/pppoatm.c:376:24: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user * @@
net/atm/pppoatm.c:376:24: sparse: expected int const *__gu_addr
net/atm/pppoatm.c:376:24: sparse: got int [noderef] __user *
>> net/atm/pppoatm.c:376:24: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
net/atm/pppoatm.c:376:24: sparse: expected void const volatile [noderef] __user *ptr
net/atm/pppoatm.c:376:24: sparse: got int const *__gu_addr
net/atm/pppoatm.c:453:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned short const *__gu_addr @@ got unsigned short [noderef] [usertype] __user * @@
net/atm/pppoatm.c:453:21: sparse: expected unsigned short const *__gu_addr
net/atm/pppoatm.c:453:21: sparse: got unsigned short [noderef] [usertype] __user *
>> net/atm/pppoatm.c:453:21: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got unsigned short const *__gu_addr @@
net/atm/pppoatm.c:453:21: sparse: expected void const volatile [noderef] __user *ptr
net/atm/pppoatm.c:453:21: sparse: got unsigned short const *__gu_addr
--
net/packet/af_packet.c:3942:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *optlen @@
net/packet/af_packet.c:3942:13: sparse: expected int const *__gu_addr
net/packet/af_packet.c:3942:13: sparse: got int [noderef] __user *optlen
>> net/packet/af_packet.c:3942:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
net/packet/af_packet.c:3942:13: sparse: expected void const volatile [noderef] __user *ptr
net/packet/af_packet.c:3942:13: sparse: got int const *__gu_addr
net/packet/af_packet.c:1008:13: sparse: sparse: context imbalance in '__packet_lookup_frame_in_block' - different lock contexts for basic block
net/packet/af_packet.c:2402:17: sparse: sparse: context imbalance in 'tpacket_rcv' - unexpected unlock
--
net/xdp/xsk.c:835:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected int const *__gu_addr @@ got int [noderef] __user *optlen @@
net/xdp/xsk.c:835:13: sparse: expected int const *__gu_addr
net/xdp/xsk.c:835:13: sparse: got int [noderef] __user *optlen
>> net/xdp/xsk.c:835:13: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const volatile [noderef] __user *ptr @@ got int const *__gu_addr @@
net/xdp/xsk.c:835:13: sparse: expected void const volatile [noderef] __user *ptr
net/xdp/xsk.c:835:13: sparse: got int const *__gu_addr

vim +361 drivers/vhost/vdpa.c

2cf1ba9a4d15cb78 Zhu Lingshan 2020-07-31 346
4c8cf31885f69e86 Tiwei Bie 2020-03-26 347 static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,
4c8cf31885f69e86 Tiwei Bie 2020-03-26 348 void __user *argp)
4c8cf31885f69e86 Tiwei Bie 2020-03-26 349 {
4c8cf31885f69e86 Tiwei Bie 2020-03-26 350 struct vdpa_device *vdpa = v->vdpa;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 351 const struct vdpa_config_ops *ops = vdpa->config;
aac50c0bd434794b Eli Cohen 2020-08-04 352 struct vdpa_vq_state vq_state;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 353 struct vdpa_callback cb;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 354 struct vhost_virtqueue *vq;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 355 struct vhost_vring_state s;
653055b9acd45d60 Jason Wang 2020-08-04 356 u64 __user *featurep = argp;
653055b9acd45d60 Jason Wang 2020-08-04 357 u64 features;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 358 u32 idx;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 359 long r;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 360
4c8cf31885f69e86 Tiwei Bie 2020-03-26 @361 r = get_user(idx, (u32 __user *)argp);
4c8cf31885f69e86 Tiwei Bie 2020-03-26 362 if (r < 0)
4c8cf31885f69e86 Tiwei Bie 2020-03-26 363 return r;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 364
4c8cf31885f69e86 Tiwei Bie 2020-03-26 365 if (idx >= v->nvqs)
4c8cf31885f69e86 Tiwei Bie 2020-03-26 366 return -ENOBUFS;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 367
4c8cf31885f69e86 Tiwei Bie 2020-03-26 368 idx = array_index_nospec(idx, v->nvqs);
4c8cf31885f69e86 Tiwei Bie 2020-03-26 369 vq = &v->vqs[idx];
4c8cf31885f69e86 Tiwei Bie 2020-03-26 370
b0bd82bf729dbd05 Jason Wang 2020-08-04 371 switch (cmd) {
b0bd82bf729dbd05 Jason Wang 2020-08-04 372 case VHOST_VDPA_SET_VRING_ENABLE:
4c8cf31885f69e86 Tiwei Bie 2020-03-26 373 if (copy_from_user(&s, argp, sizeof(s)))
4c8cf31885f69e86 Tiwei Bie 2020-03-26 374 return -EFAULT;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 375 ops->set_vq_ready(vdpa, idx, s.num);
4c8cf31885f69e86 Tiwei Bie 2020-03-26 376 return 0;
b0bd82bf729dbd05 Jason Wang 2020-08-04 377 case VHOST_GET_VRING_BASE:
23750e39d57433d0 Eli Cohen 2020-08-04 378 r = ops->get_vq_state(v->vdpa, idx, &vq_state);
23750e39d57433d0 Eli Cohen 2020-08-04 379 if (r)
23750e39d57433d0 Eli Cohen 2020-08-04 380 return r;
23750e39d57433d0 Eli Cohen 2020-08-04 381
aac50c0bd434794b Eli Cohen 2020-08-04 382 vq->last_avail_idx = vq_state.avail_index;
b0bd82bf729dbd05 Jason Wang 2020-08-04 383 break;
653055b9acd45d60 Jason Wang 2020-08-04 384 case VHOST_GET_BACKEND_FEATURES:
653055b9acd45d60 Jason Wang 2020-08-04 385 features = VHOST_VDPA_BACKEND_FEATURES;
653055b9acd45d60 Jason Wang 2020-08-04 386 if (copy_to_user(featurep, &features, sizeof(features)))
653055b9acd45d60 Jason Wang 2020-08-04 387 return -EFAULT;
653055b9acd45d60 Jason Wang 2020-08-04 388 return 0;
653055b9acd45d60 Jason Wang 2020-08-04 389 case VHOST_SET_BACKEND_FEATURES:
653055b9acd45d60 Jason Wang 2020-08-04 390 if (copy_from_user(&features, featurep, sizeof(features)))
653055b9acd45d60 Jason Wang 2020-08-04 391 return -EFAULT;
653055b9acd45d60 Jason Wang 2020-08-04 392 if (features & ~VHOST_VDPA_BACKEND_FEATURES)
653055b9acd45d60 Jason Wang 2020-08-04 393 return -EOPNOTSUPP;
653055b9acd45d60 Jason Wang 2020-08-04 394 vhost_set_backend_features(&v->vdev, features);
653055b9acd45d60 Jason Wang 2020-08-04 395 return 0;
b0bd82bf729dbd05 Jason Wang 2020-08-04 396 }
4c8cf31885f69e86 Tiwei Bie 2020-03-26 397
4c8cf31885f69e86 Tiwei Bie 2020-03-26 398 r = vhost_vring_ioctl(&v->vdev, cmd, argp);
4c8cf31885f69e86 Tiwei Bie 2020-03-26 399 if (r)
4c8cf31885f69e86 Tiwei Bie 2020-03-26 400 return r;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 401
4c8cf31885f69e86 Tiwei Bie 2020-03-26 402 switch (cmd) {
4c8cf31885f69e86 Tiwei Bie 2020-03-26 403 case VHOST_SET_VRING_ADDR:
4c8cf31885f69e86 Tiwei Bie 2020-03-26 404 if (ops->set_vq_address(vdpa, idx,
4c8cf31885f69e86 Tiwei Bie 2020-03-26 405 (u64)(uintptr_t)vq->desc,
4c8cf31885f69e86 Tiwei Bie 2020-03-26 406 (u64)(uintptr_t)vq->avail,
4c8cf31885f69e86 Tiwei Bie 2020-03-26 407 (u64)(uintptr_t)vq->used))
4c8cf31885f69e86 Tiwei Bie 2020-03-26 408 r = -EINVAL;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 409 break;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 410
4c8cf31885f69e86 Tiwei Bie 2020-03-26 411 case VHOST_SET_VRING_BASE:
aac50c0bd434794b Eli Cohen 2020-08-04 412 vq_state.avail_index = vq->last_avail_idx;
aac50c0bd434794b Eli Cohen 2020-08-04 413 if (ops->set_vq_state(vdpa, idx, &vq_state))
4c8cf31885f69e86 Tiwei Bie 2020-03-26 414 r = -EINVAL;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 415 break;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 416
4c8cf31885f69e86 Tiwei Bie 2020-03-26 417 case VHOST_SET_VRING_CALL:
265a0ad8731dc04f Zhu Lingshan 2020-07-31 418 if (vq->call_ctx.ctx) {
4c8cf31885f69e86 Tiwei Bie 2020-03-26 419 cb.callback = vhost_vdpa_virtqueue_cb;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 420 cb.private = vq;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 421 } else {
4c8cf31885f69e86 Tiwei Bie 2020-03-26 422 cb.callback = NULL;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 423 cb.private = NULL;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 424 }
4c8cf31885f69e86 Tiwei Bie 2020-03-26 425 ops->set_vq_cb(vdpa, idx, &cb);
2cf1ba9a4d15cb78 Zhu Lingshan 2020-07-31 426 vhost_vdpa_setup_vq_irq(v, idx);
4c8cf31885f69e86 Tiwei Bie 2020-03-26 427 break;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 428
4c8cf31885f69e86 Tiwei Bie 2020-03-26 429 case VHOST_SET_VRING_NUM:
4c8cf31885f69e86 Tiwei Bie 2020-03-26 430 ops->set_vq_num(vdpa, idx, vq->num);
4c8cf31885f69e86 Tiwei Bie 2020-03-26 431 break;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 432 }
4c8cf31885f69e86 Tiwei Bie 2020-03-26 433
4c8cf31885f69e86 Tiwei Bie 2020-03-26 434 return r;
4c8cf31885f69e86 Tiwei Bie 2020-03-26 435 }
4c8cf31885f69e86 Tiwei Bie 2020-03-26 436

:::::: The code at line 361 was first introduced by commit
:::::: 4c8cf31885f69e86be0b5b9e6677a26797365e1d vhost: introduce vDPA-based backend

:::::: TO: Tiwei Bie <tiwei.bie@xxxxxxxxx>
:::::: CC: Michael S. Tsirkin <mst@xxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip