diff mbox series

vhost: do not enable VHOST_MENU by default

Message ID 20200414024438.19103-1-jasowang@redhat.com (mailing list archive)
State New, archived
Headers show
Series vhost: do not enable VHOST_MENU by default | expand

Commit Message

Jason Wang April 14, 2020, 2:44 a.m. UTC
We try to keep the defconfig untouched after decoupling CONFIG_VHOST
out of CONFIG_VIRTUALIZATION in commit 20c384f1ea1a
("vhost: refine vhost and vringh kconfig") by enabling VHOST_MENU by
default. Then the defconfigs can keep enabling CONFIG_VHOST_NET
without the caring of CONFIG_VHOST.

But this will leave a "CONFIG_VHOST_MENU=y" in all defconfigs and even
for the ones that doesn't want vhost. So it actually shifts the
burdens to the maintainers of all other to add "CONFIG_VHOST_MENU is
not set". So this patch tries to enable CONFIG_VHOST explicitly in
defconfigs that enables CONFIG_VHOST_NET and CONFIG_VHOST_VSOCK.

Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 arch/mips/configs/malta_kvm_defconfig  |  1 +
 arch/powerpc/configs/powernv_defconfig |  1 +
 arch/powerpc/configs/ppc64_defconfig   |  1 +
 arch/powerpc/configs/pseries_defconfig |  1 +
 arch/s390/configs/debug_defconfig      |  1 +
 arch/s390/configs/defconfig            |  1 +
 drivers/vhost/Kconfig                  | 18 +++++-------------
 7 files changed, 11 insertions(+), 13 deletions(-)

Comments

Michael Ellerman April 14, 2020, 5:54 a.m. UTC | #1
Jason Wang <jasowang@redhat.com> writes:
> We try to keep the defconfig untouched after decoupling CONFIG_VHOST
> out of CONFIG_VIRTUALIZATION in commit 20c384f1ea1a
> ("vhost: refine vhost and vringh kconfig") by enabling VHOST_MENU by
> default. Then the defconfigs can keep enabling CONFIG_VHOST_NET
> without the caring of CONFIG_VHOST.
>
> But this will leave a "CONFIG_VHOST_MENU=y" in all defconfigs and even
> for the ones that doesn't want vhost. So it actually shifts the
> burdens to the maintainers of all other to add "CONFIG_VHOST_MENU is
> not set". So this patch tries to enable CONFIG_VHOST explicitly in
> defconfigs that enables CONFIG_VHOST_NET and CONFIG_VHOST_VSOCK.
>
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  arch/mips/configs/malta_kvm_defconfig  |  1 +
>  arch/powerpc/configs/powernv_defconfig |  1 +
>  arch/powerpc/configs/ppc64_defconfig   |  1 +
>  arch/powerpc/configs/pseries_defconfig |  1 +

Fine by me.

Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

cheers

>  arch/s390/configs/debug_defconfig      |  1 +
>  arch/s390/configs/defconfig            |  1 +
>  drivers/vhost/Kconfig                  | 18 +++++-------------
>  7 files changed, 11 insertions(+), 13 deletions(-)
>
> diff --git a/arch/mips/configs/malta_kvm_defconfig b/arch/mips/configs/malta_kvm_defconfig
> index 8ef612552a19..06f0c7a0ca87 100644
> --- a/arch/mips/configs/malta_kvm_defconfig
> +++ b/arch/mips/configs/malta_kvm_defconfig
> @@ -18,6 +18,7 @@ CONFIG_PCI=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM=m
>  CONFIG_KVM_MIPS_DEBUG_COP0_COUNTERS=y
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_MODULES=y
>  CONFIG_MODULE_UNLOAD=y
> diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig
> index 71749377d164..404245b4594d 100644
> --- a/arch/powerpc/configs/powernv_defconfig
> +++ b/arch/powerpc/configs/powernv_defconfig
> @@ -346,5 +346,6 @@ CONFIG_CRYPTO_DEV_VMX=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM_BOOK3S_64=m
>  CONFIG_KVM_BOOK3S_64_HV=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_PRINTK_TIME=y
> diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
> index 7e68cb222c7b..4599fc7be285 100644
> --- a/arch/powerpc/configs/ppc64_defconfig
> +++ b/arch/powerpc/configs/ppc64_defconfig
> @@ -61,6 +61,7 @@ CONFIG_ELECTRA_CF=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM_BOOK3S_64=m
>  CONFIG_KVM_BOOK3S_64_HV=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_OPROFILE=m
>  CONFIG_KPROBES=y
> diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
> index 6b68109e248f..4cad3901b5de 100644
> --- a/arch/powerpc/configs/pseries_defconfig
> +++ b/arch/powerpc/configs/pseries_defconfig
> @@ -321,5 +321,6 @@ CONFIG_CRYPTO_DEV_VMX=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM_BOOK3S_64=m
>  CONFIG_KVM_BOOK3S_64_HV=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_PRINTK_TIME=y
> diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig
> index 0c86ba19fa2b..6ec6e69630d1 100644
> --- a/arch/s390/configs/debug_defconfig
> +++ b/arch/s390/configs/debug_defconfig
> @@ -57,6 +57,7 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
>  CONFIG_CMM=m
>  CONFIG_APPLDATA_BASE=y
>  CONFIG_KVM=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_VHOST_VSOCK=m
>  CONFIG_OPROFILE=m
> diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig
> index 6b27d861a9a3..d1b3bf83d687 100644
> --- a/arch/s390/configs/defconfig
> +++ b/arch/s390/configs/defconfig
> @@ -57,6 +57,7 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
>  CONFIG_CMM=m
>  CONFIG_APPLDATA_BASE=y
>  CONFIG_KVM=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_VHOST_VSOCK=m
>  CONFIG_OPROFILE=m
> diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
> index e79cbbdfea45..14d296dc18cd 100644
> --- a/drivers/vhost/Kconfig
> +++ b/drivers/vhost/Kconfig
> @@ -12,23 +12,18 @@ config VHOST_RING
>  	  This option is selected by any driver which needs to access
>  	  the host side of a virtio ring.
>  
> -config VHOST
> -	tristate
> +menuconfig VHOST
> +	tristate "Vhost Devices"
>  	select VHOST_IOTLB
>  	help
> -	  This option is selected by any driver which needs to access
> -	  the core of vhost.
> -
> -menuconfig VHOST_MENU
> -	bool "VHOST drivers"
> -	default y
> +	  Enable option to support host kernel or hardware accelerator
> +	  for virtio device.
>  
> -if VHOST_MENU
> +if VHOST
>  
>  config VHOST_NET
>  	tristate "Host kernel accelerator for virtio net"
>  	depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)
> -	select VHOST
>  	---help---
>  	  This kernel module can be loaded in host kernel to accelerate
>  	  guest networking with virtio_net. Not to be confused with virtio_net
> @@ -40,7 +35,6 @@ config VHOST_NET
>  config VHOST_SCSI
>  	tristate "VHOST_SCSI TCM fabric driver"
>  	depends on TARGET_CORE && EVENTFD
> -	select VHOST
>  	default n
>  	---help---
>  	Say M here to enable the vhost_scsi TCM fabric module
> @@ -49,7 +43,6 @@ config VHOST_SCSI
>  config VHOST_VSOCK
>  	tristate "vhost virtio-vsock driver"
>  	depends on VSOCKETS && EVENTFD
> -	select VHOST
>  	select VIRTIO_VSOCKETS_COMMON
>  	default n
>  	---help---
> @@ -63,7 +56,6 @@ config VHOST_VSOCK
>  config VHOST_VDPA
>  	tristate "Vhost driver for vDPA-based backend"
>  	depends on EVENTFD
> -	select VHOST
>  	depends on VDPA
>  	help
>  	  This kernel module can be loaded in host kernel to accelerate
> -- 
> 2.20.1
Christian Borntraeger April 14, 2020, 7:26 a.m. UTC | #2
On 14.04.20 04:44, Jason Wang wrote:
> We try to keep the defconfig untouched after decoupling CONFIG_VHOST
> out of CONFIG_VIRTUALIZATION in commit 20c384f1ea1a
> ("vhost: refine vhost and vringh kconfig") by enabling VHOST_MENU by
> default. Then the defconfigs can keep enabling CONFIG_VHOST_NET
> without the caring of CONFIG_VHOST.
> 
> But this will leave a "CONFIG_VHOST_MENU=y" in all defconfigs and even
> for the ones that doesn't want vhost. So it actually shifts the
> burdens to the maintainers of all other to add "CONFIG_VHOST_MENU is
> not set". So this patch tries to enable CONFIG_VHOST explicitly in
> defconfigs that enables CONFIG_VHOST_NET and CONFIG_VHOST_VSOCK.
> 
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>

