[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202005200022.yczjkPeJ%lkp@intel.com>
Date: Wed, 20 May 2020 00:57:31 +0800
From: kbuild test robot <lkp@...el.com>
To: Jason Wang <jasowang@...hat.com>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
"Michael S. Tsirkin" <mst@...hat.com>
Subject: drivers/vhost/vhost.c:1603:13: sparse: sparse: incorrect type in
initializer (different address spaces)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 642b151f45dd54809ea00ecd3976a56c1ec9b53d
commit: 20c384f1ea1a0bc7320bc445c72dd02d2970d594 vhost: refine vhost and vringh kconfig
date: 7 weeks ago
config: m68k-randconfig-s001-20200519 (attached as .config)
reproduce:
# apt-get install sparse
# sparse version: v0.6.1-193-gb8fad4bc-dirty
git checkout 20c384f1ea1a0bc7320bc445c72dd02d2970d594
# save the attached .config to linux build tree
make C=1 ARCH=m68k CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/vhost/vhost.c:1603:13: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got unsigned int [noderef] [usertypvoid const *__gu_ptr @@
>> drivers/vhost/vhost.c:1603:13: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:1603:13: sparse: got unsigned int [noderef] [usertype] <asn:1> *idxp
>> drivers/vhost/vhost.c:1800:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got int [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:1800:21: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:1800:21: sparse: got int [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:937:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:937:16: sparse: expected void *addr
drivers/vhost/vhost.c:937:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:922:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] [usertype] <asvoid *addr @@
drivers/vhost/vhost.c:922:16: sparse: expected void *addr
drivers/vhost/vhost.c:922:16: sparse: got restricted __virtio16 [noderef] [usertype] <asn:1> *
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
>> drivers/vhost/vhost.c:1014:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:1014:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:1014:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:1014:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:1014:16: sparse: expected void *addr
drivers/vhost/vhost.c:1014:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
>> drivers/vhost/vhost.c:1014:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:1014:16: sparse: expected void const *__gu_ptr
>> drivers/vhost/vhost.c:1014:16: sparse: got restricted __virtio16 [noderef] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:989:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:989:16: sparse: expected void *addr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:989:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:995:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:995:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:995:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:995:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:995:16: sparse: expected void *addr
drivers/vhost/vhost.c:995:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:995:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:995:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:995:16: sparse: got restricted __virtio16 [noderef] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:944:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:944:16: sparse: expected void *addr
drivers/vhost/vhost.c:944:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:1002:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:1002:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:1002:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:1002:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:1002:16: sparse: expected void *addr
drivers/vhost/vhost.c:1002:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:1002:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:1002:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:1002:16: sparse: got restricted __virtio16 [noderef] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
>> drivers/vhost/vhost.c:1008:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderef] [usertypvoid const *__gu_ptr @@
drivers/vhost/vhost.c:1008:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:1008:16: sparse: got restricted __virtio16 [noderef] [usertype] <asn:1> *
drivers/vhost/vhost.c:1008:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] [usertype] <asvoid *addr @@
drivers/vhost/vhost.c:1008:16: sparse: expected void *addr
drivers/vhost/vhost.c:1008:16: sparse: got restricted __virtio16 [noderef] [usertype] <asn:1> *
>> drivers/vhost/vhost.c:1008:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderef] [usertypvoid const *__gu_ptr @@
drivers/vhost/vhost.c:1008:16: sparse: expected void const *__gu_ptr
>> drivers/vhost/vhost.c:1008:16: sparse: got restricted __virtio16 [noderef] [usertype] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:989:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:989:16: sparse: expected void *addr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:989:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:989:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void *addr @@ got restricted __virtio16 [noderef] <asvoid *addr @@
drivers/vhost/vhost.c:989:16: sparse: expected void *addr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *
drivers/vhost/vhost.c:989:16: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got restricted __virtio16 [noderevoid const *__gu_ptr @@
drivers/vhost/vhost.c:989:16: sparse: expected void const *__gu_ptr
drivers/vhost/vhost.c:989:16: sparse: got restricted __virtio16 [noderef] <asn:1> *from
drivers/vhost/vhost.c:900:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] <asn:1> *addr @@ got n:1> *addr @@
drivers/vhost/vhost.c:900:42: sparse: expected void [noderef] <asn:1> *addr
drivers/vhost/vhost.c:900:42: sparse: got void *addr
drivers/vhost/vhost.c:753:17: sparse: sparse: incorrect type in return expression (different address spaces) @@ expected void [noderef] <asn:1> * @@ got n:1> * @@
drivers/vhost/vhost.c:753:17: sparse: expected void [noderef] <asn:1> *
drivers/vhost/vhost.c:753:17: sparse: got void *
--
drivers/vhost/scsi.c:1218:30: sparse: sparse: restricted __virtio32 degrades to integer
drivers/vhost/scsi.c:1218:30: sparse: sparse: restricted __virtio32 degrades to integer
>> drivers/vhost/scsi.c:1697:21: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected void const *__gu_ptr @@ got unsigned int [noderef] [usertypvoid const *__gu_ptr @@
>> drivers/vhost/scsi.c:1697:21: sparse: expected void const *__gu_ptr
drivers/vhost/scsi.c:1697:21: sparse: got unsigned int [noderef] [usertype] <asn:1> *eventsp
vim +1603 drivers/vhost/vhost.c
feebcaeac79ad86 Jason Wang 2019-05-24 1566
feebcaeac79ad86 Jason Wang 2019-05-24 1567 static long vhost_vring_set_num_addr(struct vhost_dev *d,
feebcaeac79ad86 Jason Wang 2019-05-24 1568 struct vhost_virtqueue *vq,
feebcaeac79ad86 Jason Wang 2019-05-24 1569 unsigned int ioctl,
feebcaeac79ad86 Jason Wang 2019-05-24 1570 void __user *argp)
feebcaeac79ad86 Jason Wang 2019-05-24 1571 {
feebcaeac79ad86 Jason Wang 2019-05-24 1572 long r;
feebcaeac79ad86 Jason Wang 2019-05-24 1573
feebcaeac79ad86 Jason Wang 2019-05-24 1574 mutex_lock(&vq->mutex);
feebcaeac79ad86 Jason Wang 2019-05-24 1575
feebcaeac79ad86 Jason Wang 2019-05-24 1576 switch (ioctl) {
feebcaeac79ad86 Jason Wang 2019-05-24 1577 case VHOST_SET_VRING_NUM:
feebcaeac79ad86 Jason Wang 2019-05-24 1578 r = vhost_vring_set_num(d, vq, argp);
feebcaeac79ad86 Jason Wang 2019-05-24 1579 break;
feebcaeac79ad86 Jason Wang 2019-05-24 1580 case VHOST_SET_VRING_ADDR:
feebcaeac79ad86 Jason Wang 2019-05-24 1581 r = vhost_vring_set_addr(d, vq, argp);
feebcaeac79ad86 Jason Wang 2019-05-24 1582 break;
feebcaeac79ad86 Jason Wang 2019-05-24 1583 default:
feebcaeac79ad86 Jason Wang 2019-05-24 1584 BUG();
feebcaeac79ad86 Jason Wang 2019-05-24 1585 }
feebcaeac79ad86 Jason Wang 2019-05-24 1586
feebcaeac79ad86 Jason Wang 2019-05-24 1587 mutex_unlock(&vq->mutex);
feebcaeac79ad86 Jason Wang 2019-05-24 1588
feebcaeac79ad86 Jason Wang 2019-05-24 1589 return r;
feebcaeac79ad86 Jason Wang 2019-05-24 1590 }
26b36604523f4a6 Sonny Rao 2018-03-14 1591 long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1592 {
cecb46f194460d2 Al Viro 2012-08-27 1593 struct file *eventfp, *filep = NULL;
cecb46f194460d2 Al Viro 2012-08-27 1594 bool pollstart = false, pollstop = false;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1595 struct eventfd_ctx *ctx = NULL;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1596 u32 __user *idxp = argp;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1597 struct vhost_virtqueue *vq;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1598 struct vhost_vring_state s;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1599 struct vhost_vring_file f;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1600 u32 idx;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1601 long r;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1602
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 @1603 r = get_user(idx, idxp);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1604 if (r < 0)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1605 return r;
0f3d9a17469d71b Krishna Kumar 2010-05-25 1606 if (idx >= d->nvqs)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1607 return -ENOBUFS;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1608
ff002269a4ee9c7 Jason Wang 2018-10-30 1609 idx = array_index_nospec(idx, d->nvqs);
3ab2e420ec1caf4 Asias He 2013-04-27 1610 vq = d->vqs[idx];
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1611
feebcaeac79ad86 Jason Wang 2019-05-24 1612 if (ioctl == VHOST_SET_VRING_NUM ||
feebcaeac79ad86 Jason Wang 2019-05-24 1613 ioctl == VHOST_SET_VRING_ADDR) {
feebcaeac79ad86 Jason Wang 2019-05-24 1614 return vhost_vring_set_num_addr(d, vq, ioctl, argp);
feebcaeac79ad86 Jason Wang 2019-05-24 1615 }
feebcaeac79ad86 Jason Wang 2019-05-24 1616
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1617 mutex_lock(&vq->mutex);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1618
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1619 switch (ioctl) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1620 case VHOST_SET_VRING_BASE:
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1621 /* Moving base with an active backend?
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1622 * You don't want to do that. */
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1623 if (vq->private_data) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1624 r = -EBUSY;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1625 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1626 }
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1627 if (copy_from_user(&s, argp, sizeof s)) {
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1628 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1629 break;
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1630 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1631 if (s.num > 0xffff) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1632 r = -EINVAL;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1633 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1634 }
8d65843c44269c2 Jason Wang 2017-07-27 1635 vq->last_avail_idx = s.num;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1636 /* Forget the cached index value. */
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1637 vq->avail_idx = vq->last_avail_idx;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1638 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1639 case VHOST_GET_VRING_BASE:
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1640 s.index = idx;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1641 s.num = vq->last_avail_idx;
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1642 if (copy_to_user(argp, &s, sizeof s))
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1643 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1644 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1645 case VHOST_SET_VRING_KICK:
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1646 if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1647 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1648 break;
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1649 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1650 eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1651 if (IS_ERR(eventfp)) {
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1652 r = PTR_ERR(eventfp);
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1653 break;
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1654 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1655 if (eventfp != vq->kick) {
cecb46f194460d2 Al Viro 2012-08-27 1656 pollstop = (filep = vq->kick) != NULL;
cecb46f194460d2 Al Viro 2012-08-27 1657 pollstart = (vq->kick = eventfp) != NULL;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1658 } else
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1659 filep = eventfp;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1660 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1661 case VHOST_SET_VRING_CALL:
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1662 if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1663 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1664 break;
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1665 }
e050c7d93f4adb2 Eric Biggers 2018-01-06 1666 ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
e050c7d93f4adb2 Eric Biggers 2018-01-06 1667 if (IS_ERR(ctx)) {
e050c7d93f4adb2 Eric Biggers 2018-01-06 1668 r = PTR_ERR(ctx);
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1669 break;
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1670 }
e050c7d93f4adb2 Eric Biggers 2018-01-06 1671 swap(ctx, vq->call_ctx);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1672 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1673 case VHOST_SET_VRING_ERR:
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1674 if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1675 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1676 break;
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1677 }
09f332a589232f5 Eric Biggers 2018-01-06 1678 ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
09f332a589232f5 Eric Biggers 2018-01-06 1679 if (IS_ERR(ctx)) {
09f332a589232f5 Eric Biggers 2018-01-06 1680 r = PTR_ERR(ctx);
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1681 break;
535297a6ae4c3b7 Michael S. Tsirkin 2010-03-17 1682 }
09f332a589232f5 Eric Biggers 2018-01-06 1683 swap(ctx, vq->error_ctx);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1684 break;
2751c9882b94729 Greg Kurz 2015-04-24 1685 case VHOST_SET_VRING_ENDIAN:
2751c9882b94729 Greg Kurz 2015-04-24 1686 r = vhost_set_vring_endian(vq, argp);
2751c9882b94729 Greg Kurz 2015-04-24 1687 break;
2751c9882b94729 Greg Kurz 2015-04-24 1688 case VHOST_GET_VRING_ENDIAN:
2751c9882b94729 Greg Kurz 2015-04-24 1689 r = vhost_get_vring_endian(vq, idx, argp);
2751c9882b94729 Greg Kurz 2015-04-24 1690 break;
030881372460654 Jason Wang 2016-03-04 1691 case VHOST_SET_VRING_BUSYLOOP_TIMEOUT:
030881372460654 Jason Wang 2016-03-04 1692 if (copy_from_user(&s, argp, sizeof(s))) {
030881372460654 Jason Wang 2016-03-04 1693 r = -EFAULT;
030881372460654 Jason Wang 2016-03-04 1694 break;
030881372460654 Jason Wang 2016-03-04 1695 }
030881372460654 Jason Wang 2016-03-04 1696 vq->busyloop_timeout = s.num;
030881372460654 Jason Wang 2016-03-04 1697 break;
030881372460654 Jason Wang 2016-03-04 1698 case VHOST_GET_VRING_BUSYLOOP_TIMEOUT:
030881372460654 Jason Wang 2016-03-04 1699 s.index = idx;
030881372460654 Jason Wang 2016-03-04 1700 s.num = vq->busyloop_timeout;
030881372460654 Jason Wang 2016-03-04 1701 if (copy_to_user(argp, &s, sizeof(s)))
030881372460654 Jason Wang 2016-03-04 1702 r = -EFAULT;
030881372460654 Jason Wang 2016-03-04 1703 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1704 default:
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1705 r = -ENOIOCTLCMD;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1706 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1707
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1708 if (pollstop && vq->handle_kick)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1709 vhost_poll_stop(&vq->poll);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1710
e050c7d93f4adb2 Eric Biggers 2018-01-06 1711 if (!IS_ERR_OR_NULL(ctx))
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1712 eventfd_ctx_put(ctx);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1713 if (filep)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1714 fput(filep);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1715
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1716 if (pollstart && vq->handle_kick)
2b8b328b61c7999 Jason Wang 2013-01-28 1717 r = vhost_poll_start(&vq->poll, vq->kick);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1718
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1719 mutex_unlock(&vq->mutex);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1720
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1721 if (pollstop && vq->handle_kick)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1722 vhost_poll_flush(&vq->poll);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1723 return r;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1724 }
6ac1afbf6132df0 Asias He 2013-05-06 1725 EXPORT_SYMBOL_GPL(vhost_vring_ioctl);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1726
6b1e6cc7855b09a Jason Wang 2016-06-23 1727 int vhost_init_device_iotlb(struct vhost_dev *d, bool enabled)
6b1e6cc7855b09a Jason Wang 2016-06-23 1728 {
6b1e6cc7855b09a Jason Wang 2016-06-23 1729 struct vhost_umem *niotlb, *oiotlb;
6b1e6cc7855b09a Jason Wang 2016-06-23 1730 int i;
6b1e6cc7855b09a Jason Wang 2016-06-23 1731
6b1e6cc7855b09a Jason Wang 2016-06-23 1732 niotlb = vhost_umem_alloc();
6b1e6cc7855b09a Jason Wang 2016-06-23 1733 if (!niotlb)
6b1e6cc7855b09a Jason Wang 2016-06-23 1734 return -ENOMEM;
6b1e6cc7855b09a Jason Wang 2016-06-23 1735
6b1e6cc7855b09a Jason Wang 2016-06-23 1736 oiotlb = d->iotlb;
6b1e6cc7855b09a Jason Wang 2016-06-23 1737 d->iotlb = niotlb;
6b1e6cc7855b09a Jason Wang 2016-06-23 1738
6b1e6cc7855b09a Jason Wang 2016-06-23 1739 for (i = 0; i < d->nvqs; ++i) {
b13f9c6364373a1 Jason Wang 2018-08-08 1740 struct vhost_virtqueue *vq = d->vqs[i];
b13f9c6364373a1 Jason Wang 2018-08-08 1741
b13f9c6364373a1 Jason Wang 2018-08-08 1742 mutex_lock(&vq->mutex);
b13f9c6364373a1 Jason Wang 2018-08-08 1743 vq->iotlb = niotlb;
b13f9c6364373a1 Jason Wang 2018-08-08 1744 __vhost_vq_meta_reset(vq);
b13f9c6364373a1 Jason Wang 2018-08-08 1745 mutex_unlock(&vq->mutex);
6b1e6cc7855b09a Jason Wang 2016-06-23 1746 }
6b1e6cc7855b09a Jason Wang 2016-06-23 1747
6b1e6cc7855b09a Jason Wang 2016-06-23 1748 vhost_umem_clean(oiotlb);
6b1e6cc7855b09a Jason Wang 2016-06-23 1749
6b1e6cc7855b09a Jason Wang 2016-06-23 1750 return 0;
6b1e6cc7855b09a Jason Wang 2016-06-23 1751 }
6b1e6cc7855b09a Jason Wang 2016-06-23 1752 EXPORT_SYMBOL_GPL(vhost_init_device_iotlb);
6b1e6cc7855b09a Jason Wang 2016-06-23 1753
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1754 /* Caller must have device mutex */
935cdee7ee15956 Michael S. Tsirkin 2012-12-06 1755 long vhost_dev_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1756 {
d25cc43c6775bff Eric Biggers 2018-01-06 1757 struct eventfd_ctx *ctx;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1758 u64 p;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1759 long r;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1760 int i, fd;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1761
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1762 /* If you are not the owner, you can become one */
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1763 if (ioctl == VHOST_SET_OWNER) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1764 r = vhost_dev_set_owner(d);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1765 goto done;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1766 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1767
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1768 /* You must be the owner to do anything else */
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1769 r = vhost_dev_check_owner(d);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1770 if (r)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1771 goto done;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1772
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1773 switch (ioctl) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1774 case VHOST_SET_MEM_TABLE:
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1775 r = vhost_set_memory(d, argp);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1776 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1777 case VHOST_SET_LOG_BASE:
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1778 if (copy_from_user(&p, argp, sizeof p)) {
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1779 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1780 break;
7ad9c9d27048547 Takuya Yoshikawa 2010-05-27 1781 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1782 if ((u64)(unsigned long)p != p) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1783 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1784 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1785 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1786 for (i = 0; i < d->nvqs; ++i) {
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1787 struct vhost_virtqueue *vq;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1788 void __user *base = (void __user *)(unsigned long)p;
3ab2e420ec1caf4 Asias He 2013-04-27 1789 vq = d->vqs[i];
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1790 mutex_lock(&vq->mutex);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1791 /* If ring is inactive, will check when it's enabled. */
ea16c51433510f7 Michael S. Tsirkin 2014-06-05 1792 if (vq->private_data && !vq_log_access_ok(vq, base))
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1793 r = -EFAULT;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1794 else
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1795 vq->log_base = base;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1796 mutex_unlock(&vq->mutex);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1797 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1798 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1799 case VHOST_SET_LOG_FD:
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 @1800 r = get_user(fd, (int __user *)argp);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1801 if (r < 0)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1802 break;
d25cc43c6775bff Eric Biggers 2018-01-06 1803 ctx = fd == -1 ? NULL : eventfd_ctx_fdget(fd);
d25cc43c6775bff Eric Biggers 2018-01-06 1804 if (IS_ERR(ctx)) {
d25cc43c6775bff Eric Biggers 2018-01-06 1805 r = PTR_ERR(ctx);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1806 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1807 }
d25cc43c6775bff Eric Biggers 2018-01-06 1808 swap(ctx, d->log_ctx);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1809 for (i = 0; i < d->nvqs; ++i) {
3ab2e420ec1caf4 Asias He 2013-04-27 1810 mutex_lock(&d->vqs[i]->mutex);
3ab2e420ec1caf4 Asias He 2013-04-27 1811 d->vqs[i]->log_ctx = d->log_ctx;
3ab2e420ec1caf4 Asias He 2013-04-27 1812 mutex_unlock(&d->vqs[i]->mutex);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1813 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1814 if (ctx)
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1815 eventfd_ctx_put(ctx);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1816 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1817 default:
935cdee7ee15956 Michael S. Tsirkin 2012-12-06 1818 r = -ENOIOCTLCMD;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1819 break;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1820 }
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1821 done:
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1822 return r;
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1823 }
6ac1afbf6132df0 Asias He 2013-05-06 1824 EXPORT_SYMBOL_GPL(vhost_dev_ioctl);
3a4d5c94e959359 Michael S. Tsirkin 2010-01-14 1825
:::::: The code at line 1603 was first introduced by commit
:::::: 3a4d5c94e959359ece6d6b55045c3f046677f55c vhost_net: a kernel-level virtio server
:::::: TO: Michael S. Tsirkin <mst@...hat.com>
:::::: CC: David S. Miller <davem@...emloft.net>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (30259 bytes)
Powered by blists - more mailing lists