drivers/vhost/vringh.c:586:18: sparse: sparse: restricted __virtio16 degrades to integer

From: kernel test robot
Date: Tue Nov 30 2021 - 23:34:13 EST


Hi Eli,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 58e1100fdc5990b0cc0d4beaf2562a92e621ac7d
commit: 5262912ef3cfc5e518892c3d67fb36412cb813e2 vdpa/mlx5: Add support for control VQ and MAC setting
date: 3 months ago
config: riscv-randconfig-s031-20211201 (https://download.01.org/0day-ci/archive/20211201/202112011211.B9QiemfX-lkp@xxxxxxxxx/config)
compiler: riscv32-linux-gcc (GCC) 11.2.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.4-dirty
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5262912ef3cfc5e518892c3d67fb36412cb813e2
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 5262912ef3cfc5e518892c3d67fb36412cb813e2
# save the config file to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=riscv SHELL=/bin/bash drivers/vhost/

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/vringh.c:586:18: sparse: sparse: restricted __virtio16 degrades to integer
>> drivers/vhost/vringh.c:586:18: sparse: sparse: restricted __virtio16 degrades to integer
>> drivers/vhost/vringh.c:586:18: sparse: sparse: cast to restricted __virtio16
drivers/vhost/vringh.c:594:16: sparse: sparse: restricted __virtio16 degrades to integer
drivers/vhost/vringh.c:594:16: sparse: sparse: restricted __virtio16 degrades to integer
>> drivers/vhost/vringh.c:594:16: sparse: sparse: cast from restricted __virtio16

vim +586 drivers/vhost/vringh.c

f87d0fbb579818 Rusty Russell 2013-03-20 581
f87d0fbb579818 Rusty Russell 2013-03-20 582 /* Userspace access helpers: in this case, addresses are really userspace. */
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 583 static inline int getu16_user(const struct vringh *vrh, u16 *val, const __virtio16 *p)
f87d0fbb579818 Rusty Russell 2013-03-20 584 {
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 585 __virtio16 v = 0;
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 @586 int rc = get_user(v, (__force __virtio16 __user *)p);
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 587 *val = vringh16_to_cpu(vrh, v);
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 588 return rc;
f87d0fbb579818 Rusty Russell 2013-03-20 589 }
f87d0fbb579818 Rusty Russell 2013-03-20 590
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 591 static inline int putu16_user(const struct vringh *vrh, __virtio16 *p, u16 val)
f87d0fbb579818 Rusty Russell 2013-03-20 592 {
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 593 __virtio16 v = cpu_to_vringh16(vrh, val);
b9f7ac8c72894c Michael S. Tsirkin 2014-12-12 @594 return put_user(v, (__force __virtio16 __user *)p);
f87d0fbb579818 Rusty Russell 2013-03-20 595 }
f87d0fbb579818 Rusty Russell 2013-03-20 596

:::::: The code at line 586 was first introduced by commit
:::::: b9f7ac8c72894c19bf258a54ecaa708df4ffbe80 vringh: update for virtio 1.0 APIs

:::::: TO: Michael S. Tsirkin <mst@xxxxxxxxxx>
:::::: CC: Michael S. Tsirkin <mst@xxxxxxxxxx>

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