Fine with me.
s390 part

Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

 That was my first approach to get things fixed before I reported
this to you.

> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  arch/mips/configs/malta_kvm_defconfig  |  1 +
>  arch/powerpc/configs/powernv_defconfig |  1 +
>  arch/powerpc/configs/ppc64_defconfig   |  1 +
>  arch/powerpc/configs/pseries_defconfig |  1 +
>  arch/s390/configs/debug_defconfig      |  1 +
>  arch/s390/configs/defconfig            |  1 +
>  drivers/vhost/Kconfig                  | 18 +++++-------------
>  7 files changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/mips/configs/malta_kvm_defconfig b/arch/mips/configs/malta_kvm_defconfig
> index 8ef612552a19..06f0c7a0ca87 100644
> --- a/arch/mips/configs/malta_kvm_defconfig
> +++ b/arch/mips/configs/malta_kvm_defconfig
> @@ -18,6 +18,7 @@ CONFIG_PCI=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM=m
>  CONFIG_KVM_MIPS_DEBUG_COP0_COUNTERS=y
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_MODULES=y
>  CONFIG_MODULE_UNLOAD=y
> diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig
> index 71749377d164..404245b4594d 100644
> --- a/arch/powerpc/configs/powernv_defconfig
> +++ b/arch/powerpc/configs/powernv_defconfig
> @@ -346,5 +346,6 @@ CONFIG_CRYPTO_DEV_VMX=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM_BOOK3S_64=m
>  CONFIG_KVM_BOOK3S_64_HV=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_PRINTK_TIME=y
> diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
> index 7e68cb222c7b..4599fc7be285 100644
> --- a/arch/powerpc/configs/ppc64_defconfig
> +++ b/arch/powerpc/configs/ppc64_defconfig
> @@ -61,6 +61,7 @@ CONFIG_ELECTRA_CF=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM_BOOK3S_64=m
>  CONFIG_KVM_BOOK3S_64_HV=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_OPROFILE=m
>  CONFIG_KPROBES=y
> diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
> index 6b68109e248f..4cad3901b5de 100644
> --- a/arch/powerpc/configs/pseries_defconfig
> +++ b/arch/powerpc/configs/pseries_defconfig
> @@ -321,5 +321,6 @@ CONFIG_CRYPTO_DEV_VMX=y
>  CONFIG_VIRTUALIZATION=y
>  CONFIG_KVM_BOOK3S_64=m
>  CONFIG_KVM_BOOK3S_64_HV=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_PRINTK_TIME=y
> diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig
> index 0c86ba19fa2b..6ec6e69630d1 100644
> --- a/arch/s390/configs/debug_defconfig
> +++ b/arch/s390/configs/debug_defconfig
> @@ -57,6 +57,7 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
>  CONFIG_CMM=m
>  CONFIG_APPLDATA_BASE=y
>  CONFIG_KVM=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_VHOST_VSOCK=m
>  CONFIG_OPROFILE=m
> diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig
> index 6b27d861a9a3..d1b3bf83d687 100644
> --- a/arch/s390/configs/defconfig
> +++ b/arch/s390/configs/defconfig
> @@ -57,6 +57,7 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
>  CONFIG_CMM=m
>  CONFIG_APPLDATA_BASE=y
>  CONFIG_KVM=m
> +CONFIG_VHOST=m
>  CONFIG_VHOST_NET=m
>  CONFIG_VHOST_VSOCK=m
>  CONFIG_OPROFILE=m
> diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
> index e79cbbdfea45..14d296dc18cd 100644
> --- a/drivers/vhost/Kconfig
> +++ b/drivers/vhost/Kconfig
> @@ -12,23 +12,18 @@ config VHOST_RING
>  	  This option is selected by any driver which needs to access
>  	  the host side of a virtio ring.
>  
> -config VHOST
> -	tristate
> +menuconfig VHOST
> +	tristate "Vhost Devices"
>  	select VHOST_IOTLB
>  	help
> -	  This option is selected by any driver which needs to access
> -	  the core of vhost.
> -
> -menuconfig VHOST_MENU
> -	bool "VHOST drivers"
> -	default y
> +	  Enable option to support host kernel or hardware accelerator
> +	  for virtio device.
>  
> -if VHOST_MENU
> +if VHOST
>  
>  config VHOST_NET
>  	tristate "Host kernel accelerator for virtio net"
>  	depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)
> -	select VHOST
>  	---help---
>  	  This kernel module can be loaded in host kernel to accelerate
>  	  guest networking with virtio_net. Not to be confused with virtio_net
> @@ -40,7 +35,6 @@ config VHOST_NET
>  config VHOST_SCSI
>  	tristate "VHOST_SCSI TCM fabric driver"
>  	depends on TARGET_CORE && EVENTFD
> -	select VHOST
>  	default n
>  	---help---
>  	Say M here to enable the vhost_scsi TCM fabric module
> @@ -49,7 +43,6 @@ config VHOST_SCSI
>  config VHOST_VSOCK
>  	tristate "vhost virtio-vsock driver"
>  	depends on VSOCKETS && EVENTFD
> -	select VHOST
>  	select VIRTIO_VSOCKETS_COMMON
>  	default n
>  	---help---
> @@ -63,7 +56,6 @@ config VHOST_VSOCK
>  config VHOST_VDPA
>  	tristate "Vhost driver for vDPA-based backend"
>  	depends on EVENTFD
> -	select VHOST
>  	depends on VDPA
>  	help
>  	  This kernel module can be loaded in host kernel to accelerate
>
Jason Wang April 14, 2020, 9:48 a.m. UTC | #3
On 2020/4/14 下午3:26, Christian Borntraeger wrote:
> On 14.04.20 04:44, Jason Wang wrote:
>> We try to keep the defconfig untouched after decoupling CONFIG_VHOST
>> out of CONFIG_VIRTUALIZATION in commit 20c384f1ea1a
>> ("vhost: refine vhost and vringh kconfig") by enabling VHOST_MENU by
>> default. Then the defconfigs can keep enabling CONFIG_VHOST_NET
>> without the caring of CONFIG_VHOST.
>>
>> But this will leave a "CONFIG_VHOST_MENU=y" in all defconfigs and even
>> for the ones that doesn't want vhost. So it actually shifts the
>> burdens to the maintainers of all other to add "CONFIG_VHOST_MENU is
>> not set". So this patch tries to enable CONFIG_VHOST explicitly in
>> defconfigs that enables CONFIG_VHOST_NET and CONFIG_VHOST_VSOCK.
>>
>> Cc: Thomas Bogendoerfer<tsbogend@alpha.franken.de>
>> Cc: Benjamin Herrenschmidt<benh@kernel.crashing.org>
>> Cc: Paul Mackerras<paulus@samba.org>
>> Cc: Michael Ellerman<mpe@ellerman.id.au>
>> Cc: Heiko Carstens<heiko.carstens@de.ibm.com>
>> Cc: Vasily Gorbik<gor@linux.ibm.com>
>> Cc: Christian Borntraeger<borntraeger@de.ibm.com>
> Fine with me.
> s390 part
>
> Acked-by: Christian Borntraeger<borntraeger@de.ibm.com>
>
>   That was my first approach to get things fixed before I reported
> this to you.


Exactly.

Thanks

>
Thomas Bogendoerfer April 14, 2020, 11:52 a.m. UTC | #4
On Tue, Apr 14, 2020 at 10:44:38AM +0800, Jason Wang wrote:
> We try to keep the defconfig untouched after decoupling CONFIG_VHOST
> out of CONFIG_VIRTUALIZATION in commit 20c384f1ea1a
> ("vhost: refine vhost and vringh kconfig") by enabling VHOST_MENU by
> default. Then the defconfigs can keep enabling CONFIG_VHOST_NET
> without the caring of CONFIG_VHOST.
> 
> But this will leave a "CONFIG_VHOST_MENU=y" in all defconfigs and even
> for the ones that doesn't want vhost. So it actually shifts the
> burdens to the maintainers of all other to add "CONFIG_VHOST_MENU is
> not set". So this patch tries to enable CONFIG_VHOST explicitly in
> defconfigs that enables CONFIG_VHOST_NET and CONFIG_VHOST_VSOCK.
> 
> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
> Cc: Vasily Gorbik <gor@linux.ibm.com>
> Cc: Christian Borntraeger <borntraeger@de.ibm.com>
> Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> ---
>  arch/mips/configs/malta_kvm_defconfig  |  1 +

Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

Thomas.
kernel test robot April 14, 2020, 9:15 p.m. UTC | #5
Hi Jason,

I love your patch! Yet something to improve:

[auto build test ERROR on vhost/linux-next]
[also build test ERROR on next-20200414]
[cannot apply to powerpc/next s390/features v5.7-rc1]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vhost-do-not-enable-VHOST_MENU-by-default/20200414-110807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
config: ia64-randconfig-a001-20200415 (attached as .config)
compiler: ia64-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
        # save the attached .config to linux build tree
        GCC_VERSION=9.3.0 make.cross ARCH=ia64 

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

All error/warnings (new ones prefixed by >>):

   drivers/vhost/vhost.c: In function 'vhost_vring_ioctl':
>> drivers/vhost/vhost.c:1577:33: error: implicit declaration of function 'eventfd_fget'; did you mean 'eventfd_signal'? [-Werror=implicit-function-declaration]
    1577 |   eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
         |                                 ^~~~~~~~~~~~
         |                                 eventfd_signal
>> drivers/vhost/vhost.c:1577:31: warning: pointer/integer type mismatch in conditional expression
    1577 |   eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
         |                               ^
   cc1: some warnings being treated as errors

vim +1577 drivers/vhost/vhost.c

feebcaeac79ad8 Jason Wang         2019-05-24  1493  
feebcaeac79ad8 Jason Wang         2019-05-24  1494  static long vhost_vring_set_num_addr(struct vhost_dev *d,
feebcaeac79ad8 Jason Wang         2019-05-24  1495  				     struct vhost_virtqueue *vq,
feebcaeac79ad8 Jason Wang         2019-05-24  1496  				     unsigned int ioctl,
feebcaeac79ad8 Jason Wang         2019-05-24  1497  				     void __user *argp)
feebcaeac79ad8 Jason Wang         2019-05-24  1498  {
feebcaeac79ad8 Jason Wang         2019-05-24  1499  	long r;
feebcaeac79ad8 Jason Wang         2019-05-24  1500  
feebcaeac79ad8 Jason Wang         2019-05-24  1501  	mutex_lock(&vq->mutex);
feebcaeac79ad8 Jason Wang         2019-05-24  1502  
feebcaeac79ad8 Jason Wang         2019-05-24  1503  	switch (ioctl) {
feebcaeac79ad8 Jason Wang         2019-05-24  1504  	case VHOST_SET_VRING_NUM:
feebcaeac79ad8 Jason Wang         2019-05-24  1505  		r = vhost_vring_set_num(d, vq, argp);
feebcaeac79ad8 Jason Wang         2019-05-24  1506  		break;
feebcaeac79ad8 Jason Wang         2019-05-24  1507  	case VHOST_SET_VRING_ADDR:
feebcaeac79ad8 Jason Wang         2019-05-24  1508  		r = vhost_vring_set_addr(d, vq, argp);
feebcaeac79ad8 Jason Wang         2019-05-24  1509  		break;
feebcaeac79ad8 Jason Wang         2019-05-24  1510  	default:
feebcaeac79ad8 Jason Wang         2019-05-24  1511  		BUG();
feebcaeac79ad8 Jason Wang         2019-05-24  1512  	}
feebcaeac79ad8 Jason Wang         2019-05-24  1513  
feebcaeac79ad8 Jason Wang         2019-05-24  1514  	mutex_unlock(&vq->mutex);
feebcaeac79ad8 Jason Wang         2019-05-24  1515  
feebcaeac79ad8 Jason Wang         2019-05-24  1516  	return r;
feebcaeac79ad8 Jason Wang         2019-05-24  1517  }
26b36604523f4a Sonny Rao          2018-03-14  1518  long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1519  {
cecb46f194460d Al Viro            2012-08-27  1520  	struct file *eventfp, *filep = NULL;
cecb46f194460d Al Viro            2012-08-27  1521  	bool pollstart = false, pollstop = false;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1522  	struct eventfd_ctx *ctx = NULL;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1523  	u32 __user *idxp = argp;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1524  	struct vhost_virtqueue *vq;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1525  	struct vhost_vring_state s;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1526  	struct vhost_vring_file f;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1527  	u32 idx;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1528  	long r;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1529  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1530  	r = get_user(idx, idxp);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1531  	if (r < 0)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1532  		return r;
0f3d9a17469d71 Krishna Kumar      2010-05-25  1533  	if (idx >= d->nvqs)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1534  		return -ENOBUFS;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1535  
ff002269a4ee9c Jason Wang         2018-10-30  1536  	idx = array_index_nospec(idx, d->nvqs);
3ab2e420ec1caf Asias He           2013-04-27  1537  	vq = d->vqs[idx];
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1538  
feebcaeac79ad8 Jason Wang         2019-05-24  1539  	if (ioctl == VHOST_SET_VRING_NUM ||
feebcaeac79ad8 Jason Wang         2019-05-24  1540  	    ioctl == VHOST_SET_VRING_ADDR) {
feebcaeac79ad8 Jason Wang         2019-05-24  1541  		return vhost_vring_set_num_addr(d, vq, ioctl, argp);
feebcaeac79ad8 Jason Wang         2019-05-24  1542  	}
feebcaeac79ad8 Jason Wang         2019-05-24  1543  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1544  	mutex_lock(&vq->mutex);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1545  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1546  	switch (ioctl) {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1547  	case VHOST_SET_VRING_BASE:
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1548  		/* Moving base with an active backend?
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1549  		 * You don't want to do that. */
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1550  		if (vq->private_data) {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1551  			r = -EBUSY;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1552  			break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1553  		}
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1554  		if (copy_from_user(&s, argp, sizeof s)) {
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1555  			r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1556  			break;
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1557  		}
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1558  		if (s.num > 0xffff) {
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1559  			r = -EINVAL;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1560  			break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1561  		}
8d65843c44269c Jason Wang         2017-07-27  1562  		vq->last_avail_idx = s.num;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1563  		/* Forget the cached index value. */
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1564  		vq->avail_idx = vq->last_avail_idx;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1565  		break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1566  	case VHOST_GET_VRING_BASE:
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1567  		s.index = idx;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1568  		s.num = vq->last_avail_idx;
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1569  		if (copy_to_user(argp, &s, sizeof s))
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1570  			r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1571  		break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1572  	case VHOST_SET_VRING_KICK:
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1573  		if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1574  			r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1575  			break;
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1576  		}
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 @1577  		eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1578  		if (IS_ERR(eventfp)) {
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1579  			r = PTR_ERR(eventfp);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1580  			break;
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1581  		}
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1582  		if (eventfp != vq->kick) {
cecb46f194460d Al Viro            2012-08-27  1583  			pollstop = (filep = vq->kick) != NULL;
cecb46f194460d Al Viro            2012-08-27  1584  			pollstart = (vq->kick = eventfp) != NULL;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1585  		} else
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1586  			filep = eventfp;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1587  		break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1588  	case VHOST_SET_VRING_CALL:
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1589  		if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1590  			r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1591  			break;
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1592  		}
e050c7d93f4adb Eric Biggers       2018-01-06  1593  		ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
e050c7d93f4adb Eric Biggers       2018-01-06  1594  		if (IS_ERR(ctx)) {
e050c7d93f4adb Eric Biggers       2018-01-06  1595  			r = PTR_ERR(ctx);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1596  			break;
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1597  		}
e050c7d93f4adb Eric Biggers       2018-01-06  1598  		swap(ctx, vq->call_ctx);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1599  		break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1600  	case VHOST_SET_VRING_ERR:
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1601  		if (copy_from_user(&f, argp, sizeof f)) {
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1602  			r = -EFAULT;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1603  			break;
7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1604  		}
09f332a589232f Eric Biggers       2018-01-06  1605  		ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
09f332a589232f Eric Biggers       2018-01-06  1606  		if (IS_ERR(ctx)) {
09f332a589232f Eric Biggers       2018-01-06  1607  			r = PTR_ERR(ctx);
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1608  			break;
535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1609  		}
09f332a589232f Eric Biggers       2018-01-06  1610  		swap(ctx, vq->error_ctx);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1611  		break;
2751c9882b9472 Greg Kurz          2015-04-24  1612  	case VHOST_SET_VRING_ENDIAN:
2751c9882b9472 Greg Kurz          2015-04-24  1613  		r = vhost_set_vring_endian(vq, argp);
2751c9882b9472 Greg Kurz          2015-04-24  1614  		break;
2751c9882b9472 Greg Kurz          2015-04-24  1615  	case VHOST_GET_VRING_ENDIAN:
2751c9882b9472 Greg Kurz          2015-04-24  1616  		r = vhost_get_vring_endian(vq, idx, argp);
2751c9882b9472 Greg Kurz          2015-04-24  1617  		break;
03088137246065 Jason Wang         2016-03-04  1618  	case VHOST_SET_VRING_BUSYLOOP_TIMEOUT:
03088137246065 Jason Wang         2016-03-04  1619  		if (copy_from_user(&s, argp, sizeof(s))) {
03088137246065 Jason Wang         2016-03-04  1620  			r = -EFAULT;
03088137246065 Jason Wang         2016-03-04  1621  			break;
03088137246065 Jason Wang         2016-03-04  1622  		}
03088137246065 Jason Wang         2016-03-04  1623  		vq->busyloop_timeout = s.num;
03088137246065 Jason Wang         2016-03-04  1624  		break;
03088137246065 Jason Wang         2016-03-04  1625  	case VHOST_GET_VRING_BUSYLOOP_TIMEOUT:
03088137246065 Jason Wang         2016-03-04  1626  		s.index = idx;
03088137246065 Jason Wang         2016-03-04  1627  		s.num = vq->busyloop_timeout;
03088137246065 Jason Wang         2016-03-04  1628  		if (copy_to_user(argp, &s, sizeof(s)))
03088137246065 Jason Wang         2016-03-04  1629  			r = -EFAULT;
03088137246065 Jason Wang         2016-03-04  1630  		break;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1631  	default:
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1632  		r = -ENOIOCTLCMD;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1633  	}
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1634  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1635  	if (pollstop && vq->handle_kick)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1636  		vhost_poll_stop(&vq->poll);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1637  
e050c7d93f4adb Eric Biggers       2018-01-06  1638  	if (!IS_ERR_OR_NULL(ctx))
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1639  		eventfd_ctx_put(ctx);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1640  	if (filep)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1641  		fput(filep);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1642  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1643  	if (pollstart && vq->handle_kick)
2b8b328b61c799 Jason Wang         2013-01-28  1644  		r = vhost_poll_start(&vq->poll, vq->kick);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1645  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1646  	mutex_unlock(&vq->mutex);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1647  
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1648  	if (pollstop && vq->handle_kick)
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1649  		vhost_poll_flush(&vq->poll);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1650  	return r;
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1651  }
6ac1afbf6132df Asias He           2013-05-06  1652  EXPORT_SYMBOL_GPL(vhost_vring_ioctl);
3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1653  

:::::: The code at line 1577 was first introduced by commit
:::::: 3a4d5c94e959359ece6d6b55045c3f046677f55c vhost_net: a kernel-level virtio server

:::::: TO: Michael S. Tsirkin <mst@redhat.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Jason Wang April 15, 2020, 2:40 a.m. UTC | #6
On 2020/4/15 上午5:15, kbuild test robot wrote:
> Hi Jason,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on vhost/linux-next]
> [also build test ERROR on next-20200414]
> [cannot apply to powerpc/next s390/features v5.7-rc1]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
>
> url:    https://github.com/0day-ci/linux/commits/Jason-Wang/vhost-do-not-enable-VHOST_MENU-by-default/20200414-110807
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git linux-next
> config: ia64-randconfig-a001-20200415 (attached as .config)
> compiler: ia64-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
>          # save the attached .config to linux build tree
>          GCC_VERSION=9.3.0 make.cross ARCH=ia64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All error/warnings (new ones prefixed by >>):
>
>     drivers/vhost/vhost.c: In function 'vhost_vring_ioctl':
>>> drivers/vhost/vhost.c:1577:33: error: implicit declaration of function 'eventfd_fget'; did you mean 'eventfd_signal'? [-Werror=implicit-function-declaration]
>      1577 |   eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
>           |                                 ^~~~~~~~~~~~
>           |                                 eventfd_signal
>>> drivers/vhost/vhost.c:1577:31: warning: pointer/integer type mismatch in conditional expression


Forget to make VHOST depend on EVENTFD.

Will send v2.

Thanks


>      1577 |   eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
>           |                               ^
>     cc1: some warnings being treated as errors
>
> vim +1577 drivers/vhost/vhost.c
>
> feebcaeac79ad8 Jason Wang         2019-05-24  1493
> feebcaeac79ad8 Jason Wang         2019-05-24  1494  static long vhost_vring_set_num_addr(struct vhost_dev *d,
> feebcaeac79ad8 Jason Wang         2019-05-24  1495  				     struct vhost_virtqueue *vq,
> feebcaeac79ad8 Jason Wang         2019-05-24  1496  				     unsigned int ioctl,
> feebcaeac79ad8 Jason Wang         2019-05-24  1497  				     void __user *argp)
> feebcaeac79ad8 Jason Wang         2019-05-24  1498  {
> feebcaeac79ad8 Jason Wang         2019-05-24  1499  	long r;
> feebcaeac79ad8 Jason Wang         2019-05-24  1500
> feebcaeac79ad8 Jason Wang         2019-05-24  1501  	mutex_lock(&vq->mutex);
> feebcaeac79ad8 Jason Wang         2019-05-24  1502
> feebcaeac79ad8 Jason Wang         2019-05-24  1503  	switch (ioctl) {
> feebcaeac79ad8 Jason Wang         2019-05-24  1504  	case VHOST_SET_VRING_NUM:
> feebcaeac79ad8 Jason Wang         2019-05-24  1505  		r = vhost_vring_set_num(d, vq, argp);
> feebcaeac79ad8 Jason Wang         2019-05-24  1506  		break;
> feebcaeac79ad8 Jason Wang         2019-05-24  1507  	case VHOST_SET_VRING_ADDR:
> feebcaeac79ad8 Jason Wang         2019-05-24  1508  		r = vhost_vring_set_addr(d, vq, argp);
> feebcaeac79ad8 Jason Wang         2019-05-24  1509  		break;
> feebcaeac79ad8 Jason Wang         2019-05-24  1510  	default:
> feebcaeac79ad8 Jason Wang         2019-05-24  1511  		BUG();
> feebcaeac79ad8 Jason Wang         2019-05-24  1512  	}
> feebcaeac79ad8 Jason Wang         2019-05-24  1513
> feebcaeac79ad8 Jason Wang         2019-05-24  1514  	mutex_unlock(&vq->mutex);
> feebcaeac79ad8 Jason Wang         2019-05-24  1515
> feebcaeac79ad8 Jason Wang         2019-05-24  1516  	return r;
> feebcaeac79ad8 Jason Wang         2019-05-24  1517  }
> 26b36604523f4a Sonny Rao          2018-03-14  1518  long vhost_vring_ioctl(struct vhost_dev *d, unsigned int ioctl, void __user *argp)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1519  {
> cecb46f194460d Al Viro            2012-08-27  1520  	struct file *eventfp, *filep = NULL;
> cecb46f194460d Al Viro            2012-08-27  1521  	bool pollstart = false, pollstop = false;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1522  	struct eventfd_ctx *ctx = NULL;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1523  	u32 __user *idxp = argp;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1524  	struct vhost_virtqueue *vq;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1525  	struct vhost_vring_state s;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1526  	struct vhost_vring_file f;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1527  	u32 idx;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1528  	long r;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1529
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1530  	r = get_user(idx, idxp);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1531  	if (r < 0)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1532  		return r;
> 0f3d9a17469d71 Krishna Kumar      2010-05-25  1533  	if (idx >= d->nvqs)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1534  		return -ENOBUFS;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1535
> ff002269a4ee9c Jason Wang         2018-10-30  1536  	idx = array_index_nospec(idx, d->nvqs);
> 3ab2e420ec1caf Asias He           2013-04-27  1537  	vq = d->vqs[idx];
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1538
> feebcaeac79ad8 Jason Wang         2019-05-24  1539  	if (ioctl == VHOST_SET_VRING_NUM ||
> feebcaeac79ad8 Jason Wang         2019-05-24  1540  	    ioctl == VHOST_SET_VRING_ADDR) {
> feebcaeac79ad8 Jason Wang         2019-05-24  1541  		return vhost_vring_set_num_addr(d, vq, ioctl, argp);
> feebcaeac79ad8 Jason Wang         2019-05-24  1542  	}
> feebcaeac79ad8 Jason Wang         2019-05-24  1543
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1544  	mutex_lock(&vq->mutex);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1545
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1546  	switch (ioctl) {
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1547  	case VHOST_SET_VRING_BASE:
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1548  		/* Moving base with an active backend?
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1549  		 * You don't want to do that. */
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1550  		if (vq->private_data) {
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1551  			r = -EBUSY;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1552  			break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1553  		}
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1554  		if (copy_from_user(&s, argp, sizeof s)) {
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1555  			r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1556  			break;
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1557  		}
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1558  		if (s.num > 0xffff) {
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1559  			r = -EINVAL;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1560  			break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1561  		}
> 8d65843c44269c Jason Wang         2017-07-27  1562  		vq->last_avail_idx = s.num;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1563  		/* Forget the cached index value. */
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1564  		vq->avail_idx = vq->last_avail_idx;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1565  		break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1566  	case VHOST_GET_VRING_BASE:
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1567  		s.index = idx;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1568  		s.num = vq->last_avail_idx;
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1569  		if (copy_to_user(argp, &s, sizeof s))
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1570  			r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1571  		break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1572  	case VHOST_SET_VRING_KICK:
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1573  		if (copy_from_user(&f, argp, sizeof f)) {
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1574  			r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1575  			break;
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1576  		}
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14 @1577  		eventfp = f.fd == -1 ? NULL : eventfd_fget(f.fd);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1578  		if (IS_ERR(eventfp)) {
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1579  			r = PTR_ERR(eventfp);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1580  			break;
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1581  		}
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1582  		if (eventfp != vq->kick) {
> cecb46f194460d Al Viro            2012-08-27  1583  			pollstop = (filep = vq->kick) != NULL;
> cecb46f194460d Al Viro            2012-08-27  1584  			pollstart = (vq->kick = eventfp) != NULL;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1585  		} else
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1586  			filep = eventfp;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1587  		break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1588  	case VHOST_SET_VRING_CALL:
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1589  		if (copy_from_user(&f, argp, sizeof f)) {
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1590  			r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1591  			break;
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1592  		}
> e050c7d93f4adb Eric Biggers       2018-01-06  1593  		ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
> e050c7d93f4adb Eric Biggers       2018-01-06  1594  		if (IS_ERR(ctx)) {
> e050c7d93f4adb Eric Biggers       2018-01-06  1595  			r = PTR_ERR(ctx);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1596  			break;
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1597  		}
> e050c7d93f4adb Eric Biggers       2018-01-06  1598  		swap(ctx, vq->call_ctx);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1599  		break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1600  	case VHOST_SET_VRING_ERR:
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1601  		if (copy_from_user(&f, argp, sizeof f)) {
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1602  			r = -EFAULT;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1603  			break;
> 7ad9c9d2704854 Takuya Yoshikawa   2010-05-27  1604  		}
> 09f332a589232f Eric Biggers       2018-01-06  1605  		ctx = f.fd == -1 ? NULL : eventfd_ctx_fdget(f.fd);
> 09f332a589232f Eric Biggers       2018-01-06  1606  		if (IS_ERR(ctx)) {
> 09f332a589232f Eric Biggers       2018-01-06  1607  			r = PTR_ERR(ctx);
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1608  			break;
> 535297a6ae4c3b Michael S. Tsirkin 2010-03-17  1609  		}
> 09f332a589232f Eric Biggers       2018-01-06  1610  		swap(ctx, vq->error_ctx);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1611  		break;
> 2751c9882b9472 Greg Kurz          2015-04-24  1612  	case VHOST_SET_VRING_ENDIAN:
> 2751c9882b9472 Greg Kurz          2015-04-24  1613  		r = vhost_set_vring_endian(vq, argp);
> 2751c9882b9472 Greg Kurz          2015-04-24  1614  		break;
> 2751c9882b9472 Greg Kurz          2015-04-24  1615  	case VHOST_GET_VRING_ENDIAN:
> 2751c9882b9472 Greg Kurz          2015-04-24  1616  		r = vhost_get_vring_endian(vq, idx, argp);
> 2751c9882b9472 Greg Kurz          2015-04-24  1617  		break;
> 03088137246065 Jason Wang         2016-03-04  1618  	case VHOST_SET_VRING_BUSYLOOP_TIMEOUT:
> 03088137246065 Jason Wang         2016-03-04  1619  		if (copy_from_user(&s, argp, sizeof(s))) {
> 03088137246065 Jason Wang         2016-03-04  1620  			r = -EFAULT;
> 03088137246065 Jason Wang         2016-03-04  1621  			break;
> 03088137246065 Jason Wang         2016-03-04  1622  		}
> 03088137246065 Jason Wang         2016-03-04  1623  		vq->busyloop_timeout = s.num;
> 03088137246065 Jason Wang         2016-03-04  1624  		break;
> 03088137246065 Jason Wang         2016-03-04  1625  	case VHOST_GET_VRING_BUSYLOOP_TIMEOUT:
> 03088137246065 Jason Wang         2016-03-04  1626  		s.index = idx;
> 03088137246065 Jason Wang         2016-03-04  1627  		s.num = vq->busyloop_timeout;
> 03088137246065 Jason Wang         2016-03-04  1628  		if (copy_to_user(argp, &s, sizeof(s)))
> 03088137246065 Jason Wang         2016-03-04  1629  			r = -EFAULT;
> 03088137246065 Jason Wang         2016-03-04  1630  		break;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1631  	default:
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1632  		r = -ENOIOCTLCMD;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1633  	}
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1634
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1635  	if (pollstop && vq->handle_kick)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1636  		vhost_poll_stop(&vq->poll);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1637
> e050c7d93f4adb Eric Biggers       2018-01-06  1638  	if (!IS_ERR_OR_NULL(ctx))
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1639  		eventfd_ctx_put(ctx);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1640  	if (filep)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1641  		fput(filep);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1642
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1643  	if (pollstart && vq->handle_kick)
> 2b8b328b61c799 Jason Wang         2013-01-28  1644  		r = vhost_poll_start(&vq->poll, vq->kick);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1645
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1646  	mutex_unlock(&vq->mutex);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1647
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1648  	if (pollstop && vq->handle_kick)
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1649  		vhost_poll_flush(&vq->poll);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1650  	return r;
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1651  }
> 6ac1afbf6132df Asias He           2013-05-06  1652  EXPORT_SYMBOL_GPL(vhost_vring_ioctl);
> 3a4d5c94e95935 Michael S. Tsirkin 2010-01-14  1653
>
> :::::: The code at line 1577 was first introduced by commit
> :::::: 3a4d5c94e959359ece6d6b55045c3f046677f55c vhost_net: a kernel-level virtio server
>
> :::::: TO: Michael S. Tsirkin <mst@redhat.com>
> :::::: CC: David S. Miller <davem@davemloft.net>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/arch/mips/configs/malta_kvm_defconfig b/arch/mips/configs/malta_kvm_defconfig
index 8ef612552a19..06f0c7a0ca87 100644
--- a/arch/mips/configs/malta_kvm_defconfig
+++ b/arch/mips/configs/malta_kvm_defconfig
@@ -18,6 +18,7 @@  CONFIG_PCI=y
 CONFIG_VIRTUALIZATION=y
 CONFIG_KVM=m
 CONFIG_KVM_MIPS_DEBUG_COP0_COUNTERS=y
+CONFIG_VHOST=m
 CONFIG_VHOST_NET=m
 CONFIG_MODULES=y
 CONFIG_MODULE_UNLOAD=y
diff --git a/arch/powerpc/configs/powernv_defconfig b/arch/powerpc/configs/powernv_defconfig
index 71749377d164..404245b4594d 100644
--- a/arch/powerpc/configs/powernv_defconfig
+++ b/arch/powerpc/configs/powernv_defconfig
@@ -346,5 +346,6 @@  CONFIG_CRYPTO_DEV_VMX=y
 CONFIG_VIRTUALIZATION=y
 CONFIG_KVM_BOOK3S_64=m
 CONFIG_KVM_BOOK3S_64_HV=m
+CONFIG_VHOST=m
 CONFIG_VHOST_NET=m
 CONFIG_PRINTK_TIME=y
diff --git a/arch/powerpc/configs/ppc64_defconfig b/arch/powerpc/configs/ppc64_defconfig
index 7e68cb222c7b..4599fc7be285 100644
--- a/arch/powerpc/configs/ppc64_defconfig
+++ b/arch/powerpc/configs/ppc64_defconfig
@@ -61,6 +61,7 @@  CONFIG_ELECTRA_CF=y
 CONFIG_VIRTUALIZATION=y
 CONFIG_KVM_BOOK3S_64=m
 CONFIG_KVM_BOOK3S_64_HV=m
+CONFIG_VHOST=m
 CONFIG_VHOST_NET=m
 CONFIG_OPROFILE=m
 CONFIG_KPROBES=y
diff --git a/arch/powerpc/configs/pseries_defconfig b/arch/powerpc/configs/pseries_defconfig
index 6b68109e248f..4cad3901b5de 100644
--- a/arch/powerpc/configs/pseries_defconfig
+++ b/arch/powerpc/configs/pseries_defconfig
@@ -321,5 +321,6 @@  CONFIG_CRYPTO_DEV_VMX=y
 CONFIG_VIRTUALIZATION=y
 CONFIG_KVM_BOOK3S_64=m
 CONFIG_KVM_BOOK3S_64_HV=m
+CONFIG_VHOST=m
 CONFIG_VHOST_NET=m
 CONFIG_PRINTK_TIME=y
diff --git a/arch/s390/configs/debug_defconfig b/arch/s390/configs/debug_defconfig
index 0c86ba19fa2b..6ec6e69630d1 100644
--- a/arch/s390/configs/debug_defconfig
+++ b/arch/s390/configs/debug_defconfig
@@ -57,6 +57,7 @@  CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
 CONFIG_CMM=m
 CONFIG_APPLDATA_BASE=y
 CONFIG_KVM=m
+CONFIG_VHOST=m
 CONFIG_VHOST_NET=m
 CONFIG_VHOST_VSOCK=m
 CONFIG_OPROFILE=m
diff --git a/arch/s390/configs/defconfig b/arch/s390/configs/defconfig
index 6b27d861a9a3..d1b3bf83d687 100644
--- a/arch/s390/configs/defconfig
+++ b/arch/s390/configs/defconfig
@@ -57,6 +57,7 @@  CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
 CONFIG_CMM=m
 CONFIG_APPLDATA_BASE=y
 CONFIG_KVM=m
+CONFIG_VHOST=m
 CONFIG_VHOST_NET=m
 CONFIG_VHOST_VSOCK=m
 CONFIG_OPROFILE=m
diff --git a/drivers/vhost/Kconfig b/drivers/vhost/Kconfig
index e79cbbdfea45..14d296dc18cd 100644
--- a/drivers/vhost/Kconfig
+++ b/drivers/vhost/Kconfig
@@ -12,23 +12,18 @@  config VHOST_RING
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
 
-config VHOST
-	tristate
+menuconfig VHOST
+	tristate "Vhost Devices"
 	select VHOST_IOTLB
 	help
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
-menuconfig VHOST_MENU
-	bool "VHOST drivers"
-	default y
+	  Enable option to support host kernel or hardware accelerator
+	  for virtio device.
 
-if VHOST_MENU
+if VHOST
 
 config VHOST_NET
 	tristate "Host kernel accelerator for virtio net"
 	depends on NET && EVENTFD && (TUN || !TUN) && (TAP || !TAP)
-	select VHOST
 	---help---
 	  This kernel module can be loaded in host kernel to accelerate
 	  guest networking with virtio_net. Not to be confused with virtio_net
@@ -40,7 +35,6 @@  config VHOST_NET
 config VHOST_SCSI
 	tristate "VHOST_SCSI TCM fabric driver"
 	depends on TARGET_CORE && EVENTFD
-	select VHOST
 	default n
 	---help---
 	Say M here to enable the vhost_scsi TCM fabric module
@@ -49,7 +43,6 @@  config VHOST_SCSI
 config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
-	select VHOST
 	select VIRTIO_VSOCKETS_COMMON
 	default n
 	---help---
@@ -63,7 +56,6 @@  config VHOST_VSOCK
 config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
-	select VHOST
 	depends on VDPA
 	help
 	  This kernel module can be loaded in host kernel to accelerate