Skip to contentSkip to conversation

vDPA support

PATCH In review Jason Wang 7 participants 49 messages Mar 26, 2020 – Nov 3, 2021

Subsystems (20)
lore
Share & tools
lore

Jason Wang

author
#0 lore raw

v9 cover vDPA support

Hi all:

This is an update version of vDPA support in kernel.

vDPA device is a device that uses a datapath which complies with the virtio specifications with vendor specific control path. vDPA devices can be both physically located on the hardware or emulated by software. vDPA hardware devices are usually implemented through PCIE with the following types:

- PF (Physical Function) - A single Physical Function
- VF (Virtual Function) - Device that supports single root I/O virtualization (SR-IOV). Its Virtual Function (VF) represents a virtualized instance of the device that can be assigned to different partitions
- ADI (Assignable Device Interface) and its equivalents - With technologies such as Intel Scalable IOV, a virtual device (VDEV) composed by host OS utilizing one or more ADIs. Or its equivalent like SF (Sub function) from Mellanox.

From a driver's perspective, depends on how and where the DMA translation is done, vDPA devices are split into two types:

- Platform specific DMA translation - From the driver's perspective, the device can be used on a platform where device access to data in memory is limited and/or translated. An example is a PCIE vDPA whose DMA request was tagged via a bus (e.g PCIE) specific way. DMA translation and protection are done at PCIE bus IOMMU level.
- Device specific DMA translation - The device implements DMA isolation and protection through its own logic. An example is a vDPA device which uses on-chip IOMMU.

To hide the differences and complexity of the above types for a vDPA device/IOMMU options and in order to present a generic virtio device to the upper layer, a device agnostic framework is required.

This series introduces a software vDPA bus which abstracts the common attributes of vDPA device, vDPA bus driver and the communication method, the bus operations (vdpa_config_ops) between the vDPA device abstraction and the vDPA bus driver. This allows multiple types of drivers to be used for vDPA device like the virtio_vdpa and vhost_vdpa driver to operate on the bus and allow vDPA device could be used by either kernel virtio driver or userspace vhost drivers as:

virtio drivers vhost drivers

          |             |
    [virtio bus]   [vhost uAPI]
          |             |
   virtio device   vhost device
   virtio_vdpa drv vhost_vdpa drv
             \       /
            [vDPA bus]
                 |
            vDPA device
            hardware drv
                 |
            [hardware bus]
                 |
            vDPA hardware

virtio_vdpa driver is a transport implementation for kernel virtio drivers on top of vDPA bus operations. An alternative is to refactor virtio bus which is sub-optimal since the bus and drivers are designed to be use by kernel subsystem, a non-trivial major refactoring is needed which may impact a brunches of drivers and devices implementation inside the kernel. Using a new transport may grealy simply both the design and changes.

vhost_vdpa driver is a new type of vhost device which allows userspace vhost drivers to use vDPA devices via vhost uAPI (with minor extension). This help to minimize the changes of existed vhost drivers for using vDPA devices.

With the abstraction of vDPA bus and vDPA bus operations, the difference and complexity of the under layer hardware is hidden from upper layer. The vDPA bus drivers on top can use a unified vdpa_config_ops to control different types of vDPA device.

Two drivers were implemented with the framework introduced in this series:

- Intel IFC VF driver which depends on the platform IOMMU for DMA translation
- VDPA simulator which is a software test device with an emulated onchip IOMMU

Future work:

- direct doorbell mapping support
- control virtqueue support
- dirty page tracking support
- direct interrupt support
- management API (devlink)

Please review.

Thanks

Changes from V8:

- switch to use devres for PCI resoureces of IFCVF (Jason)
- require the caller of vdap_alloc_device() to use "struct foo" instead of foo (Jason)
- some tweaks on the IFCVF driver

Changes from V7:

- refine kconfig to solve the dependency issues on archs that lacks of CONFIG_VIRTUALIZATION (kbuild)

Changes from V6:

- vdpa_alloc_device() will allocate parent strcture (Jason)
- remove the vdpa core dev info in IFCVF patch (Jason)
- provide a free method in the vdpa bus operations for drivet to free private data
- switch to use new layout in vdapsim and IFCVF
- make IFCVF depends on PCI_MSI (kbuild)
- some tweaks on the IFCVF driver

Changes from V5:

- include Intel IFCVF driver and vhost-vdpa drivers
- add the platform IOMMU support for vhost-vdpa
- check the return value of dev_set_name() (Jason)
- various tweaks and fixes

Changes from V4:

- use put_device() instead of kfree when fail to register virtio device (Jason)
- simplify the error handling when allocating vdpasim device (Jason)
- don't use device_for_each_child() during module exit (Jason)
- correct the error checking for vdpa_alloc_device() (Harpreet, Lingshan)

Changes from V3:

- various Kconfig fixes (Randy)

Changes from V2:

- release idr in the release function for put_device() unwind (Jason)
- don't panic when fail to register vdpa bus (Jason)
- use unsigned int instead of int for ida (Jason)
- fix the wrong commit log in virito_vdpa patches (Jason)
- make vdpa_sim depends on RUNTIME_TESTING_MENU (Michael)
- provide a bus release function for vDPA device (Jason)
- fix the wrong unwind when creating devices for vDPA simulator (Jason)
- move vDPA simulator to a dedicated directory (Lingshan)
- cancel the work before release vDPA simulator

Changes from V1:

- drop sysfs API, leave the management interface to future development (Michael)
- introduce incremental DMA ops (dma_map/dma_unmap) (Michael)
- introduce dma_device and use it instead of parent device for doing IOMMU or DMA from bus driver (Michael, Jason, Ling Shan, Tiwei)
- accept parent device and dma device when register vdpa device
- coding style and compile fixes (Randy)
- using vdpa_xxx instead of xxx_vdpa (Jason)
- ove vDPA accessors to header and make it static inline (Jason)
- split vdp_register_device() into two helpers vdpa_init_device() and vdpa_register_device() which allows intermediate step to be done (Jason)
- warn on invalidate queue state when fail to creating virtqueue (Jason)
- make to_virtio_vdpa_device() static (Jason)
- use kmalloc/kfree instead of devres for virtio vdpa device (Jason)
- avoid using cast in vdpa bus function (Jason)
- introduce module_vdpa_driver and fix module refcnt (Jason)
- fix returning freed address in vdapsim coherent DMA addr allocation (Dan)
- various other fixes and tweaks

V8: https://lkml.org/lkml/2020/3/25/125
V7: https://lkml.org/lkml/2020/3/24/21
V6: https://lkml.org/lkml/2020/3/18/88
V5: https://lkml.org/lkml/2020/2/26/58
V4: https://lkml.org/lkml/2020/2/20/59
V3: https://lkml.org/lkml/2020/2/19/1347
V2: https://lkml.org/lkml/2020/2/9/275
V1: https://lkml.org/lkml/2020/1/16/353

Jason Wang (7):
vhost: refine vhost and vringh kconfig
vhost: allow per device message handler
vhost: factor out IOTLB
vringh: IOTLB support
vDPA: introduce vDPA bus
virtio: introduce a vDPA based transport
vdpasim: vDPA device simulator

Tiwei Bie (1):
vhost: introduce vDPA-based backend

Zhu Lingshan (1):
virtio: Intel IFC VF driver for VDPA

 MAINTAINERS                             |   2 +
 arch/arm/kvm/Kconfig                    |   2 -
 arch/arm64/kvm/Kconfig                  |   2 -
 arch/mips/kvm/Kconfig                   |   2 -
 arch/powerpc/kvm/Kconfig                |   2 -
 arch/s390/kvm/Kconfig                   |   4 -
 arch/x86/kvm/Kconfig                    |   4 -
 drivers/Kconfig                         |   2 +
 drivers/misc/mic/Kconfig                |   4 -
 drivers/net/caif/Kconfig                |   4 -
 drivers/vhost/Kconfig                   |  42 +-
 drivers/vhost/Kconfig.vringh            |   6 -
 drivers/vhost/Makefile                  |   6 +
 drivers/vhost/iotlb.c                   | 177 +++++
 drivers/vhost/net.c                     |   5 +-
 drivers/vhost/scsi.c                    |   2 +-
 drivers/vhost/vdpa.c                    | 883 ++++++++++++++++++++++++
 drivers/vhost/vhost.c                   | 233 +++----
 drivers/vhost/vhost.h                   |  45 +-
 drivers/vhost/vringh.c                  | 421 ++++++++++-
 drivers/vhost/vsock.c                   |   2 +-
 drivers/virtio/Kconfig                  |  15 +
 drivers/virtio/Makefile                 |   2 +
 drivers/virtio/vdpa/Kconfig             |  37 +
 drivers/virtio/vdpa/Makefile            |   4 +
 drivers/virtio/vdpa/ifcvf/Makefile      |   3 +
 drivers/virtio/vdpa/ifcvf/ifcvf_base.c  | 389 +++++++++++
 drivers/virtio/vdpa/ifcvf/ifcvf_base.h  | 118 ++++
 drivers/virtio/vdpa/ifcvf/ifcvf_main.c  | 435 ++++++++++++
 drivers/virtio/vdpa/vdpa.c              | 180 +++++
 drivers/virtio/vdpa/vdpa_sim/Makefile   |   2 +
 drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c | 629 +++++++++++++++++
 drivers/virtio/virtio_vdpa.c            | 396 +++++++++++
 include/linux/vdpa.h                    | 253 +++++++
 include/linux/vhost_iotlb.h             |  47 ++
 include/linux/vringh.h                  |  36 +
 include/uapi/linux/vhost.h              |  24 +
 include/uapi/linux/vhost_types.h        |   8 +
 38 files changed, 4180 insertions(+), 248 deletions(-)
 delete mode 100644 drivers/vhost/Kconfig.vringh
 create mode 100644 drivers/vhost/iotlb.c
 create mode 100644 drivers/vhost/vdpa.c
 create mode 100644 drivers/virtio/vdpa/Kconfig
 create mode 100644 drivers/virtio/vdpa/Makefile
 create mode 100644 drivers/virtio/vdpa/ifcvf/Makefile
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_base.c
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_base.h
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_main.c
 create mode 100644 drivers/virtio/vdpa/vdpa.c
 create mode 100644 drivers/virtio/vdpa/vdpa_sim/Makefile
 create mode 100644 drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c
 create mode 100644 drivers/virtio/virtio_vdpa.c
 create mode 100644 include/linux/vdpa.h
 create mode 100644 include/linux/vhost_iotlb.h
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH v9 1/9 vhost: refine vhost and vringh kconfig

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

---
 arch/arm/kvm/Kconfig         |  2 --
 arch/arm64/kvm/Kconfig       |  2 --
 arch/mips/kvm/Kconfig        |  2 --
 arch/powerpc/kvm/Kconfig     |  2 --
 arch/s390/kvm/Kconfig        |  4 ----
 arch/x86/kvm/Kconfig         |  4 ----
 drivers/Kconfig              |  2 ++
 drivers/misc/mic/Kconfig     |  4 ----
 drivers/net/caif/Kconfig     |  4 ----
 drivers/vhost/Kconfig        | 23 ++++++++++++++---------
 drivers/vhost/Kconfig.vringh |  6 ------
 11 files changed, 16 insertions(+), 39 deletions(-)
 delete mode 100644 drivers/vhost/Kconfig.vringh
arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
 	---help---
 	  Provides host support for ARM processors.
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
 config KVM_INDIRECT_VECTORS
        def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
 
 	  If unsure, say N.
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
 	default y
 	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
 
 	  If unsure, say N.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
 	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
 	 auditing of KVM MMU events at runtime.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
 
 source "drivers/virtio/Kconfig"
 
+source "drivers/vhost/Kconfig"
+
 source "drivers/hv/Kconfig"
 
 source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
 	  OS and tools for MIC to use with this driver are available from
 	  <http://software.intel.com/en-us/mic-developer>.
 
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
 endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
 	---help---
 	  The CAIF driver for CAIF over Virtio.
 
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
 endif # CAIF_DRIVERS
drivers/vhost/Kconfig +14 -9
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
 	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
 	default n
 	---help---
 	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
 	To compile this driver as a module, choose M here: the module will be called
 	vhost_vsock.
 
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
 	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
 	  adds some overhead, it is disabled by default.
 
 	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -6
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 7 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Quoted 204 lines

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

---
 arch/arm/kvm/Kconfig         |  2 --
 arch/arm64/kvm/Kconfig       |  2 --
 arch/mips/kvm/Kconfig        |  2 --
 arch/powerpc/kvm/Kconfig     |  2 --
 arch/s390/kvm/Kconfig        |  4 ----
 arch/x86/kvm/Kconfig         |  4 ----
 drivers/Kconfig              |  2 ++
 drivers/misc/mic/Kconfig     |  4 ----
 drivers/net/caif/Kconfig     |  4 ----
 drivers/vhost/Kconfig        | 23 ++++++++++++++---------
 drivers/vhost/Kconfig.vringh |  6 ------
 11 files changed, 16 insertions(+), 39 deletions(-)
 delete mode 100644 drivers/vhost/Kconfig.vringh
arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
 	---help---
 	  Provides host support for ARM processors.
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
 config KVM_INDIRECT_VECTORS
        def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
 
 	  If unsure, say N.
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
 	default y
 	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
 
 	  If unsure, say N.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
 	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
 	 auditing of KVM MMU events at runtime.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
 
 source "drivers/virtio/Kconfig"
 
+source "drivers/vhost/Kconfig"
+
 source "drivers/hv/Kconfig"
 
 source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
 	  OS and tools for MIC to use with this driver are available from
 	  <http://software.intel.com/en-us/mic-developer>.
 
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
 endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
 	---help---
 	  The CAIF driver for CAIF over Virtio.
 
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
 endif # CAIF_DRIVERS
drivers/vhost/Kconfig +14 -9
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
 	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
 	default n
 	---help---
 	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
 	To compile this driver as a module, choose M here: the module will be called
 	vhost_vsock.
 
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
 	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
 	  adds some overhead, it is disabled by default.
 
 	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -6
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
author
#3 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 11 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

If yes, what's your build config looks like?

Thanks

#4 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 10 lines · Jason Wang
Quoted 8 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

Quoted 7 lines
Quoted 3 lines

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 4 lines

If yes, what's your build config looks like?

Thanks

#5 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 42 lines · Christian Borntraeger
Quoted 10 lines · Jason Wang
Quoted 8 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

Quoted 7 lines
Quoted 3 lines

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 7 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

---
 arch/s390/configs/debug_defconfig | 5 +++--
 arch/s390/configs/defconfig       | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
arch/s390/configs/debug_defconfig +3 -2
index 46038bc58c9e..0b83274341ce 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
 CONFIG_CMM=m
 CONFIG_APPLDATA_BASE=y
 CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
 CONFIG_OPROFILE=m
 CONFIG_KPROBES=y
 CONFIG_JUMP_LABEL=y
@@ -561,6 +559,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
 CONFIG_VIRTIO_PCI=m
 CONFIG_VIRTIO_BALLOON=m
 CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
 CONFIG_S390_CCW_IOMMU=y
 CONFIG_S390_AP_IOMMU=y
 CONFIG_EXT4_FS=y
arch/s390/configs/defconfig +3 -2
index 7cd0648c1f4e..39e69c4e8cf7 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
 CONFIG_CMM=m
 CONFIG_APPLDATA_BASE=y
 CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
 CONFIG_OPROFILE=m
 CONFIG_KPROBES=y
 CONFIG_JUMP_LABEL=y
@@ -557,6 +555,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
 CONFIG_VIRTIO_PCI=m
 CONFIG_VIRTIO_BALLOON=m
 CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
 CONFIG_S390_CCW_IOMMU=y
 CONFIG_S390_AP_IOMMU=y
 CONFIG_EXT4_FS=y
Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 57 lines · Christian Borntraeger
Quoted 42 lines · Christian Borntraeger
Quoted 10 lines · Jason Wang
Quoted 8 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

Quoted 7 lines
Quoted 3 lines

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 7 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

And a bunch of other places I guess... and I guess we need to select VHOST_RING too?
Also Jason, I just noticed that you added:

config VHOST_RING
tristate
+ select VHOST_IOTLB
help
This option is selected by any driver which needs to access the host side of a virtio ring.

but are you sure this will do the right thing if VHOST_RING itself selected?

Quoted 53 lines
---
 arch/s390/configs/debug_defconfig | 5 +++--
 arch/s390/configs/defconfig       | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
arch/s390/configs/debug_defconfig +3 -2
index 46038bc58c9e..0b83274341ce 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
 CONFIG_CMM=m
 CONFIG_APPLDATA_BASE=y
 CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
 CONFIG_OPROFILE=m
 CONFIG_KPROBES=y
 CONFIG_JUMP_LABEL=y
@@ -561,6 +559,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
 CONFIG_VIRTIO_PCI=m
 CONFIG_VIRTIO_BALLOON=m
 CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
 CONFIG_S390_CCW_IOMMU=y
 CONFIG_S390_AP_IOMMU=y
 CONFIG_EXT4_FS=y
arch/s390/configs/defconfig +3 -2
index 7cd0648c1f4e..39e69c4e8cf7 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
 CONFIG_CMM=m
 CONFIG_APPLDATA_BASE=y
 CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
 CONFIG_OPROFILE=m
 CONFIG_KPROBES=y
 CONFIG_JUMP_LABEL=y
@@ -557,6 +555,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
 CONFIG_VIRTIO_PCI=m
 CONFIG_VIRTIO_BALLOON=m
 CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
 CONFIG_S390_CCW_IOMMU=y
 CONFIG_S390_AP_IOMMU=y
 CONFIG_EXT4_FS=y
Signature · 1 line
2.25.1
author
#7 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

In reply to Christian Borntraeger
Quoted 51 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
   HOSTCC  scripts/basic/fixdep
   HOSTCC  scripts/kconfig/conf.o
   HOSTCC  scripts/kconfig/confdata.o
   HOSTCC  scripts/kconfig/expr.o
   LEX     scripts/kconfig/lexer.lex.c
   YACC    scripts/kconfig/parser.tab.[ch]
   HOSTCC  scripts/kconfig/lexer.lex.o
   HOSTCC  scripts/kconfig/parser.tab.o
   HOSTCC  scripts/kconfig/preprocess.o
   HOSTCC  scripts/kconfig/symbol.o
   HOSTCC  scripts/kconfig/util.o
   HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 7 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

Quoted 52 lines
---
  arch/s390/configs/debug_defconfig | 5 +++--
  arch/s390/configs/defconfig       | 5 +++--
  2 files changed, 6 insertions(+), 4 deletions(-)
arch/s390/configs/debug_defconfig +3 -2
index 46038bc58c9e..0b83274341ce 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
  CONFIG_CMM=m
  CONFIG_APPLDATA_BASE=y
  CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
  CONFIG_OPROFILE=m
  CONFIG_KPROBES=y
  CONFIG_JUMP_LABEL=y
@@ -561,6 +559,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
  CONFIG_VIRTIO_PCI=m
  CONFIG_VIRTIO_BALLOON=m
  CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
  CONFIG_S390_CCW_IOMMU=y
  CONFIG_S390_AP_IOMMU=y
  CONFIG_EXT4_FS=y
arch/s390/configs/defconfig +3 -2
index 7cd0648c1f4e..39e69c4e8cf7 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
  CONFIG_CMM=m
  CONFIG_APPLDATA_BASE=y
  CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
  CONFIG_OPROFILE=m
  CONFIG_KPROBES=y
  CONFIG_JUMP_LABEL=y
@@ -557,6 +555,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
  CONFIG_VIRTIO_PCI=m
  CONFIG_VIRTIO_BALLOON=m
  CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
  CONFIG_S390_CCW_IOMMU=y
  CONFIG_S390_AP_IOMMU=y
  CONFIG_EXT4_FS=y
#8 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 64 lines · Jason Wang
Quoted 50 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
   HOSTCC  scripts/basic/fixdep
   HOSTCC  scripts/kconfig/conf.o
   HOSTCC  scripts/kconfig/confdata.o
   HOSTCC  scripts/kconfig/expr.o
   LEX     scripts/kconfig/lexer.lex.c
   YACC    scripts/kconfig/parser.tab.[ch]
   HOSTCC  scripts/kconfig/lexer.lex.o
   HOSTCC  scripts/kconfig/parser.tab.o
   HOSTCC  scripts/kconfig/preprocess.o
   HOSTCC  scripts/kconfig/symbol.o
   HOSTCC  scripts/kconfig/util.o
   HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 6 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

Quoted 8 lines

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

I think I prefer 2, but does it auto-select VHOST_IOTLB then? Generally what was the reason to drop select VHOST from devices?

Quoted 53 lines
Quoted 53 lines

---
  arch/s390/configs/debug_defconfig | 5 +++--
  arch/s390/configs/defconfig       | 5 +++--
  2 files changed, 6 insertions(+), 4 deletions(-)
arch/s390/configs/debug_defconfig +3 -2
index 46038bc58c9e..0b83274341ce 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
  CONFIG_CMM=m
  CONFIG_APPLDATA_BASE=y
  CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
  CONFIG_OPROFILE=m
  CONFIG_KPROBES=y
  CONFIG_JUMP_LABEL=y
@@ -561,6 +559,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
  CONFIG_VIRTIO_PCI=m
  CONFIG_VIRTIO_BALLOON=m
  CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
  CONFIG_S390_CCW_IOMMU=y
  CONFIG_S390_AP_IOMMU=y
  CONFIG_EXT4_FS=y
arch/s390/configs/defconfig +3 -2
index 7cd0648c1f4e..39e69c4e8cf7 100644
@@ -57,8 +57,6 @@ CONFIG_PROTECTED_VIRTUALIZATION_GUEST=y
  CONFIG_CMM=m
  CONFIG_APPLDATA_BASE=y
  CONFIG_KVM=m
-CONFIG_VHOST_NET=m
-CONFIG_VHOST_VSOCK=m
  CONFIG_OPROFILE=m
  CONFIG_KPROBES=y
  CONFIG_JUMP_LABEL=y
@@ -557,6 +555,9 @@ CONFIG_VFIO_MDEV_DEVICE=m
  CONFIG_VIRTIO_PCI=m
  CONFIG_VIRTIO_BALLOON=m
  CONFIG_VIRTIO_INPUT=y
+CONFIG_VHOST=m
+CONFIG_VHOST_NET=m
+CONFIG_VHOST_VSOCK=m
  CONFIG_S390_CCW_IOMMU=y
  CONFIG_S390_AP_IOMMU=y
  CONFIG_EXT4_FS=y
author
#9 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 64 lines · Michael S. Tsirkin
Quoted 63 lines · Jason Wang
Quoted 49 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commithttps://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
    HOSTCC  scripts/basic/fixdep
    HOSTCC  scripts/kconfig/conf.o
    HOSTCC  scripts/kconfig/confdata.o
    HOSTCC  scripts/kconfig/expr.o
    LEX     scripts/kconfig/lexer.lex.c
    YACC    scripts/kconfig/parser.tab.[ch]
    HOSTCC  scripts/kconfig/lexer.lex.o
    HOSTCC  scripts/kconfig/parser.tab.o
    HOSTCC  scripts/kconfig/preprocess.o
    HOSTCC  scripts/kconfig/symbol.o
    HOSTCC  scripts/kconfig/util.o
    HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 6 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

Quoted 6 lines
Quoted 5 lines

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

I think I prefer 2, but does it auto-select VHOST_IOTLB then?

I think so. E.g VHOST_NET will select VHOST,  and VHOST will select VHOST_IOTLB.

Quoted 3 lines

Generally what was the reason to drop select VHOST from devices?

The reason is a sub menu is needed for VHOST devices, then I use menuconfig for CONFIG_VHOST.

Then select is not necessary anymore.

Thanks

#10 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

In reply to Jason Wang
Quoted 64 lines · Jason Wang
Quoted 50 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
   HOSTCC  scripts/basic/fixdep
   HOSTCC  scripts/kconfig/conf.o
   HOSTCC  scripts/kconfig/confdata.o
   HOSTCC  scripts/kconfig/expr.o
   LEX     scripts/kconfig/lexer.lex.c
   YACC    scripts/kconfig/parser.tab.[ch]
   HOSTCC  scripts/kconfig/lexer.lex.o
   HOSTCC  scripts/kconfig/parser.tab.o
   HOSTCC  scripts/kconfig/preprocess.o
   HOSTCC  scripts/kconfig/symbol.o
   HOSTCC  scripts/kconfig/util.o
   HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 6 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

Quoted 8 lines

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

OK I tried this:

drivers/vhost/Kconfig +4 -4
index 2523a1d4290a..a314b900d479 100644
@@ -19,11 +19,10 @@ menuconfig VHOST
 	  This option is selected by any driver which needs to access
 	  the core of vhost.
 
-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
@@ -35,6 +34,7 @@ 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
@@ -44,6 +44,7 @@ config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
 	select VIRTIO_VSOCKETS_COMMON
+	select VHOST
 	default n
 	---help---
 	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -57,6 +58,7 @@ config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
 	select VDPA
+	select VHOST
 	help
 	  This kernel module can be loaded in host kernel to accelerate
 	  guest virtio devices with the vDPA-based backends.
@@ -78,5 +80,3 @@ config VHOST_CROSS_ENDIAN_LEGACY
 	  adds some overhead, it is disabled by default.
 
 	  If unsure, say "N".
-
-endif

But now CONFIG_VHOST is always "y", never "m".
Which I think will make it a built-in.
Didn't figure out why yet.

Signature · 1 line
MST
author
#11 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 121 lines · Michael S. Tsirkin
Quoted 61 lines · Jason Wang
Quoted 49 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
    HOSTCC  scripts/basic/fixdep
    HOSTCC  scripts/kconfig/conf.o
    HOSTCC  scripts/kconfig/confdata.o
    HOSTCC  scripts/kconfig/expr.o
    LEX     scripts/kconfig/lexer.lex.c
    YACC    scripts/kconfig/parser.tab.[ch]
    HOSTCC  scripts/kconfig/lexer.lex.o
    HOSTCC  scripts/kconfig/parser.tab.o
    HOSTCC  scripts/kconfig/preprocess.o
    HOSTCC  scripts/kconfig/symbol.o
    HOSTCC  scripts/kconfig/util.o
    HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 6 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

Quoted 8 lines

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

OK I tried this:

drivers/vhost/Kconfig +4 -4
index 2523a1d4290a..a314b900d479 100644
@@ -19,11 +19,10 @@ menuconfig VHOST
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
 
-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
@@ -35,6 +34,7 @@ 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
@@ -44,6 +44,7 @@ config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
  	select VIRTIO_VSOCKETS_COMMON
+	select VHOST
  	default n
  	---help---
  	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -57,6 +58,7 @@ config VHOST_VDPA
  	tristate "Vhost driver for vDPA-based backend"
  	depends on EVENTFD
  	select VDPA
+	select VHOST
  	help
  	  This kernel module can be loaded in host kernel to accelerate
  	  guest virtio devices with the vDPA-based backends.
@@ -78,5 +80,3 @@ config VHOST_CROSS_ENDIAN_LEGACY
  	  adds some overhead, it is disabled by default.
 
  	  If unsure, say "N".
-
-endif
Quoted 3 lines

But now CONFIG_VHOST is always "y", never "m".
Which I think will make it a built-in.
Didn't figure out why yet.

Is it because the dependency of EVENTFD for CONFIG_VHOST?

Remove that one for this patch, I can get CONFIG_VHOST=m.

But according to documentation/kbuild/kconfig.rst, select is used for option without prompt.

Thanks

Quoted 1 line
#12 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 121 lines · Jason Wang
Quoted 119 lines · Michael S. Tsirkin
Quoted 61 lines · Jason Wang
Quoted 49 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
    HOSTCC  scripts/basic/fixdep
    HOSTCC  scripts/kconfig/conf.o
    HOSTCC  scripts/kconfig/confdata.o
    HOSTCC  scripts/kconfig/expr.o
    LEX     scripts/kconfig/lexer.lex.c
    YACC    scripts/kconfig/parser.tab.[ch]
    HOSTCC  scripts/kconfig/lexer.lex.o
    HOSTCC  scripts/kconfig/parser.tab.o
    HOSTCC  scripts/kconfig/preprocess.o
    HOSTCC  scripts/kconfig/symbol.o
    HOSTCC  scripts/kconfig/util.o
    HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 6 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

Quoted 8 lines

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

OK I tried this:

drivers/vhost/Kconfig +4 -4
index 2523a1d4290a..a314b900d479 100644
@@ -19,11 +19,10 @@ menuconfig VHOST
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
-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
@@ -35,6 +34,7 @@ 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
@@ -44,6 +44,7 @@ config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
  	select VIRTIO_VSOCKETS_COMMON
+	select VHOST
  	default n
  	---help---
  	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -57,6 +58,7 @@ config VHOST_VDPA
  	tristate "Vhost driver for vDPA-based backend"
  	depends on EVENTFD
  	select VDPA
+	select VHOST
  	help
  	  This kernel module can be loaded in host kernel to accelerate
  	  guest virtio devices with the vDPA-based backends.
@@ -78,5 +80,3 @@ config VHOST_CROSS_ENDIAN_LEGACY
  	  adds some overhead, it is disabled by default.
  	  If unsure, say "N".
-
-endif
 
Quoted 6 lines
Quoted 3 lines

But now CONFIG_VHOST is always "y", never "m".
Which I think will make it a built-in.
Didn't figure out why yet.

Is it because the dependency of EVENTFD for CONFIG_VHOST?

Oh no, it's because I forgot to change menuconfig to config.

Quoted 9 lines

Remove that one for this patch, I can get CONFIG_VHOST=m.

But according to documentation/kbuild/kconfig.rst, select is used for option without prompt.

Thanks

Quoted 1 line
#13 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 122 lines · Michael S. Tsirkin
Quoted 121 lines · Jason Wang
Quoted 119 lines · Michael S. Tsirkin
Quoted 61 lines · Jason Wang
Quoted 49 lines · Christian Borntraeger
Quoted 38 lines · Christian Borntraeger
Quoted 7 lines · Jason Wang
Quoted 6 lines · Christian Borntraeger
Quoted 5 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

FWIW, this now results in vhost not being build with defconfig kernels (in todays linux-next).

Hi Christian:

Did you meet it even with this commit https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=a4be40cbcedba9b5b714f3c95182e8a45176e42d?

I simply used linux-next. The defconfig does NOT contain CONFIG_VHOST and therefore CONFIG_VHOST_NET and friends can not be selected.

$ git checkout next-20200401
$ make defconfig
    HOSTCC  scripts/basic/fixdep
    HOSTCC  scripts/kconfig/conf.o
    HOSTCC  scripts/kconfig/confdata.o
    HOSTCC  scripts/kconfig/expr.o
    LEX     scripts/kconfig/lexer.lex.c
    YACC    scripts/kconfig/parser.tab.[ch]
    HOSTCC  scripts/kconfig/lexer.lex.o
    HOSTCC  scripts/kconfig/parser.tab.o
    HOSTCC  scripts/kconfig/preprocess.o
    HOSTCC  scripts/kconfig/symbol.o
    HOSTCC  scripts/kconfig/util.o
    HOSTLD  scripts/kconfig/conf
*** Default configuration is based on 'x86_64_defconfig'
#
# configuration written to .config
#
Quoted 6 lines
$ grep VHOST .config
# CONFIG_VHOST is not set
Quoted 3 lines

If yes, what's your build config looks like?

Thanks

This was x86. Not sure if that did work before.
On s390 this is definitely a regression as the defconfig files for s390 do select VHOST_NET

Quoted 8 lines

grep VHOST arch/s390/configs/* arch/s390/configs/debug_defconfig:CONFIG_VHOST_NET=m arch/s390/configs/debug_defconfig:CONFIG_VHOST_VSOCK=m arch/s390/configs/defconfig:CONFIG_VHOST_NET=m arch/s390/configs/defconfig:CONFIG_VHOST_VSOCK=m

and this worked with 5.6, but does not work with next. Just adding CONFIG_VHOST=m to the defconfig solves the issue, something like

Right, I think we probably need

Quoted 8 lines

1) add CONFIG_VHOST=m to all defconfigs that enables CONFIG_VHOST_NET/VSOCK/SCSI.

or

2) don't use menuconfig for CONFIG_VHOST, let NET/SCSI/VDPA just select it.

Thanks

OK I tried this:

drivers/vhost/Kconfig +4 -4
index 2523a1d4290a..a314b900d479 100644
@@ -19,11 +19,10 @@ menuconfig VHOST
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
-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
@@ -35,6 +34,7 @@ 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
@@ -44,6 +44,7 @@ config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
  	select VIRTIO_VSOCKETS_COMMON
+	select VHOST
  	default n
  	---help---
  	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -57,6 +58,7 @@ config VHOST_VDPA
  	tristate "Vhost driver for vDPA-based backend"
  	depends on EVENTFD
  	select VDPA
+	select VHOST
  	help
  	  This kernel module can be loaded in host kernel to accelerate
  	  guest virtio devices with the vDPA-based backends.
@@ -78,5 +80,3 @@ config VHOST_CROSS_ENDIAN_LEGACY
  	  adds some overhead, it is disabled by default.
  	  If unsure, say "N".
-
-endif
 
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines

But now CONFIG_VHOST is always "y", never "m".
Which I think will make it a built-in.
Didn't figure out why yet.

Is it because the dependency of EVENTFD for CONFIG_VHOST?

Oh no, it's because I forgot to change menuconfig to config.

Quoted 1 line

Remove that one for this patch, I can get CONFIG_VHOST=m.

FWIW, the current vhost/linux-next branch seems to work again.

#14 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

In reply to Jason Wang
Quoted 8 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

Quoted 6 lines

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

Is this just so we can drop the dependency on CONFIG_VIRTUALIZATION? If yes what happens if we drop this patch?
Given the impact it had I'd like to defer it till next release if possible.

Quoted 133 lines
---
 arch/arm/kvm/Kconfig         |  2 --
 arch/arm64/kvm/Kconfig       |  2 --
 arch/mips/kvm/Kconfig        |  2 --
 arch/powerpc/kvm/Kconfig     |  2 --
 arch/s390/kvm/Kconfig        |  4 ----
 arch/x86/kvm/Kconfig         |  4 ----
 drivers/Kconfig              |  2 ++
 drivers/misc/mic/Kconfig     |  4 ----
 drivers/net/caif/Kconfig     |  4 ----
 drivers/vhost/Kconfig        | 23 ++++++++++++++---------
 drivers/vhost/Kconfig.vringh |  6 ------
 11 files changed, 16 insertions(+), 39 deletions(-)
 delete mode 100644 drivers/vhost/Kconfig.vringh
arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
 	---help---
 	  Provides host support for ARM processors.
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
 config KVM_INDIRECT_VECTORS
        def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
 
 	  If unsure, say N.
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
 	default y
 	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
 
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
 
 	  If unsure, say N.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
 	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
 	 auditing of KVM MMU events at runtime.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
 endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
 
 source "drivers/virtio/Kconfig"
 
+source "drivers/vhost/Kconfig"
+
 source "drivers/hv/Kconfig"
 
 source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
 	  OS and tools for MIC to use with this driver are available from
 	  <http://software.intel.com/en-us/mic-developer>.
 
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
 endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
 	---help---
 	  The CAIF driver for CAIF over Virtio.
 
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
 endif # CAIF_DRIVERS
drivers/vhost/Kconfig +3 -0
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help

drivers/vhost/Kconfig line 14

Quoted 10 lines
drivers/vhost/Kconfig +10 -0
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+if VHOST
+

The description here is wrong, isn't it? VHOST and VHOST_RING are no longer selected, right?

Quoted 55 lines
drivers/vhost/Kconfig +1 -9
 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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
 	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
 	default n
 	---help---
 	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
 	To compile this driver as a module, choose M here: the module will be called
 	vhost_vsock.
 
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
 	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
 	  adds some overhead, it is disabled by default.
 
 	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -6
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1
author
#15 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 9 lines · Michael S. Tsirkin
Quoted 8 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

Quoted 8 lines
Quoted 6 lines

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

Is this just so we can drop the dependency on CONFIG_VIRTUALIZATION? If yes what happens if we drop this patch?

The problem is that then VHOST_RING must depend on CONFIG_VIRTUALIZATION (which enable VHOST_IOTLB) to work.

But it looks to me CAIF and VOP doesn't requires CONFIG_VIRTUALIZATION.

Quoted 141 lines

Given the impact it had I'd like to defer it till next release if possible.

Quoted 137 lines
---
  arch/arm/kvm/Kconfig         |  2 --
  arch/arm64/kvm/Kconfig       |  2 --
  arch/mips/kvm/Kconfig        |  2 --
  arch/powerpc/kvm/Kconfig     |  2 --
  arch/s390/kvm/Kconfig        |  4 ----
  arch/x86/kvm/Kconfig         |  4 ----
  drivers/Kconfig              |  2 ++
  drivers/misc/mic/Kconfig     |  4 ----
  drivers/net/caif/Kconfig     |  4 ----
  drivers/vhost/Kconfig        | 23 ++++++++++++++---------
  drivers/vhost/Kconfig.vringh |  6 ------
  11 files changed, 16 insertions(+), 39 deletions(-)

delete mode 100644 drivers/vhost/Kconfig.vringh

arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
  	---help---
  	  Provides host support for ARM processors.
 
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
  config KVM_INDIRECT_VECTORS
         def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
 
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
 
  	  If unsure, say N.
 
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
  	default y
  	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
 
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
 
  	  If unsure, say N.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
  	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
  	 auditing of KVM MMU events at runtime.
 
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
 
  source "drivers/virtio/Kconfig"
 
+source "drivers/vhost/Kconfig"
+
  source "drivers/hv/Kconfig"
 
  source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
  	  OS and tools for MIC to use with this driver are available from
  	  <http://software.intel.com/en-us/mic-developer>.
 
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
  endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
  	---help---
  	  The CAIF driver for CAIF over Virtio.
 
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
  endif # CAIF_DRIVERS
drivers/vhost/Kconfig +7 -0
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
  # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
Quoted 8 lines

drivers/vhost/Kconfig line 14

Quoted 6 lines
drivers/vhost/Kconfig +6 -0
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+if VHOST
+

The description here is wrong, isn't it? VHOST and VHOST_RING are no longer selected, right?

For VHOST not currently.

For VHOST_RING, it was selected by CAIF, VOP and VDPASIM.

Thanks

Quoted 57 lines
Quoted 57 lines
drivers/vhost/Kconfig +1 -9
  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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
  	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
  	default n
  	---help---
  	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
  	To compile this driver as a module, choose M here: the module will be called
  	vhost_vsock.
 
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
  config VHOST_CROSS_ENDIAN_LEGACY
  	bool "Cross-endian support for vhost"
  	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
  	  adds some overhead, it is disabled by default.
 
  	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -6
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1
#16 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 17 lines · Jason Wang
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

Quoted 8 lines
Quoted 2 lines

Is this just so we can drop the dependency on CONFIG_VIRTUALIZATION? If yes what happens if we drop this patch?

The problem is that then VHOST_RING must depend on CONFIG_VIRTUALIZATION (which enable VHOST_IOTLB) to work.

But it looks to me CAIF and VOP doesn't requires CONFIG_VIRTUALIZATION.

How about stubs for IOTLB so VHOST_RING does not depend on VHOST_IOTLB? I'm pretty sure neither user of vringh can actually use IOTLB, it's a software only thing.

Quoted 139 lines
Quoted 129 lines

Given the impact it had I'd like to defer it till next release if possible.

Quoted 124 lines
---
  arch/arm/kvm/Kconfig         |  2 --
  arch/arm64/kvm/Kconfig       |  2 --
  arch/mips/kvm/Kconfig        |  2 --
  arch/powerpc/kvm/Kconfig     |  2 --
  arch/s390/kvm/Kconfig        |  4 ----
  arch/x86/kvm/Kconfig         |  4 ----
  drivers/Kconfig              |  2 ++
  drivers/misc/mic/Kconfig     |  4 ----
  drivers/net/caif/Kconfig     |  4 ----
  drivers/vhost/Kconfig        | 23 ++++++++++++++---------
  drivers/vhost/Kconfig.vringh |  6 ------
  11 files changed, 16 insertions(+), 39 deletions(-)

delete mode 100644 drivers/vhost/Kconfig.vringh

arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
  	---help---
  	  Provides host support for ARM processors.
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
  config KVM_INDIRECT_VECTORS
         def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
  	  If unsure, say N.
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
  	default y
  	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
  	  If unsure, say N.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
  	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
  	 auditing of KVM MMU events at runtime.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
  endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
  source "drivers/virtio/Kconfig"
+source "drivers/vhost/Kconfig"
+
  source "drivers/hv/Kconfig"
  source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
  	  OS and tools for MIC to use with this driver are available from
  	  <http://software.intel.com/en-us/mic-developer>.
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
  endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
  	---help---
  	  The CAIF driver for CAIF over Virtio.
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
  endif # CAIF_DRIVERS
drivers/vhost/Kconfig +7 -0
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
  # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
Quoted 8 lines

drivers/vhost/Kconfig line 14

Quoted 6 lines
drivers/vhost/Kconfig +6 -0
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+if VHOST
+

The description here is wrong, isn't it? VHOST and VHOST_RING are no longer selected, right?

Quoted 1 line

For VHOST not currently.

Can we just bring it back and select it?

Quoted 60 lines

For VHOST_RING, it was selected by CAIF, VOP and VDPASIM.

Thanks

Quoted 55 lines
Quoted 55 lines
drivers/vhost/Kconfig +1 -9
  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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
  	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
  	default n
  	---help---
  	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
  	To compile this driver as a module, choose M here: the module will be called
  	vhost_vsock.
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
  config VHOST_CROSS_ENDIAN_LEGACY
  	bool "Cross-endian support for vhost"
  	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
  	  adds some overhead, it is disabled by default.
  	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -6
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1
author
#17 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Jason Wang
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

Is this just so we can drop the dependency on CONFIG_VIRTUALIZATION? If yes what happens if we drop this patch?

The problem is that then VHOST_RING must depend on CONFIG_VIRTUALIZATION (which enable VHOST_IOTLB) to work.

But it looks to me CAIF and VOP doesn't requires CONFIG_VIRTUALIZATION.

How about stubs for IOTLB so VHOST_RING does not depend on VHOST_IOTLB?

That could work.

Quoted 2 lines

I'm pretty sure neither user of vringh can actually use IOTLB, it's a software only thing.

Right.

Quoted 138 lines
Quoted 138 lines
Quoted 137 lines

Given the impact it had I'd like to defer it till next release if possible.

Quoted 120 lines
---
   arch/arm/kvm/Kconfig         |  2 --
   arch/arm64/kvm/Kconfig       |  2 --
   arch/mips/kvm/Kconfig        |  2 --
   arch/powerpc/kvm/Kconfig     |  2 --
   arch/s390/kvm/Kconfig        |  4 ----
   arch/x86/kvm/Kconfig         |  4 ----
   drivers/Kconfig              |  2 ++
   drivers/misc/mic/Kconfig     |  4 ----
   drivers/net/caif/Kconfig     |  4 ----
   drivers/vhost/Kconfig        | 23 ++++++++++++++---------
   drivers/vhost/Kconfig.vringh |  6 ------
   11 files changed, 16 insertions(+), 39 deletions(-)

delete mode 100644 drivers/vhost/Kconfig.vringh

arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
   	---help---
   	  Provides host support for ARM processors.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
   config KVM_INDIRECT_VECTORS
          def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
   	  If unsure, say N.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
   	default y
   	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
   	  If unsure, say N.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
   	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
   	 auditing of KVM MMU events at runtime.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
   source "drivers/virtio/Kconfig"
+source "drivers/vhost/Kconfig"
+
   source "drivers/hv/Kconfig"
   source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
   	  OS and tools for MIC to use with this driver are available from
   	  <http://software.intel.com/en-us/mic-developer>.
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
   endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
   	---help---
   	  The CAIF driver for CAIF over Virtio.
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
   endif # CAIF_DRIVERS
drivers/vhost/Kconfig +3 -0
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
   # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help

drivers/vhost/Kconfig line 14

Quoted 10 lines
drivers/vhost/Kconfig +10 -0
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+if VHOST
+

The description here is wrong, isn't it? VHOST and VHOST_RING are no longer selected, right?

Quoted 2 lines
Quoted 1 line

For VHOST not currently.

Can we just bring it back and select it?

Right, so if bring it back, we don't even need the stub.

How about something like attached?

Thanks

Quoted 52 lines
Quoted 52 lines

For VHOST_RING, it was selected by CAIF, VOP and VDPASIM.

Thanks

Quoted 46 lines
Quoted 46 lines
drivers/vhost/Kconfig +1 -9
   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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
   	tristate "vhost virtio-vsock driver"
   	depends on VSOCKETS && EVENTFD
   	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
   	default n
   	---help---
   	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
   	To compile this driver as a module, choose M here: the module will be called
   	vhost_vsock.
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
   config VHOST_CROSS_ENDIAN_LEGACY
   	bool "Cross-endian support for vhost"
   	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
   	  adds some overhead, it is disabled by default.
   	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -0
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/vhost/Kconfig.vringh deleted +0 -6
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001
From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
 drivers/vhost/Kconfig | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +11 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
 	select VHOST_IOTLB
 	help
 	  This option is selected by any driver which needs to access
 	  the core of vhost.
 
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
 
 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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
 config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
+	select VHOST
 	select VIRTIO_VSOCKETS_COMMON
 	default n
 	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
 config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
+	select VHOST
 	select VDPA
 	help
 	  This kernel module can be loaded in host kernel to accelerate
Signature · 1 line
2.20.1
#18 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 278 lines · Jason Wang
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Jason Wang
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

Is this just so we can drop the dependency on CONFIG_VIRTUALIZATION? If yes what happens if we drop this patch?

The problem is that then VHOST_RING must depend on CONFIG_VIRTUALIZATION (which enable VHOST_IOTLB) to work.

But it looks to me CAIF and VOP doesn't requires CONFIG_VIRTUALIZATION.

How about stubs for IOTLB so VHOST_RING does not depend on VHOST_IOTLB?

That could work.

Quoted 2 lines

I'm pretty sure neither user of vringh can actually use IOTLB, it's a software only thing.

Right.

Quoted 138 lines
Quoted 138 lines
Quoted 137 lines

Given the impact it had I'd like to defer it till next release if possible.

Quoted 120 lines
---
   arch/arm/kvm/Kconfig         |  2 --
   arch/arm64/kvm/Kconfig       |  2 --
   arch/mips/kvm/Kconfig        |  2 --
   arch/powerpc/kvm/Kconfig     |  2 --
   arch/s390/kvm/Kconfig        |  4 ----
   arch/x86/kvm/Kconfig         |  4 ----
   drivers/Kconfig              |  2 ++
   drivers/misc/mic/Kconfig     |  4 ----
   drivers/net/caif/Kconfig     |  4 ----
   drivers/vhost/Kconfig        | 23 ++++++++++++++---------
   drivers/vhost/Kconfig.vringh |  6 ------
   11 files changed, 16 insertions(+), 39 deletions(-)

delete mode 100644 drivers/vhost/Kconfig.vringh

arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
   	---help---
   	  Provides host support for ARM processors.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
   config KVM_INDIRECT_VECTORS
          def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
   	  If unsure, say N.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
   	default y
   	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
   	  If unsure, say N.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
   	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
   	 auditing of KVM MMU events at runtime.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
   source "drivers/virtio/Kconfig"
+source "drivers/vhost/Kconfig"
+
   source "drivers/hv/Kconfig"
   source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
   	  OS and tools for MIC to use with this driver are available from
   	  <http://software.intel.com/en-us/mic-developer>.
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
   endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
   	---help---
   	  The CAIF driver for CAIF over Virtio.
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
   endif # CAIF_DRIVERS
drivers/vhost/Kconfig +3 -0
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
   # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help

drivers/vhost/Kconfig line 14

Quoted 10 lines
drivers/vhost/Kconfig +10 -0
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+if VHOST
+

The description here is wrong, isn't it? VHOST and VHOST_RING are no longer selected, right?

Quoted 2 lines
Quoted 1 line

For VHOST not currently.

Can we just bring it back and select it?

Right, so if bring it back, we don't even need the stub.

How about something like attached?

Thanks

Quoted 54 lines
Quoted 54 lines

For VHOST_RING, it was selected by CAIF, VOP and VDPASIM.

Thanks

Quoted 48 lines
Quoted 48 lines
drivers/vhost/Kconfig +1 -9
   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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
   	tristate "vhost virtio-vsock driver"
   	depends on VSOCKETS && EVENTFD
   	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
   	default n
   	---help---
   	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
   	To compile this driver as a module, choose M here: the module will be called
   	vhost_vsock.
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
   config VHOST_CROSS_ENDIAN_LEGACY
   	bool "Cross-endian support for vhost"
   	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
   	  adds some overhead, it is disabled by default.
   	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -2
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/vhost/Kconfig.vringh deleted +0 -4
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
 drivers/vhost/Kconfig | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +2 -3
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
 	select VHOST_IOTLB

drivers/vhost/Kconfig config VHOST_RING · line 25

Quoted 10 lines
drivers/vhost/Kconfig +5 -1
 	help
 	  This option is selected by any driver which needs to access
 	  the core of vhost.
 
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU

Will this not still have the problem with defconfigs? They don't set VHOST_MENU ...

Quoted 35 lines
drivers/vhost/Kconfig +4 -0
 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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
 config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
+	select VHOST
 	select VIRTIO_VSOCKETS_COMMON
 	default n
 	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
 config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
+	select VHOST
 	select VDPA
 	help
 	  This kernel module can be loaded in host kernel to accelerate
Signature · 1 line
2.20.1
author
#19 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 18 lines · Michael S. Tsirkin
Quoted 18 lines
drivers/vhost/Kconfig +2 -3
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
  	  This option is selected by any driver which needs to access
  	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
  	select VHOST_IOTLB
  	help
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
 
Quoted 8 lines

drivers/vhost/Kconfig config VHOST_RING · line 25

Quoted 6 lines
drivers/vhost/Kconfig +5 -1
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU

Will this not still have the problem with defconfigs? They don't set VHOST_MENU ...

Looks not, since it was enabled by default.

I tested this on s390/ppc defconfigs:

# make ARCH=s390 defconfig
*** Default configuration is based on 'defconfig'
#
# No change to .config
#
# grep CONFIG_VHOST .config
CONFIG_VHOST_IOTLB=m
CONFIG_VHOST=m
CONFIG_VHOST_MENU=y
CONFIG_VHOST_NET=m
CONFIG_VHOST_VSOCK=m
# CONFIG_VHOST_VDPA is not set
# CONFIG_VHOST_CROSS_ENDIAN_LEGACY is not set

Thanks

#20 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

In reply to Jason Wang
Quoted 279 lines · Jason Wang
Quoted 17 lines · Michael S. Tsirkin
Quoted 16 lines · Jason Wang
Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Jason Wang

Currently, CONFIG_VHOST depends on CONFIG_VIRTUALIZATION. But vhost is not necessarily for VM since it's a generic userspace and kernel communication protocol. Such dependency may prevent archs without virtualization support from using vhost.

To solve this, a dedicated vhost menu is created under drivers so CONIFG_VHOST can be decoupled out of CONFIG_VIRTUALIZATION.

While at it, also squash Kconfig.vringh into vhost Kconfig file. This avoids the trick of conditional inclusion from VOP or CAIF. Then it will be easier to introduce new vringh users and common dependency for both vringh and vhost.

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

Is this just so we can drop the dependency on CONFIG_VIRTUALIZATION? If yes what happens if we drop this patch?

The problem is that then VHOST_RING must depend on CONFIG_VIRTUALIZATION (which enable VHOST_IOTLB) to work.

But it looks to me CAIF and VOP doesn't requires CONFIG_VIRTUALIZATION.

How about stubs for IOTLB so VHOST_RING does not depend on VHOST_IOTLB?

That could work.

Quoted 2 lines

I'm pretty sure neither user of vringh can actually use IOTLB, it's a software only thing.

Right.

Quoted 138 lines
Quoted 138 lines
Quoted 137 lines

Given the impact it had I'd like to defer it till next release if possible.

Quoted 120 lines
---
   arch/arm/kvm/Kconfig         |  2 --
   arch/arm64/kvm/Kconfig       |  2 --
   arch/mips/kvm/Kconfig        |  2 --
   arch/powerpc/kvm/Kconfig     |  2 --
   arch/s390/kvm/Kconfig        |  4 ----
   arch/x86/kvm/Kconfig         |  4 ----
   drivers/Kconfig              |  2 ++
   drivers/misc/mic/Kconfig     |  4 ----
   drivers/net/caif/Kconfig     |  4 ----
   drivers/vhost/Kconfig        | 23 ++++++++++++++---------
   drivers/vhost/Kconfig.vringh |  6 ------
   11 files changed, 16 insertions(+), 39 deletions(-)

delete mode 100644 drivers/vhost/Kconfig.vringh

arch/arm/kvm/Kconfig +0 -2
index f591026347a5..be97393761bf 100644
@@ -54,6 +54,4 @@ config KVM_ARM_HOST
   	---help---
   	  Provides host support for ARM processors.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/arm64/kvm/Kconfig +0 -2
index a475c68cbfec..449386d76441 100644
@@ -64,6 +64,4 @@ config KVM_ARM_PMU
   config KVM_INDIRECT_VECTORS
          def_bool KVM && (HARDEN_BRANCH_PREDICTOR || HARDEN_EL2_VECTORS)
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/mips/kvm/Kconfig +0 -2
index eac25aef21e0..b91d145aa2d5 100644
@@ -72,6 +72,4 @@ config KVM_MIPS_DEBUG_COP0_COUNTERS
   	  If unsure, say N.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/powerpc/kvm/Kconfig +0 -2
index 711fca9bc6f0..12885eda324e 100644
@@ -204,6 +204,4 @@ config KVM_XIVE
   	default y
   	depends on KVM_XICS && PPC_XIVE_NATIVE && KVM_BOOK3S_HV_POSSIBLE
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/s390/kvm/Kconfig +0 -4
index d3db3d7ed077..def3b60f1fe8 100644
@@ -55,8 +55,4 @@ config KVM_S390_UCONTROL
   	  If unsure, say N.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
arch/x86/kvm/Kconfig +0 -4
index 991019d5eee1..0dfe70e17af9 100644
@@ -94,8 +94,4 @@ config KVM_MMU_AUDIT
   	 This option adds a R/W kVM module parameter 'mmu_audit', which allows
   	 auditing of KVM MMU events at runtime.
-# OK, it's a little counter-intuitive to do this, but it puts it neatly under
-# the virtualization menu.
-source "drivers/vhost/Kconfig"
-
   endif # VIRTUALIZATION
drivers/Kconfig +2 -0
index 8befa53f43be..7a6d8b2b68b4 100644
@@ -138,6 +138,8 @@ source "drivers/virt/Kconfig"
   source "drivers/virtio/Kconfig"
+source "drivers/vhost/Kconfig"
+
   source "drivers/hv/Kconfig"
   source "drivers/xen/Kconfig"
drivers/misc/mic/Kconfig +0 -4
index b6841ba6d922..8f201d019f5a 100644
@@ -133,8 +133,4 @@ config VOP
   	  OS and tools for MIC to use with this driver are available from
   	  <http://software.intel.com/en-us/mic-developer>.
-if VOP
-source "drivers/vhost/Kconfig.vringh"
-endif
-
   endmenu
drivers/net/caif/Kconfig +0 -4
index e74e2bb61236..9db0570c5beb 100644
@@ -58,8 +58,4 @@ config CAIF_VIRTIO
   	---help---
   	  The CAIF driver for CAIF over Virtio.
-if CAIF_VIRTIO
-source "drivers/vhost/Kconfig.vringh"
-endif
-
   endif # CAIF_DRIVERS
drivers/vhost/Kconfig +3 -0
index 3d03ccbd1adc..4aef10a54cd1 100644
@@ -1,8 +1,20 @@
   # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_RING
+	tristate
+	help

drivers/vhost/Kconfig line 14

Quoted 10 lines
drivers/vhost/Kconfig +10 -0
+	  This option is selected by any driver which needs to access
+	  the host side of a virtio ring.
+
+menuconfig VHOST
+	tristate "Host kernel accelerator for virtio (VHOST)"
+	help
+	  This option is selected by any driver which needs to access
+	  the core of vhost.
+if VHOST
+

The description here is wrong, isn't it? VHOST and VHOST_RING are no longer selected, right?

Quoted 2 lines
Quoted 1 line

For VHOST not currently.

Can we just bring it back and select it?

Right, so if bring it back, we don't even need the stub.

How about something like attached?

Thanks

Quoted 54 lines
Quoted 54 lines

For VHOST_RING, it was selected by CAIF, VOP and VDPASIM.

Thanks

Quoted 48 lines
Quoted 48 lines
drivers/vhost/Kconfig +1 -9
   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
@@ -14,7 +26,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
@@ -24,7 +35,6 @@ config VHOST_VSOCK
   	tristate "vhost virtio-vsock driver"
   	depends on VSOCKETS && EVENTFD
   	select VIRTIO_VSOCKETS_COMMON
-	select VHOST
   	default n
   	---help---
   	This kernel module can be loaded in the host kernel to provide AF_VSOCK
@@ -34,12 +44,6 @@ config VHOST_VSOCK
   	To compile this driver as a module, choose M here: the module will be called
   	vhost_vsock.
-config VHOST
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the core of vhost.
-
   config VHOST_CROSS_ENDIAN_LEGACY
   	bool "Cross-endian support for vhost"
   	default n
@@ -54,3 +58,4 @@ config VHOST_CROSS_ENDIAN_LEGACY
   	  adds some overhead, it is disabled by default.
   	  If unsure, say "N".
+endif
drivers/vhost/Kconfig.vringh deleted +0 -2
deleted file mode 100644
index c1fe36a9b8d4..000000000000
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0-only
-config VHOST_RING
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/vhost/Kconfig.vringh deleted +0 -4
-	tristate
-	---help---
-	  This option is selected by any driver which needs to access
-	  the host side of a virtio ring.
Signature · 1 line
2.20.1

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
 drivers/vhost/Kconfig | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +2 -3
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
 	select VHOST_IOTLB

drivers/vhost/Kconfig config VHOST_RING · line 25

Quoted 10 lines
drivers/vhost/Kconfig +5 -1
 	help
 	  This option is selected by any driver which needs to access
 	  the core of vhost.
 
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU

In fact this is similar to VIRTIO, and I wonder whether VIRTIO has also been broken by

	commit 7b95fec6d2ffa53f4a8d637b0f223644d458ea4e
	Author: Vincent Legoll <[email protected]>
	Date:   Sun Jan 7 12:33:56 2018 +0100

	    virtio: make VIRTIO a menuconfig to ease disabling it all

I see lots of defconfigs set VIRTIO_PCI but not VIRTIO_MENU ...

Signature · 1 line
MST
author
#21 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 42 lines · Michael S. Tsirkin
Quoted 30 lines
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang<[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
  drivers/vhost/Kconfig | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +2 -3
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
  	  This option is selected by any driver which needs to access
  	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
  	select VHOST_IOTLB

drivers/vhost/Kconfig config VHOST_RING · line 25

Quoted 10 lines
drivers/vhost/Kconfig +5 -1
  	help
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
 
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU

In fact this is similar to VIRTIO, and I wonder whether VIRTIO has also been broken by

Quoted 7 lines
	commit 7b95fec6d2ffa53f4a8d637b0f223644d458ea4e
	Author: Vincent Legoll<[email protected]>
	Date:   Sun Jan 7 12:33:56 2018 +0100

	    virtio: make VIRTIO a menuconfig to ease disabling it all

I see lots of defconfigs set VIRTIO_PCI but not VIRTIO_MENU ...

Probably not since VIRTIO_MENU has "default y"

E.g for powerpc, I got:

# make ARCH=powerpc defconfig
*** Default configuration is based on 'ppc64_defconfig'
#
# No change to .config
#
# grep CONFIG_VIRTIO .config
CONFIG_VIRTIO_BLK=m
CONFIG_VIRTIO_NET=m
CONFIG_VIRTIO_CONSOLE=m
CONFIG_VIRTIO=m
CONFIG_VIRTIO_MENU=y
CONFIG_VIRTIO_PCI=m
CONFIG_VIRTIO_PCI_LEGACY=y
# CONFIG_VIRTIO_VDPA is not set
CONFIG_VIRTIO_BALLOON=m
# CONFIG_VIRTIO_INPUT is not set
# CONFIG_VIRTIO_MMIO is not set
# CONFIG_VIRTIO_FS is not set

Thanks

#22 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

In reply to Jason Wang
Quoted 23 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
 drivers/vhost/Kconfig | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +0 -0
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.

drivers/vhost/Kconfig config VHOST_RING · line 19

Quoted 10 lines
drivers/vhost/Kconfig +2 -3
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
 	select VHOST_IOTLB
 	help
 	  This option is selected by any driver which needs to access
 	  the core of vhost.

OK so don't we need the dependency on EVENTFD though? I recall there was a bug this was supposed to fix ...

Quoted 41 lines
drivers/vhost/Kconfig +9 -1
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
 
 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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
 config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
+	select VHOST
 	select VIRTIO_VSOCKETS_COMMON
 	default n
 	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
 config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
+	select VHOST
 	select VDPA
 	help
 	  This kernel module can be loaded in host kernel to accelerate
Signature · 1 line
2.20.1
#23 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

In reply to Jason Wang
Quoted 65 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
 drivers/vhost/Kconfig | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +10 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
 	select VHOST_IOTLB
 	help
 	  This option is selected by any driver which needs to access
 	  the core of vhost.
 
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
 
 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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
 config VHOST_VSOCK
 	tristate "vhost virtio-vsock driver"
 	depends on VSOCKETS && EVENTFD
+	select VHOST
 	select VIRTIO_VSOCKETS_COMMON
 	default n
 	---help---

drivers/vhost/Kconfig config VHOST_VSOCK · line 68

Quoted 7 lines
drivers/vhost/Kconfig +1 -0
@@ -56,6 +62,7 @@ config VHOST_VSOCK
 config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
+	select VHOST
 	select VDPA
 	help
 	  This kernel module can be loaded in host kernel to accelerate

OK so I squashed this into the original buggy patch. Could you please play with vhost branch of my tree on various arches? If it looks ok to you let me know I'll push this to next.

Signature · 1 line
MST
author
#24 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 62 lines · Michael S. Tsirkin
Quoted 61 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
  drivers/vhost/Kconfig | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +10 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
  	  This option is selected by any driver which needs to access
  	  the host side of a virtio ring.
 
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
  	select VHOST_IOTLB
  	help
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
 
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
 
  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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
  config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
+	select VHOST
Quoted 8 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 65

Quoted 8 lines
drivers/vhost/Kconfig +1 -0
  	select VIRTIO_VSOCKETS_COMMON
  	default n
  	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
  config VHOST_VDPA
  	tristate "Vhost driver for vDPA-based backend"
  	depends on EVENTFD
+	select VHOST

This part is not squashed.

Quoted 7 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 68

Quoted 3 lines
drivers/vhost/Kconfig +0 -0
  	select VDPA
  	help
  	  This kernel module can be loaded in host kernel to accelerate

OK so I squashed this into the original buggy patch. Could you please play with vhost branch of my tree on various arches? If it looks ok to you let me know I'll push this to next.

With the above part squashed. I've tested all the archs whose defconfig have VHOST_NET or VHOST_VSOCK enabled.

All looks fine.

Thanks

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#25 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 83 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
  drivers/vhost/Kconfig | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +10 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
  	  This option is selected by any driver which needs to access
  	  the host side of a virtio ring.
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
  	select VHOST_IOTLB
  	help
  	  This option is selected by any driver which needs to access
  	  the core of vhost.
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
  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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
  config VHOST_VSOCK
  	tristate "vhost virtio-vsock driver"
  	depends on VSOCKETS && EVENTFD
+	select VHOST
Quoted 8 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 65

Quoted 8 lines
drivers/vhost/Kconfig +1 -0
  	select VIRTIO_VSOCKETS_COMMON
  	default n
  	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
  config VHOST_VDPA
  	tristate "Vhost driver for vDPA-based backend"
  	depends on EVENTFD
+	select VHOST

This part is not squashed.

Quoted 7 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 68

Quoted 3 lines
drivers/vhost/Kconfig +0 -0
  	select VDPA
  	help
  	  This kernel module can be loaded in host kernel to accelerate

OK so I squashed this into the original buggy patch. Could you please play with vhost branch of my tree on various arches? If it looks ok to you let me know I'll push this to next.

Quoted 6 lines

With the above part squashed. I've tested all the archs whose defconfig have VHOST_NET or VHOST_VSOCK enabled.

All looks fine.

Thanks

I'm a bit confused. So is the next tag in my tree ok now?

Signature · 1 line
MST
author
#26 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 81 lines · Michael S. Tsirkin
Quoted 80 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
   drivers/vhost/Kconfig | 15 +++++++++++----
   1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +10 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
   	  This option is selected by any driver which needs to access
   	  the host side of a virtio ring.
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
   	select VHOST_IOTLB
   	help
   	  This option is selected by any driver which needs to access
   	  the core of vhost.
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
   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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
   config VHOST_VSOCK
   	tristate "vhost virtio-vsock driver"
   	depends on VSOCKETS && EVENTFD
+	select VHOST
Quoted 8 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 65

Quoted 8 lines
drivers/vhost/Kconfig +1 -0
   	select VIRTIO_VSOCKETS_COMMON
   	default n
   	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
   config VHOST_VDPA
   	tristate "Vhost driver for vDPA-based backend"
   	depends on EVENTFD
+	select VHOST

This part is not squashed.

Quoted 7 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 68

Quoted 3 lines
drivers/vhost/Kconfig +0 -0
   	select VDPA
   	help
   	  This kernel module can be loaded in host kernel to accelerate

OK so I squashed this into the original buggy patch. Could you please play with vhost branch of my tree on various arches? If it looks ok to you let me know I'll push this to next.

Quoted 8 lines
Quoted 6 lines

With the above part squashed. I've tested all the archs whose defconfig have VHOST_NET or VHOST_VSOCK enabled.

All looks fine.

Thanks

I'm a bit confused. So is the next tag in my tree ok now?

Still need to select CONFIG_VHOST for  CONFIG_VHOST_VDPA. Others are ok.

Thanks

Quoted 1 line
#27 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 88 lines · Jason Wang
Quoted 86 lines · Michael S. Tsirkin
Quoted 85 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
   drivers/vhost/Kconfig | 15 +++++++++++----
   1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +10 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
   	  This option is selected by any driver which needs to access
   	  the host side of a virtio ring.
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
   	select VHOST_IOTLB
   	help
   	  This option is selected by any driver which needs to access
   	  the core of vhost.
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
   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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
   config VHOST_VSOCK
   	tristate "vhost virtio-vsock driver"
   	depends on VSOCKETS && EVENTFD
+	select VHOST
Quoted 8 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 65

Quoted 8 lines
drivers/vhost/Kconfig +1 -0
   	select VIRTIO_VSOCKETS_COMMON
   	default n
   	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
   config VHOST_VDPA
   	tristate "Vhost driver for vDPA-based backend"
   	depends on EVENTFD
+	select VHOST

This part is not squashed.

Quoted 7 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 68

Quoted 3 lines
drivers/vhost/Kconfig +0 -0
   	select VDPA
   	help
   	  This kernel module can be loaded in host kernel to accelerate

OK so I squashed this into the original buggy patch. Could you please play with vhost branch of my tree on various arches? If it looks ok to you let me know I'll push this to next.

With the above part squashed. I've tested all the archs whose defconfig have VHOST_NET or VHOST_VSOCK enabled.

All looks fine.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Thanks

I'm a bit confused. So is the next tag in my tree ok now?

Still need to select CONFIG_VHOST for  CONFIG_VHOST_VDPA. Others are ok.

Thanks

Oh like this then?

drivers/vhost/Kconfig +1 -0
index bdd270fede26..cb6b17323eb2 100644
@@ -61,6 +63,7 @@ config VHOST_VSOCK
 config VHOST_VDPA
 	tristate "Vhost driver for vDPA-based backend"
 	depends on EVENTFD
+	select VHOST
 	select VDPA
 	help
 	  This kernel module can be loaded in host kernel to accelerate
author
#28 lore raw

Re: [PATCH V9 1/9] vhost: refine vhost and vringh kconfig

Quoted 100 lines · Michael S. Tsirkin
Quoted 83 lines · Jason Wang
Quoted 82 lines · Michael S. Tsirkin
Quoted 81 lines · Jason Wang
Quoted 59 lines · Michael S. Tsirkin
Quoted 58 lines · Jason Wang
Quoted 1 line

From 9b3a5d23b8bf6b0a11e65e688335d782f8e6aa5c Mon Sep 17 00:00:00 2001

From: Jason Wang <[email protected]>
Date: Wed, 1 Apr 2020 22:17:27 +0800
Subject: [PATCH] vhost: let CONFIG_VHOST to be selected by drivers

The defconfig on some archs enable vhost_net or vhost_vsock by default. So instead of adding CONFIG_VHOST=m to all of those files, simply letting CONFIG_VHOST to be selected by all of the vhost drivers. This fixes the build on the archs with CONFIG_VHOST_NET=m in their defconfig.

---
    drivers/vhost/Kconfig | 15 +++++++++++----
    1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/Kconfig +10 -4
index 2523a1d4290a..362b832f5338 100644
@@ -11,19 +11,23 @@ config VHOST_RING
    	  This option is selected by any driver which needs to access
    	  the host side of a virtio ring.
-menuconfig VHOST
-	tristate "Host kernel accelerator for virtio (VHOST)"
-	depends on EVENTFD
+config VHOST
+	tristate
    	select VHOST_IOTLB
    	help
    	  This option is selected by any driver which needs to access
    	  the core of vhost.
-if VHOST
+menuconfig VHOST_MENU
+	bool "VHOST drivers"
+	default y
+
+if VHOST_MENU
    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
@@ -35,6 +39,7 @@ 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
@@ -43,6 +48,7 @@ config VHOST_SCSI
    config VHOST_VSOCK
    	tristate "vhost virtio-vsock driver"
    	depends on VSOCKETS && EVENTFD
+	select VHOST
Quoted 8 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 65

Quoted 8 lines
drivers/vhost/Kconfig +1 -0
    	select VIRTIO_VSOCKETS_COMMON
    	default n
    	---help---
@@ -56,6 +62,7 @@ config VHOST_VSOCK
    config VHOST_VDPA
    	tristate "Vhost driver for vDPA-based backend"
    	depends on EVENTFD
+	select VHOST

This part is not squashed.

Quoted 7 lines

drivers/vhost/Kconfig config VHOST_VSOCK · line 69

Quoted 3 lines
drivers/vhost/Kconfig +0 -0
    	select VDPA
    	help
    	  This kernel module can be loaded in host kernel to accelerate

OK so I squashed this into the original buggy patch. Could you please play with vhost branch of my tree on various arches? If it looks ok to you let me know I'll push this to next.

With the above part squashed. I've tested all the archs whose defconfig have VHOST_NET or VHOST_VSOCK enabled.

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

All looks fine.

Thanks

I'm a bit confused. So is the next tag in my tree ok now?

Still need to select CONFIG_VHOST for  CONFIG_VHOST_VDPA. Others are ok.

Thanks

Oh like this then?

drivers/vhost/Kconfig +0 -0
index bdd270fede26..cb6b17323eb2 100644

drivers/vhost/Kconfig config VHOST_VSOCK · line 69

Quoted 7 lines
drivers/vhost/Kconfig +1 -0
@@ -61,6 +63,7 @@ config VHOST_VSOCK
  config VHOST_VDPA
  	tristate "Vhost driver for vDPA-based backend"
  	depends on EVENTFD
+	select VHOST
  	select VDPA
  	help
  	  This kernel module can be loaded in host kernel to accelerate

Yes.

Thanks

Quoted 1 line
author
#29 lore raw

PATCH v9 2/9 vhost: allow per device message handler

In reply to Jason Wang

This patch allow device to register its own message handler during vhost_dev_init(). vDPA device will use it to implement its own DMA mapping logic.

---
 drivers/vhost/net.c   |  3 ++-
 drivers/vhost/scsi.c  |  2 +-
 drivers/vhost/vhost.c | 12 ++++++++++--
 drivers/vhost/vhost.h |  6 +++++-
 drivers/vhost/vsock.c |  2 +-
 5 files changed, 19 insertions(+), 6 deletions(-)
drivers/vhost/net.c +2 -1
index e158159671fa..c8ab8d83b530 100644
@@ -1324,7 +1324,8 @@ static int vhost_net_open(struct inode *inode, struct file *f)
 	}
 	vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX,
 		       UIO_MAXIOV + VHOST_NET_BATCH,
-		       VHOST_NET_PKT_WEIGHT, VHOST_NET_WEIGHT);
+		       VHOST_NET_PKT_WEIGHT, VHOST_NET_WEIGHT,
+		       NULL);
 
 	vhost_poll_init(n->poll + VHOST_NET_VQ_TX, handle_tx_net, EPOLLOUT, dev);
 	vhost_poll_init(n->poll + VHOST_NET_VQ_RX, handle_rx_net, EPOLLIN, dev);
drivers/vhost/scsi.c +1 -1
index 0b949a14bce3..7653667a8cdc 100644
@@ -1628,7 +1628,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
 		vs->vqs[i].vq.handle_kick = vhost_scsi_handle_kick;
 	}
 	vhost_dev_init(&vs->dev, vqs, VHOST_SCSI_MAX_VQ, UIO_MAXIOV,
-		       VHOST_SCSI_WEIGHT, 0);
+		       VHOST_SCSI_WEIGHT, 0, NULL);
 
 	vhost_scsi_init_inflight(vs, NULL);
 
drivers/vhost/vhost.c +10 -2
index f44340b41494..8e9e2341e40a 100644
@@ -457,7 +457,9 @@ static size_t vhost_get_desc_size(struct vhost_virtqueue *vq,
 
 void vhost_dev_init(struct vhost_dev *dev,
 		    struct vhost_virtqueue **vqs, int nvqs,
-		    int iov_limit, int weight, int byte_weight)
+		    int iov_limit, int weight, int byte_weight,
+		    int (*msg_handler)(struct vhost_dev *dev,
+				       struct vhost_iotlb_msg *msg))
 {
 	struct vhost_virtqueue *vq;
 	int i;
@@ -473,6 +475,7 @@ void vhost_dev_init(struct vhost_dev *dev,
 	dev->iov_limit = iov_limit;
 	dev->weight = weight;
 	dev->byte_weight = byte_weight;
+	dev->msg_handler = msg_handler;
 	init_llist_head(&dev->work_list);
 	init_waitqueue_head(&dev->wait);
 	INIT_LIST_HEAD(&dev->read_list);
@@ -1178,7 +1181,12 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
 		ret = -EINVAL;
 		goto done;
 	}
-	if (vhost_process_iotlb_msg(dev, &msg)) {
+
+	if (dev->msg_handler)
+		ret = dev->msg_handler(dev, &msg);
+	else
+		ret = vhost_process_iotlb_msg(dev, &msg);
+	if (ret) {
 		ret = -EFAULT;
 		goto done;
 	}
drivers/vhost/vhost.h +5 -1
index a123fd70847e..f9d1a03dd153 100644
@@ -174,11 +174,15 @@ struct vhost_dev {
 	int weight;
 	int byte_weight;
 	u64 kcov_handle;
+	int (*msg_handler)(struct vhost_dev *dev,
+			   struct vhost_iotlb_msg *msg);
 };
 
 bool vhost_exceeds_weight(struct vhost_virtqueue *vq, int pkts, int total_len);
 void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs,
-		    int nvqs, int iov_limit, int weight, int byte_weight);
+		    int nvqs, int iov_limit, int weight, int byte_weight,
+		    int (*msg_handler)(struct vhost_dev *dev,
+				       struct vhost_iotlb_msg *msg));
 long vhost_dev_set_owner(struct vhost_dev *dev);
 bool vhost_dev_has_owner(struct vhost_dev *dev);
 long vhost_dev_check_owner(struct vhost_dev *);
drivers/vhost/vsock.c +1 -1
index c2d7d57e98cf..97669484a3f6 100644
@@ -621,7 +621,7 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file)
 
 	vhost_dev_init(&vsock->dev, vqs, ARRAY_SIZE(vsock->vqs),
 		       UIO_MAXIOV, VHOST_VSOCK_PKT_WEIGHT,
-		       VHOST_VSOCK_WEIGHT);
+		       VHOST_VSOCK_WEIGHT, NULL);
 
 	file->private_data = vsock;
 	spin_lock_init(&vsock->send_pkt_list_lock);
Signature · 1 line
2.20.1
author
#30 lore raw

PATCH v9 3/9 vhost: factor out IOTLB

In reply to Jason Wang

This patch factors out IOTLB into a dedicated module in order to be reused by other modules like vringh. User may choose to enable the automatic retiring by specifying VHOST_IOTLB_FLAG_RETIRE flag to fit for the case of vhost device IOTLB implementation.

---
 MAINTAINERS                 |   1 +
 drivers/vhost/Kconfig       |   9 ++
 drivers/vhost/Makefile      |   3 +
 drivers/vhost/iotlb.c       | 177 +++++++++++++++++++++++++++++
 drivers/vhost/net.c         |   2 +-
 drivers/vhost/vhost.c       | 221 +++++++++++-------------------------
 drivers/vhost/vhost.h       |  39 ++-----
 include/linux/vhost_iotlb.h |  47 ++++++++
 8 files changed, 318 insertions(+), 181 deletions(-)
 create mode 100644 drivers/vhost/iotlb.c
 create mode 100644 include/linux/vhost_iotlb.h
MAINTAINERS +1 -0
index c74e4ea714a5..0fb645b5a7df 100644
@@ -17768,6 +17768,7 @@ T:	git git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git
 S:	Maintained
 F:	drivers/vhost/
 F:	include/uapi/linux/vhost.h
+F:	include/linux/vhost_iotlb.h
 
 VIRTIO INPUT DRIVER
 M:	Gerd Hoffmann <[email protected]>
drivers/vhost/Kconfig +9 -0
index 4aef10a54cd1..2f6c2105b953 100644
@@ -1,4 +1,9 @@
 # SPDX-License-Identifier: GPL-2.0-only
+config VHOST_IOTLB
+	tristate
+	help
+	  Generic IOTLB implementation for vhost and vringh.
+
 config VHOST_RING
 	tristate
 	help
@@ -7,9 +12,11 @@ config VHOST_RING
 
 menuconfig VHOST
 	tristate "Host kernel accelerator for virtio (VHOST)"
+	select VHOST_IOTLB
 	help
 	  This option is selected by any driver which needs to access
 	  the core of vhost.
+
 if VHOST
 
 config VHOST_NET
@@ -58,4 +65,6 @@ config VHOST_CROSS_ENDIAN_LEGACY
 	  adds some overhead, it is disabled by default.
 
 	  If unsure, say "N".
+
 endif
+
drivers/vhost/Makefile +3 -0
index 6c6df24f770c..fb831002bcf0 100644
@@ -11,3 +11,6 @@ vhost_vsock-y := vsock.o
 obj-$(CONFIG_VHOST_RING) += vringh.o
 
 obj-$(CONFIG_VHOST)	+= vhost.o
+
+obj-$(CONFIG_VHOST_IOTLB) += vhost_iotlb.o
+vhost_iotlb-y := iotlb.o
drivers/vhost/iotlb.c new file +177 -0

177 lines not on this page · raw message

drivers/vhost/net.c +1 -1
index c8ab8d83b530..c7298b192ab4 100644
@@ -1595,7 +1595,7 @@ static long vhost_net_reset_owner(struct vhost_net *n)
 	struct socket *tx_sock = NULL;
 	struct socket *rx_sock = NULL;
 	long err;
-	struct vhost_umem *umem;
+	struct vhost_iotlb *umem;
 
 	mutex_lock(&n->dev.mutex);
 	err = vhost_dev_check_owner(&n->dev);
drivers/vhost/vhost.c +69 -152

432 lines not on this page · raw message

drivers/vhost/vhost.h +11 -28
index f9d1a03dd153..181382185bbc 100644
@@ -12,6 +12,7 @@
 #include <linux/virtio_config.h>
 #include <linux/virtio_ring.h>
 #include <linux/atomic.h>
+#include <linux/vhost_iotlb.h>
 
 struct vhost_work;
 typedef void (*vhost_work_fn_t)(struct vhost_work *work);
@@ -52,27 +53,6 @@ struct vhost_log {
 	u64 len;
 };
 
-#define START(node) ((node)->start)
-#define LAST(node) ((node)->last)
-
-struct vhost_umem_node {
-	struct rb_node rb;
-	struct list_head link;
-	__u64 start;
-	__u64 last;
-	__u64 size;
-	__u64 userspace_addr;
-	__u32 perm;
-	__u32 flags_padding;
-	__u64 __subtree_last;
-};
-
-struct vhost_umem {
-	struct rb_root_cached umem_tree;
-	struct list_head umem_list;
-	int numem;
-};
-
 enum vhost_uaddr_type {
 	VHOST_ADDR_DESC = 0,
 	VHOST_ADDR_AVAIL = 1,
@@ -90,7 +70,7 @@ struct vhost_virtqueue {
 	struct vring_desc __user *desc;
 	struct vring_avail __user *avail;
 	struct vring_used __user *used;
-	const struct vhost_umem_node *meta_iotlb[VHOST_NUM_ADDRS];
+	const struct vhost_iotlb_map *meta_iotlb[VHOST_NUM_ADDRS];
 	struct file *kick;
 	struct eventfd_ctx *call_ctx;
 	struct eventfd_ctx *error_ctx;
@@ -128,8 +108,8 @@ struct vhost_virtqueue {
 	struct iovec *indirect;
 	struct vring_used_elem *heads;
 	/* Protected by virtqueue mutex. */
-	struct vhost_umem *umem;
-	struct vhost_umem *iotlb;
+	struct vhost_iotlb *umem;
+	struct vhost_iotlb *iotlb;
 	void *private_data;
 	u64 acked_features;
 	u64 acked_backend_features;
@@ -164,8 +144,8 @@ struct vhost_dev {
 	struct eventfd_ctx *log_ctx;
 	struct llist_head work_list;
 	struct task_struct *worker;
-	struct vhost_umem *umem;
-	struct vhost_umem *iotlb;
+	struct vhost_iotlb *umem;
+	struct vhost_iotlb *iotlb;
 	spinlock_t iotlb_lock;
 	struct list_head read_list;
 	struct list_head pending_list;
@@ -186,8 +166,8 @@ void vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue **vqs,
 long vhost_dev_set_owner(struct vhost_dev *dev);
 bool vhost_dev_has_owner(struct vhost_dev *dev);
 long vhost_dev_check_owner(struct vhost_dev *);
-struct vhost_umem *vhost_dev_reset_owner_prepare(void);
-void vhost_dev_reset_owner(struct vhost_dev *, struct vhost_umem *);
+struct vhost_iotlb *vhost_dev_reset_owner_prepare(void);
+void vhost_dev_reset_owner(struct vhost_dev *dev, struct vhost_iotlb *iotlb);
 void vhost_dev_cleanup(struct vhost_dev *);
 void vhost_dev_stop(struct vhost_dev *);
 long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, void __user *argp);
@@ -233,6 +213,9 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev,
 			     struct iov_iter *from);
 int vhost_init_device_iotlb(struct vhost_dev *d, bool enabled);
 
+void vhost_iotlb_map_free(struct vhost_iotlb *iotlb,
+			  struct vhost_iotlb_map *map);
+
 #define vq_err(vq, fmt, ...) do {                                  \
 		pr_debug(pr_fmt(fmt), ##__VA_ARGS__);       \
 		if ((vq)->error_ctx)                               \
include/linux/vhost_iotlb.h new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.20.1
author
#31 lore raw

PATCH v9 4/9 vringh: IOTLB support

In reply to Jason Wang

This patch implements the third memory accessor for vringh besides current kernel and userspace accessors. This idea is to allow vringh to do the address translation through an IOTLB which is implemented via vhost_map interval tree. Users should setup and IOVA to PA mapping in this IOTLB.

This allows us to:

- Use vringh to access virtqueues with vIOMMU
- Use vringh to implement software virtqueues for vDPA devices

---
 drivers/vhost/Kconfig  |   1 +
 drivers/vhost/vringh.c | 421 ++++++++++++++++++++++++++++++++++++++---
 include/linux/vringh.h |  36 ++++
 3 files changed, 435 insertions(+), 23 deletions(-)
drivers/vhost/Kconfig +1 -0
index 2f6c2105b953..b03872886901 100644
@@ -6,6 +6,7 @@ config VHOST_IOTLB
 
 config VHOST_RING
 	tristate
+	select VHOST_IOTLB
 	help
 	  This option is selected by any driver which needs to access
 	  the host side of a virtio ring.
drivers/vhost/vringh.c +398 -23

557 lines not on this page · raw message

include/linux/vringh.h +36 -0
index d237087eb257..bd0503ca6f8f 100644
@@ -14,6 +14,8 @@
 #include <linux/virtio_byteorder.h>
 #include <linux/uio.h>
 #include <linux/slab.h>
+#include <linux/dma-direction.h>
+#include <linux/vhost_iotlb.h>
 #include <asm/barrier.h>
 
 /* virtio_ring with information needed for host access. */
@@ -39,6 +41,9 @@ struct vringh {
 	/* The vring (note: it may contain user pointers!) */
 	struct vring vring;
 
+	/* IOTLB for this vring */
+	struct vhost_iotlb *iotlb;
+
 	/* The function to call to notify the guest about added buffers */
 	void (*notify)(struct vringh *);
 };
@@ -248,4 +253,35 @@ static inline __virtio64 cpu_to_vringh64(const struct vringh *vrh, u64 val)
 {
 	return __cpu_to_virtio64(vringh_is_little_endian(vrh), val);
 }
+
+void vringh_set_iotlb(struct vringh *vrh, struct vhost_iotlb *iotlb);
+
+int vringh_init_iotlb(struct vringh *vrh, u64 features,
+		      unsigned int num, bool weak_barriers,
+		      struct vring_desc *desc,
+		      struct vring_avail *avail,
+		      struct vring_used *used);
+
+int vringh_getdesc_iotlb(struct vringh *vrh,
+			 struct vringh_kiov *riov,
+			 struct vringh_kiov *wiov,
+			 u16 *head,
+			 gfp_t gfp);
+
+ssize_t vringh_iov_pull_iotlb(struct vringh *vrh,
+			      struct vringh_kiov *riov,
+			      void *dst, size_t len);
+ssize_t vringh_iov_push_iotlb(struct vringh *vrh,
+			      struct vringh_kiov *wiov,
+			      const void *src, size_t len);
+
+void vringh_abandon_iotlb(struct vringh *vrh, unsigned int num);
+
+int vringh_complete_iotlb(struct vringh *vrh, u16 head, u32 len);
+
+bool vringh_notify_enable_iotlb(struct vringh *vrh);
+void vringh_notify_disable_iotlb(struct vringh *vrh);
+
+int vringh_need_notify_iotlb(struct vringh *vrh);
+
 #endif /* _LINUX_VRINGH_H */
Signature · 1 line
2.20.1
author
#32 lore raw

PATCH v9 5/9 vDPA: introduce vDPA bus

In reply to Jason Wang

vDPA device is a device that uses a datapath which complies with the virtio specifications with vendor specific control path. vDPA devices can be both physically located on the hardware or emulated by software. vDPA hardware devices are usually implemented through PCIE with the following types:

- PF (Physical Function) - A single Physical Function
- VF (Virtual Function) - Device that supports single root I/O virtualization (SR-IOV). Its Virtual Function (VF) represents a virtualized instance of the device that can be assigned to different partitions
- ADI (Assignable Device Interface) and its equivalents - With technologies such as Intel Scalable IOV, a virtual device (VDEV) composed by host OS utilizing one or more ADIs. Or its equivalent like SF (Sub function) from Mellanox.

From a driver's perspective, depends on how and where the DMA translation is done, vDPA devices are split into two types:

- Platform specific DMA translation - From the driver's perspective, the device can be used on a platform where device access to data in memory is limited and/or translated. An example is a PCIE vDPA whose DMA request was tagged via a bus (e.g PCIE) specific way. DMA translation and protection are done at PCIE bus IOMMU level.
- Device specific DMA translation - The device implements DMA isolation and protection through its own logic. An example is a vDPA device which uses on-chip IOMMU.

To hide the differences and complexity of the above types for a vDPA device/IOMMU options and in order to present a generic virtio device to the upper layer, a device agnostic framework is required.

This patch introduces a software vDPA bus which abstracts the common attributes of vDPA device, vDPA bus driver and the communication method (vdpa_config_ops) between the vDPA device abstraction and the vDPA bus driver. This allows multiple types of drivers to be used for vDPA device like the virtio_vdpa and vhost_vdpa driver to operate on the bus and allow vDPA device could be used by either kernel virtio driver or userspace vhost drivers as:

virtio drivers vhost drivers

          |             |
    [virtio bus]   [vhost uAPI]
          |             |
   virtio device   vhost device
   virtio_vdpa drv vhost_vdpa drv
             \       /
            [vDPA bus]
                 |
            vDPA device
            hardware drv
                 |
            [hardware bus]
                 |
            vDPA hardware

With the abstraction of vDPA bus and vDPA bus operations, the difference and complexity of the under layer hardware is hidden from upper layer. The vDPA bus drivers on top can use a unified vdpa_config_ops to control different types of vDPA device.

---
 MAINTAINERS                  |   1 +
 drivers/virtio/Kconfig       |   2 +
 drivers/virtio/Makefile      |   1 +
 drivers/virtio/vdpa/Kconfig  |   7 +
 drivers/virtio/vdpa/Makefile |   2 +
 drivers/virtio/vdpa/vdpa.c   | 180 +++++++++++++++++++++++++
 include/linux/vdpa.h         | 253 +++++++++++++++++++++++++++++++++++
 7 files changed, 446 insertions(+)
 create mode 100644 drivers/virtio/vdpa/Kconfig
 create mode 100644 drivers/virtio/vdpa/Makefile
 create mode 100644 drivers/virtio/vdpa/vdpa.c
 create mode 100644 include/linux/vdpa.h
MAINTAINERS +1 -0
index 0fb645b5a7df..2b8d9fa38d9a 100644
@@ -17701,6 +17701,7 @@ F:	tools/virtio/
 F:	drivers/net/virtio_net.c
 F:	drivers/block/virtio_blk.c
 F:	include/linux/virtio*.h
+F:	include/linux/vdpa.h
 F:	include/uapi/linux/virtio_*.h
 F:	drivers/crypto/virtio/
 F:	mm/balloon_compaction.c
drivers/virtio/Kconfig +2 -0
index 078615cf2afc..9c4fdb64d9ac 100644
@@ -96,3 +96,5 @@ config VIRTIO_MMIO_CMDLINE_DEVICES
 	 If unsure, say 'N'.
 
 endif # VIRTIO_MENU
+
+source "drivers/virtio/vdpa/Kconfig"
drivers/virtio/Makefile +1 -0
index 3a2b5c5dcf46..fdf5eacd0d0a 100644
@@ -6,3 +6,4 @@ virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o
 virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o
+obj-$(CONFIG_VDPA) += vdpa/
drivers/virtio/vdpa/Kconfig new file +7 -0
new file mode 100644
index 000000000000..351617723d12
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: GPL-2.0-only
+config VDPA
+	tristate
+	help
+	  Enable this module to support vDPA device that uses a
+	  datapath which complies with virtio specifications with
+	  vendor specific control path.
drivers/virtio/vdpa/Makefile new file +2 -0
new file mode 100644
index 000000000000..ee6a35e8a4fb
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_VDPA) += vdpa.o
drivers/virtio/vdpa/vdpa.c new file +180 -0

180 lines not on this page · raw message

include/linux/vdpa.h new file +253 -0

253 lines not on this page · raw message

Signature · 1 line
2.20.1
author
#33 lore raw

PATCH v9 6/9 virtio: introduce a vDPA based transport

In reply to Jason Wang

This patch introduces a vDPA transport for virtio. This is used to use kernel virtio driver to drive the vDPA device that is capable of populating virtqueue directly.

A new virtio-vdpa driver will be registered to the vDPA bus, when a new virtio-vdpa device is probed, it will register the device with vdpa based config ops. This means it is a software transport between vDPA driver and vDPA device. The transport was implemented through bus_ops of vDPA parent.

---
 drivers/virtio/Kconfig       |  13 ++
 drivers/virtio/Makefile      |   1 +
 drivers/virtio/virtio_vdpa.c | 396 +++++++++++++++++++++++++++++++++++
 3 files changed, 410 insertions(+)
 create mode 100644 drivers/virtio/virtio_vdpa.c
drivers/virtio/Kconfig +13 -0
index 9c4fdb64d9ac..99e424570644 100644
@@ -43,6 +43,19 @@ config VIRTIO_PCI_LEGACY
 
 	  If unsure, say Y.
 
+config VIRTIO_VDPA
+	tristate "vDPA driver for virtio devices"
+	select VDPA
+	select VIRTIO
+	help
+	  This driver provides support for virtio based paravirtual
+	  device driver over vDPA bus. For this to be useful, you need
+	  an appropriate vDPA device implementation that operates on a
+	  physical device to allow the datapath of virtio to be
+	  offloaded to hardware.
+
+	  If unsure, say M.
+
 config VIRTIO_PMEM
 	tristate "Support for virtio pmem driver"
 	depends on VIRTIO
drivers/virtio/Makefile +1 -0
index fdf5eacd0d0a..3407ac03fe60 100644
@@ -6,4 +6,5 @@ virtio_pci-y := virtio_pci_modern.o virtio_pci_common.o
 virtio_pci-$(CONFIG_VIRTIO_PCI_LEGACY) += virtio_pci_legacy.o
 obj-$(CONFIG_VIRTIO_BALLOON) += virtio_balloon.o
 obj-$(CONFIG_VIRTIO_INPUT) += virtio_input.o
+obj-$(CONFIG_VIRTIO_VDPA) += virtio_vdpa.o
 obj-$(CONFIG_VDPA) += vdpa/
drivers/virtio/virtio_vdpa.c new file +396 -0

396 lines not on this page · raw message

Signature · 1 line
2.20.1
author
#34 lore raw

PATCH v9 7/9 vhost: introduce vDPA-based backend

In reply to Jason Wang

From: Tiwei Bie <[email protected]>

This patch introduces a vDPA-based vhost backend. This backend is built on top of the same interface defined in virtio-vDPA and provides a generic vhost interface for userspace to accelerate the virtio devices in guest.

This backend is implemented as a vDPA device driver on top of the same ops used in virtio-vDPA. It will create char device entry named vhost-vdpa-$index for userspace to use. Userspace can use vhost ioctls on top of this char device to setup the backend.

Vhost ioctls are extended to make it type agnostic and behave like a virtio device, this help to eliminate type specific API like what vhost_net/scsi/vsock did:

- VHOST_VDPA_GET_DEVICE_ID: get the virtio device ID which is defined by virtio specification to differ from different type of devices
- VHOST_VDPA_GET_VRING_NUM: get the maximum size of virtqueue supported by the vDPA device
- VHSOT_VDPA_SET/GET_STATUS: set and get virtio status of vDPA device
- VHOST_VDPA_SET/GET_CONFIG: access virtio config space
- VHOST_VDPA_SET_VRING_ENABLE: enable a specific virtqueue

For memory mapping, IOTLB API is mandated for vhost-vDPA which means userspace drivers are required to use VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE to add or remove mapping for a specific userspace memory region.

The vhost-vDPA API is designed to be type agnostic, but it allows net device only in current stage. Due to the lacking of control virtqueue support, some features were filter out by vhost-vdpa.

We will enable more features and devices in the near future.

---
 drivers/vhost/Kconfig            |  11 +
 drivers/vhost/Makefile           |   3 +
 drivers/vhost/vdpa.c             | 883 +++++++++++++++++++++++++++++++
 include/uapi/linux/vhost.h       |  24 +
 include/uapi/linux/vhost_types.h |   8 +
 5 files changed, 929 insertions(+)
 create mode 100644 drivers/vhost/vdpa.c
drivers/vhost/Kconfig +11 -0
index b03872886901..2a4efe39d79b 100644
@@ -52,6 +52,17 @@ config VHOST_VSOCK
 	To compile this driver as a module, choose M here: the module will be called
 	vhost_vsock.
 
+config VHOST_VDPA
+	tristate "Vhost driver for vDPA-based backend"
+	depends on EVENTFD
+	select VDPA
+	help
+	  This kernel module can be loaded in host kernel to accelerate
+	  guest virtio devices with the vDPA-based backends.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called vhost_vdpa.
+
 config VHOST_CROSS_ENDIAN_LEGACY
 	bool "Cross-endian support for vhost"
 	default n
drivers/vhost/Makefile +3 -0
index fb831002bcf0..f3e1897cce85 100644
@@ -10,6 +10,9 @@ vhost_vsock-y := vsock.o
 
 obj-$(CONFIG_VHOST_RING) += vringh.o
 
+obj-$(CONFIG_VHOST_VDPA) += vhost_vdpa.o
+vhost_vdpa-y := vdpa.o
+
 obj-$(CONFIG_VHOST)	+= vhost.o
 
 obj-$(CONFIG_VHOST_IOTLB) += vhost_iotlb.o
drivers/vhost/vdpa.c new file +883 -0

883 lines not on this page · raw message

include/uapi/linux/vhost.h +24 -0
index 40d028eed645..9fe72e4b1373 100644
@@ -116,4 +116,28 @@
 #define VHOST_VSOCK_SET_GUEST_CID	_IOW(VHOST_VIRTIO, 0x60, __u64)
 #define VHOST_VSOCK_SET_RUNNING		_IOW(VHOST_VIRTIO, 0x61, int)
 
+/* VHOST_VDPA specific defines */
+
+/* Get the device id. The device ids follow the same definition of
+ * the device id defined in virtio-spec.
+ */
+#define VHOST_VDPA_GET_DEVICE_ID	_IOR(VHOST_VIRTIO, 0x70, __u32)
+/* Get and set the status. The status bits follow the same definition
+ * of the device status defined in virtio-spec.
+ */
+#define VHOST_VDPA_GET_STATUS		_IOR(VHOST_VIRTIO, 0x71, __u8)
+#define VHOST_VDPA_SET_STATUS		_IOW(VHOST_VIRTIO, 0x72, __u8)
+/* Get and set the device config. The device config follows the same
+ * definition of the device config defined in virtio-spec.
+ */
+#define VHOST_VDPA_GET_CONFIG		_IOR(VHOST_VIRTIO, 0x73, \
+					     struct vhost_vdpa_config)
+#define VHOST_VDPA_SET_CONFIG		_IOW(VHOST_VIRTIO, 0x74, \
+					     struct vhost_vdpa_config)
+/* Enable/disable the ring. */
+#define VHOST_VDPA_SET_VRING_ENABLE	_IOW(VHOST_VIRTIO, 0x75, \
+					     struct vhost_vring_state)
+/* Get the max ring size. */
+#define VHOST_VDPA_GET_VRING_NUM	_IOR(VHOST_VIRTIO, 0x76, __u16)
+
 #endif
include/uapi/linux/vhost_types.h +8 -0
index c907290ff065..669457ce5c48 100644
@@ -119,6 +119,14 @@ struct vhost_scsi_target {
 	unsigned short reserved;
 };
 
+/* VHOST_VDPA specific definitions */
+
+struct vhost_vdpa_config {
+	__u32 off;
+	__u32 len;
+	__u8 buf[0];
+};
+
 /* Feature bits */
 /* Log all write descriptors. Can be changed while device is active. */
 #define VHOST_F_LOG_ALL 26
Signature · 1 line
2.20.1
#35 lore raw

Re: [PATCH V9 7/9] vhost: introduce vDPA-based backend

Quoted 34 lines · Jason Wang

From: Tiwei Bie <[email protected]>

This patch introduces a vDPA-based vhost backend. This backend is built on top of the same interface defined in virtio-vDPA and provides a generic vhost interface for userspace to accelerate the virtio devices in guest.

This backend is implemented as a vDPA device driver on top of the same ops used in virtio-vDPA. It will create char device entry named vhost-vdpa-$index for userspace to use. Userspace can use vhost ioctls on top of this char device to setup the backend.

Vhost ioctls are extended to make it type agnostic and behave like a virtio device, this help to eliminate type specific API like what vhost_net/scsi/vsock did:

- VHOST_VDPA_GET_DEVICE_ID: get the virtio device ID which is defined by virtio specification to differ from different type of devices
- VHOST_VDPA_GET_VRING_NUM: get the maximum size of virtqueue supported by the vDPA device
- VHSOT_VDPA_SET/GET_STATUS: set and get virtio status of vDPA device
- VHOST_VDPA_SET/GET_CONFIG: access virtio config space
- VHOST_VDPA_SET_VRING_ENABLE: enable a specific virtqueue

For memory mapping, IOTLB API is mandated for vhost-vDPA which means userspace drivers are required to use VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE to add or remove mapping for a specific userspace memory region.

The vhost-vDPA API is designed to be type agnostic, but it allows net device only in current stage. Due to the lacking of control virtqueue support, some features were filter out by vhost-vdpa.

We will enable more features and devices in the near future.

[..]

Quoted 17 lines
drivers/vhost/vdpa.c new file +16 -0
+static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
+{
+	struct vdpa_device *vdpa = v->vdpa;
+	const struct vdpa_config_ops *ops = vdpa->config;
+	struct device *dma_dev = vdpa_get_dma_dev(vdpa);
+	struct bus_type *bus;
+	int ret;
+
+	/* Device want to do DMA by itself */
+	if (ops->set_map || ops->dma_map)
+		return 0;
+
+	bus = dma_dev->bus;
+	if (!bus)
+		return -EFAULT;
+

drivers/vhost/vdpa.c line 651

Quoted 10 lines
drivers/vhost/vdpa.c new file +10 -0
+	if (!iommu_capable(bus, IOMMU_CAP_CACHE_COHERENCY))
+		return -ENOTSUPP;
+
+	v->domain = iommu_domain_alloc(bus);
+	if (!v->domain)
+		return -EIO;
+
+	ret = iommu_attach_device(v->domain, dma_dev);
+	if (ret)
+		goto err_attach;

I've been looking at the security of iommu_attach_device() users, and I wonder if this is safe?

The security question is if userspace is able to control the DMA address the devices uses? Eg if any of the cpu to device ring's are in userspace memory?

For instance if userspace can tell the device to send a packet from an arbitrary user controlled address.

Thanks,
Jason

author
#36 lore raw

Re: [PATCH V9 7/9] vhost: introduce vDPA-based backend

Quoted 70 lines · Jason Gunthorpe
Quoted 34 lines · Jason Wang

From: Tiwei Bie <[email protected]>

This patch introduces a vDPA-based vhost backend. This backend is built on top of the same interface defined in virtio-vDPA and provides a generic vhost interface for userspace to accelerate the virtio devices in guest.

This backend is implemented as a vDPA device driver on top of the same ops used in virtio-vDPA. It will create char device entry named vhost-vdpa-$index for userspace to use. Userspace can use vhost ioctls on top of this char device to setup the backend.

Vhost ioctls are extended to make it type agnostic and behave like a virtio device, this help to eliminate type specific API like what vhost_net/scsi/vsock did:

- VHOST_VDPA_GET_DEVICE_ID: get the virtio device ID which is defined by virtio specification to differ from different type of devices
- VHOST_VDPA_GET_VRING_NUM: get the maximum size of virtqueue supported by the vDPA device
- VHSOT_VDPA_SET/GET_STATUS: set and get virtio status of vDPA device
- VHOST_VDPA_SET/GET_CONFIG: access virtio config space
- VHOST_VDPA_SET_VRING_ENABLE: enable a specific virtqueue

For memory mapping, IOTLB API is mandated for vhost-vDPA which means userspace drivers are required to use VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE to add or remove mapping for a specific userspace memory region.

The vhost-vDPA API is designed to be type agnostic, but it allows net device only in current stage. Due to the lacking of control virtqueue support, some features were filter out by vhost-vdpa.

We will enable more features and devices in the near future.

[..]

Quoted 17 lines
drivers/vhost/vdpa.c new file +16 -0
+static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
+{
+     struct vdpa_device *vdpa = v->vdpa;
+     const struct vdpa_config_ops *ops = vdpa->config;
+     struct device *dma_dev = vdpa_get_dma_dev(vdpa);
+     struct bus_type *bus;
+     int ret;
+
+     /* Device want to do DMA by itself */
+     if (ops->set_map || ops->dma_map)
+             return 0;
+
+     bus = dma_dev->bus;
+     if (!bus)
+             return -EFAULT;
+

drivers/vhost/vdpa.c line 651

Quoted 10 lines
drivers/vhost/vdpa.c new file +10 -0
+     if (!iommu_capable(bus, IOMMU_CAP_CACHE_COHERENCY))
+             return -ENOTSUPP;
+
+     v->domain = iommu_domain_alloc(bus);
+     if (!v->domain)
+             return -EIO;
+
+     ret = iommu_attach_device(v->domain, dma_dev);
+     if (ret)
+             goto err_attach;

I've been looking at the security of iommu_attach_device() users, and I wonder if this is safe?

Quoted 6 lines

The security question is if userspace is able to control the DMA address the devices uses? Eg if any of the cpu to device ring's are in userspace memory?

For instance if userspace can tell the device to send a packet from an arbitrary user controlled address.

The map is validated via pin_user_pages() which guarantees that the address is not arbitrary and must belong to userspace?

Thanks

Quoted 4 lines

Thanks,
Jason

#37 lore raw

Re: [PATCH V9 7/9] vhost: introduce vDPA-based backend

Quoted 75 lines · Jason Wang
Quoted 74 lines · Jason Gunthorpe
Quoted 34 lines · Jason Wang

From: Tiwei Bie <[email protected]>

This patch introduces a vDPA-based vhost backend. This backend is built on top of the same interface defined in virtio-vDPA and provides a generic vhost interface for userspace to accelerate the virtio devices in guest.

This backend is implemented as a vDPA device driver on top of the same ops used in virtio-vDPA. It will create char device entry named vhost-vdpa-$index for userspace to use. Userspace can use vhost ioctls on top of this char device to setup the backend.

Vhost ioctls are extended to make it type agnostic and behave like a virtio device, this help to eliminate type specific API like what vhost_net/scsi/vsock did:

- VHOST_VDPA_GET_DEVICE_ID: get the virtio device ID which is defined by virtio specification to differ from different type of devices
- VHOST_VDPA_GET_VRING_NUM: get the maximum size of virtqueue supported by the vDPA device
- VHSOT_VDPA_SET/GET_STATUS: set and get virtio status of vDPA device
- VHOST_VDPA_SET/GET_CONFIG: access virtio config space
- VHOST_VDPA_SET_VRING_ENABLE: enable a specific virtqueue

For memory mapping, IOTLB API is mandated for vhost-vDPA which means userspace drivers are required to use VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE to add or remove mapping for a specific userspace memory region.

The vhost-vDPA API is designed to be type agnostic, but it allows net device only in current stage. Due to the lacking of control virtqueue support, some features were filter out by vhost-vdpa.

We will enable more features and devices in the near future.

[..]

Quoted 17 lines
drivers/vhost/vdpa.c new file +16 -0
+static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
+{
+     struct vdpa_device *vdpa = v->vdpa;
+     const struct vdpa_config_ops *ops = vdpa->config;
+     struct device *dma_dev = vdpa_get_dma_dev(vdpa);
+     struct bus_type *bus;
+     int ret;
+
+     /* Device want to do DMA by itself */
+     if (ops->set_map || ops->dma_map)
+             return 0;
+
+     bus = dma_dev->bus;
+     if (!bus)
+             return -EFAULT;
+

drivers/vhost/vdpa.c line 651

Quoted 10 lines
drivers/vhost/vdpa.c new file +10 -0
+     if (!iommu_capable(bus, IOMMU_CAP_CACHE_COHERENCY))
+             return -ENOTSUPP;
+
+     v->domain = iommu_domain_alloc(bus);
+     if (!v->domain)
+             return -EIO;
+
+     ret = iommu_attach_device(v->domain, dma_dev);
+     if (ret)
+             goto err_attach;

I've been looking at the security of iommu_attach_device() users, and I wonder if this is safe?

The security question is if userspace is able to control the DMA address the devices uses? Eg if any of the cpu to device ring's are in userspace memory?

Quoted 5 lines
Quoted 2 lines

For instance if userspace can tell the device to send a packet from an arbitrary user controlled address.

The map is validated via pin_user_pages() which guarantees that the address is not arbitrary and must belong to userspace?

That controls what gets put into the IOMMU, it doesn't restrict what DMA the device itself can issue.

Upon investigating more it seems the answer is that iommu_attach_device() requires devices to be in singleton groups, so there is no leakage from rouge DMA

Jason

author
#38 lore raw

Re: [PATCH V9 7/9] vhost: introduce vDPA-based backend

Quoted 83 lines · Jason Gunthorpe
Quoted 75 lines · Jason Wang
Quoted 74 lines · Jason Gunthorpe
Quoted 34 lines · Jason Wang

From: Tiwei Bie <[email protected]>

This patch introduces a vDPA-based vhost backend. This backend is built on top of the same interface defined in virtio-vDPA and provides a generic vhost interface for userspace to accelerate the virtio devices in guest.

This backend is implemented as a vDPA device driver on top of the same ops used in virtio-vDPA. It will create char device entry named vhost-vdpa-$index for userspace to use. Userspace can use vhost ioctls on top of this char device to setup the backend.

Vhost ioctls are extended to make it type agnostic and behave like a virtio device, this help to eliminate type specific API like what vhost_net/scsi/vsock did:

- VHOST_VDPA_GET_DEVICE_ID: get the virtio device ID which is defined by virtio specification to differ from different type of devices
- VHOST_VDPA_GET_VRING_NUM: get the maximum size of virtqueue supported by the vDPA device
- VHSOT_VDPA_SET/GET_STATUS: set and get virtio status of vDPA device
- VHOST_VDPA_SET/GET_CONFIG: access virtio config space
- VHOST_VDPA_SET_VRING_ENABLE: enable a specific virtqueue

For memory mapping, IOTLB API is mandated for vhost-vDPA which means userspace drivers are required to use VHOST_IOTLB_UPDATE/VHOST_IOTLB_INVALIDATE to add or remove mapping for a specific userspace memory region.

The vhost-vDPA API is designed to be type agnostic, but it allows net device only in current stage. Due to the lacking of control virtqueue support, some features were filter out by vhost-vdpa.

We will enable more features and devices in the near future.

[..]

Quoted 17 lines
drivers/vhost/vdpa.c new file +16 -0
+static int vhost_vdpa_alloc_domain(struct vhost_vdpa *v)
+{
+     struct vdpa_device *vdpa = v->vdpa;
+     const struct vdpa_config_ops *ops = vdpa->config;
+     struct device *dma_dev = vdpa_get_dma_dev(vdpa);
+     struct bus_type *bus;
+     int ret;
+
+     /* Device want to do DMA by itself */
+     if (ops->set_map || ops->dma_map)
+             return 0;
+
+     bus = dma_dev->bus;
+     if (!bus)
+             return -EFAULT;
+

drivers/vhost/vdpa.c line 651

Quoted 10 lines
drivers/vhost/vdpa.c new file +10 -0
+     if (!iommu_capable(bus, IOMMU_CAP_CACHE_COHERENCY))
+             return -ENOTSUPP;
+
+     v->domain = iommu_domain_alloc(bus);
+     if (!v->domain)
+             return -EIO;
+
+     ret = iommu_attach_device(v->domain, dma_dev);
+     if (ret)
+             goto err_attach;

I've been looking at the security of iommu_attach_device() users, and I wonder if this is safe?

The security question is if userspace is able to control the DMA address the devices uses? Eg if any of the cpu to device ring's are in userspace memory?

Quoted 5 lines
Quoted 2 lines

For instance if userspace can tell the device to send a packet from an arbitrary user controlled address.

The map is validated via pin_user_pages() which guarantees that the address is not arbitrary and must belong to userspace?

Quoted 6 lines

That controls what gets put into the IOMMU, it doesn't restrict what DMA the device itself can issue.

Upon investigating more it seems the answer is that iommu_attach_device() requires devices to be in singleton groups, so there is no leakage from rouge DMA

Yes, I think so.

Thanks

Quoted 3 lines

Jason

author
#39 lore raw

PATCH v9 8/9 vdpasim: vDPA device simulator

In reply to Jason Wang

This patch implements a software vDPA networking device. The datapath is implemented through vringh and workqueue. The device has an on-chip IOMMU which translates IOVA to PA. For kernel virtio drivers, vDPA simulator driver provides dma_ops. For vhost driers, set_map() methods of vdpa_config_ops is implemented to accept mappings from vhost.

Currently, vDPA device simulator will loopback TX traffic to RX. So the main use case for the device is vDPA feature testing, prototyping and development.

Note, there's no management API implemented, a vDPA device will be registered once the module is probed. We need to handle this in the future development.

---
 drivers/virtio/vdpa/Kconfig             |  19 +
 drivers/virtio/vdpa/Makefile            |   1 +
 drivers/virtio/vdpa/vdpa_sim/Makefile   |   2 +
 drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c | 629 ++++++++++++++++++++++++
 4 files changed, 651 insertions(+)
 create mode 100644 drivers/virtio/vdpa/vdpa_sim/Makefile
 create mode 100644 drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c
drivers/virtio/vdpa/Kconfig +19 -0
index 351617723d12..ae204465964e 100644
@@ -5,3 +5,22 @@ config VDPA
 	  Enable this module to support vDPA device that uses a
 	  datapath which complies with virtio specifications with
 	  vendor specific control path.
+
+menuconfig VDPA_MENU
+	bool "VDPA drivers"
+	default n
+
+if VDPA_MENU
+
+config VDPA_SIM
+	tristate "vDPA device simulator"
+	depends on RUNTIME_TESTING_MENU
+	select VDPA
+	select VHOST_RING
+	default n
+	help
+	  vDPA networking device simulator which loop TX traffic back
+	  to RX. This device is used for testing, prototyping and
+	  development of vDPA.
+
+endif # VDPA_MENU
drivers/virtio/vdpa/Makefile +1 -0
index ee6a35e8a4fb..3814af8e097b 100644
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VDPA) += vdpa.o
+obj-$(CONFIG_VDPA_SIM) += vdpa_sim/
drivers/virtio/vdpa/vdpa_sim/Makefile new file +2 -0
new file mode 100644
index 000000000000..b40278f65e04
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_VDPA_SIM) += vdpa_sim.o
drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c new file +629 -0

629 lines not on this page · raw message

Signature · 1 line
2.20.1
#40 lore raw

Re: [PATCH V9 8/9] vdpasim: vDPA device simulator

Hi Jason,

Quoted 10 lines · Jason Wang

This patch implements a software vDPA networking device. The datapath is implemented through vringh and workqueue. The device has an on-chip IOMMU which translates IOVA to PA. For kernel virtio drivers, vDPA simulator driver provides dma_ops. For vhost driers, set_map() methods of vdpa_config_ops is implemented to accept mappings from vhost.

Currently, vDPA device simulator will loopback TX traffic to RX. So the main use case for the device is vDPA feature testing, prototyping and development.

Quoted 5 lines

Note, there's no management API implemented, a vDPA device will be registered once the module is probed. We need to handle this in the future development.

This is now commit 2c53d0f64c06f458 ("vdpasim: vDPA device simulator").

drivers/virtio/vdpa/Kconfig config VDPA · line 11

Quoted 10 lines
drivers/virtio/vdpa/Kconfig +4 -0
@@ -5,3 +5,22 @@ config VDPA
          Enable this module to support vDPA device that uses a
          datapath which complies with virtio specifications with
          vendor specific control path.
+
+menuconfig VDPA_MENU
+       bool "VDPA drivers"
+       default n

*
* VDPA drivers
*
VDPA drivers (VDPA_MENU) [N/y/?] (NEW) ?

There is no help available for this option.
Symbol: VDPA_MENU [=n]
Type : bool
Defined at drivers/vdpa/Kconfig:9
Prompt: VDPA drivers
Location:
-> Device Drivers

I think this deserves a help text, so users know if they want to enable this option or not.

I had a quick look, but couldn't find the meaning of "vdpa" in the whole kernel source tree.

Thanks!

Quoted 5 lines
drivers/virtio/vdpa/Kconfig +5 -0
+
+if VDPA_MENU
+
+config VDPA_SIM
+       tristate "vDPA device simulator"

drivers/virtio/vdpa/Kconfig config VDPA · line 26

Quoted 10 lines
drivers/virtio/vdpa/Kconfig +10 -0
+       depends on RUNTIME_TESTING_MENU
+       select VDPA
+       select VHOST_RING
+       default n
+       help
+         vDPA networking device simulator which loop TX traffic back
+         to RX. This device is used for testing, prototyping and
+         development of vDPA.
+
+endif # VDPA_MENU

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
author
#41 lore raw

Re: [PATCH V9 8/9] vdpasim: vDPA device simulator

Quoted 43 lines · Geert Uytterhoeven

Hi Jason,

Quoted 10 lines · Jason Wang

This patch implements a software vDPA networking device. The datapath is implemented through vringh and workqueue. The device has an on-chip IOMMU which translates IOVA to PA. For kernel virtio drivers, vDPA simulator driver provides dma_ops. For vhost driers, set_map() methods of vdpa_config_ops is implemented to accept mappings from vhost.

Currently, vDPA device simulator will loopback TX traffic to RX. So the main use case for the device is vDPA feature testing, prototyping and development.

Quoted 5 lines

Note, there's no management API implemented, a vDPA device will be registered once the module is probed. We need to handle this in the future development.

This is now commit 2c53d0f64c06f458 ("vdpasim: vDPA device simulator").

drivers/virtio/vdpa/Kconfig config VDPA · line 11

Quoted 10 lines
drivers/virtio/vdpa/Kconfig +4 -0
@@ -5,3 +5,22 @@ config VDPA
           Enable this module to support vDPA device that uses a
           datapath which complies with virtio specifications with
           vendor specific control path.
+
+menuconfig VDPA_MENU
+       bool "VDPA drivers"
+       default n

*
* VDPA drivers
*
VDPA drivers (VDPA_MENU) [N/y/?] (NEW) ?

There is no help available for this option.
Symbol: VDPA_MENU [=n]
Type : bool
Defined at drivers/vdpa/Kconfig:9
Prompt: VDPA drivers
Location:
-> Device Drivers

Quoted 2 lines

I think this deserves a help text, so users know if they want to enable this option or not.

Will add a help text for this.

Quoted 3 lines

I had a quick look, but couldn't find the meaning of "vdpa" in the whole kernel source tree.

The meaning was explained in the commit log of 961e9c84077f6c8579d7a628cbe94a675cb67ae4 and help text for CONFIG_VDPA.

Thanks

Quoted 22 lines

Thanks!

Quoted 5 lines
drivers/virtio/vdpa/Kconfig +5 -0
+
+if VDPA_MENU
+
+config VDPA_SIM
+       tristate "vDPA device simulator"

drivers/virtio/vdpa/Kconfig config VDPA · line 26

Quoted 10 lines
drivers/virtio/vdpa/Kconfig +10 -0
+       depends on RUNTIME_TESTING_MENU
+       select VDPA
+       select VHOST_RING
+       default n
+       help
+         vDPA networking device simulator which loop TX traffic back
+         to RX. This device is used for testing, prototyping and
+         development of vDPA.
+
+endif # VDPA_MENU

Gr{oetje,eeting}s,

Geert

author
#42 lore raw

PATCH v9 9/9 virtio: Intel IFC VF driver for VDPA

In reply to Jason Wang

From: Zhu Lingshan <[email protected]>

This commit introduced two layers to drive IFC VF:

(1) ifcvf_base layer, which handles IFC VF NIC hardware operations and configurations.

(2) ifcvf_main layer, which complies to VDPA bus framework, implemented device operations for VDPA bus, handles device probe, bus attaching, vring operations, etc.

---
 drivers/virtio/vdpa/Kconfig            |  11 +
 drivers/virtio/vdpa/Makefile           |   1 +
 drivers/virtio/vdpa/ifcvf/Makefile     |   3 +
 drivers/virtio/vdpa/ifcvf/ifcvf_base.c | 389 ++++++++++++++++++++++
 drivers/virtio/vdpa/ifcvf/ifcvf_base.h | 118 +++++++
 drivers/virtio/vdpa/ifcvf/ifcvf_main.c | 435 +++++++++++++++++++++++++
 6 files changed, 957 insertions(+)
 create mode 100644 drivers/virtio/vdpa/ifcvf/Makefile
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_base.c
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_base.h
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_main.c
drivers/virtio/vdpa/Kconfig +11 -0
index ae204465964e..7db1460104b7 100644
@@ -23,4 +23,15 @@ config VDPA_SIM
 	  to RX. This device is used for testing, prototyping and
 	  development of vDPA.
 
+config IFCVF
+	tristate "Intel IFC VF VDPA driver"
+	depends on PCI_MSI
+	select VDPA
+	default n
+	help
+	  This kernel module can drive Intel IFC VF NIC to offload
+	  virtio dataplane traffic to hardware.
+	  To compile this driver as a module, choose M here: the module will
+	  be called ifcvf.
+
 endif # VDPA_MENU
drivers/virtio/vdpa/Makefile +1 -0
index 3814af8e097b..8bbb686ca7a2 100644
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 obj-$(CONFIG_VDPA) += vdpa.o
 obj-$(CONFIG_VDPA_SIM) += vdpa_sim/
+obj-$(CONFIG_IFCVF)    += ifcvf/
drivers/virtio/vdpa/ifcvf/Makefile new file +3 -0
new file mode 100644
index 000000000000..d709915995ab
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_IFCVF) += ifcvf.o
+ifcvf-$(CONFIG_IFCVF) += ifcvf_main.o ifcvf_base.o
drivers/virtio/vdpa/ifcvf/ifcvf_base.c new file +389 -0

389 lines not on this page · raw message

drivers/virtio/vdpa/ifcvf/ifcvf_base.h new file +118 -0

118 lines not on this page · raw message

drivers/virtio/vdpa/ifcvf/ifcvf_main.c new file +435 -0

435 lines not on this page · raw message

Signature · 1 line
2.20.1
maintainer
#43 lore raw

Re: [PATCH V9 9/9] virtio: Intel IFC VF driver for VDPA

Quoted 17 lines · Jason Wang

From: Zhu Lingshan <[email protected]>

This commit introduced two layers to drive IFC VF:

(1) ifcvf_base layer, which handles IFC VF NIC hardware operations and configurations.

(2) ifcvf_main layer, which complies to VDPA bus framework, implemented device operations for VDPA bus, handles device probe, bus attaching, vring operations, etc.

drivers/virtio/vdpa/ifcvf/ifcvf_main.c line 234

Quoted 7 lines
drivers/virtio/vdpa/ifcvf/ifcvf_main.c new file +7 -0
+
+#define IFCVF_QUEUE_ALIGNMENT  PAGE_SIZE
+#define IFCVF_QUEUE_MAX                32768
+static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
+{
+       return IFCVF_QUEUE_ALIGNMENT;
+}

This fails to build on arm64 with 64kb page size (found in linux-next):

/drivers/vdpa/ifcvf/ifcvf_main.c: In function 'ifcvf_vdpa_get_vq_align':
arch/arm64/include/asm/page-def.h:17:20: error: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Werror=overflow]

   17 | #define PAGE_SIZE  (_AC(1, UL) << PAGE_SHIFT)
      |                    ^

drivers/vdpa/ifcvf/ifcvf_base.h:37:31: note: in expansion of macro 'PAGE_SIZE'
37 | #define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
| ^~~~~~~~~
drivers/vdpa/ifcvf/ifcvf_main.c:231:9: note: in expansion of macro 'IFCVF_QUEUE_ALIGNMENT'

  231 |  return IFCVF_QUEUE_ALIGNMENT;
      |         ^~~~~~~~~~~~~~~~~~~~~

It's probably good enough to just not allow the driver to be built in that configuration as it's fairly rare but unfortunately there is no simple Kconfig symbol for it.

In a similar driver, we did

config VMXNET3

        tristate "VMware VMXNET3 ethernet driver"
        depends on PCI && INET
        depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \
                     IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \
                     PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES)

I think we should probably make PAGE_SIZE_64KB a global symbol in arch/Kconfig and have it selected by the other symbols so drivers like yours can add a dependency for it.

Arnd

author
#44 lore raw

Re: [PATCH V9 9/9] virtio: Intel IFC VF driver for VDPA

Quoted 36 lines · Arnd Bergmann
Quoted 15 lines · Jason Wang

From: Zhu Lingshan <[email protected]>

This commit introduced two layers to drive IFC VF:

(1) ifcvf_base layer, which handles IFC VF NIC hardware operations and configurations.

(2) ifcvf_main layer, which complies to VDPA bus framework, implemented device operations for VDPA bus, handles device probe, bus attaching, vring operations, etc.

drivers/virtio/vdpa/ifcvf/ifcvf_main.c line 234

Quoted 7 lines
drivers/virtio/vdpa/ifcvf/ifcvf_main.c new file +7 -0
+
+#define IFCVF_QUEUE_ALIGNMENT  PAGE_SIZE
+#define IFCVF_QUEUE_MAX                32768
+static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
+{
+       return IFCVF_QUEUE_ALIGNMENT;
+}

This fails to build on arm64 with 64kb page size (found in linux-next):

/drivers/vdpa/ifcvf/ifcvf_main.c: In function 'ifcvf_vdpa_get_vq_align':
arch/arm64/include/asm/page-def.h:17:20: error: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Werror=overflow]

    17 | #define PAGE_SIZE  (_AC(1, UL) << PAGE_SHIFT)
       |                    ^

drivers/vdpa/ifcvf/ifcvf_base.h:37:31: note: in expansion of macro 'PAGE_SIZE'
37 | #define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
| ^~~~~~~~~
drivers/vdpa/ifcvf/ifcvf_main.c:231:9: note: in expansion of macro 'IFCVF_QUEUE_ALIGNMENT'

Quoted 6 lines
   231 |  return IFCVF_QUEUE_ALIGNMENT;
       |         ^~~~~~~~~~~~~~~~~~~~~

It's probably good enough to just not allow the driver to be built in that configuration as it's fairly rare but unfortunately there is no simple Kconfig symbol for it.

Or I think the 64KB alignment is probably more than enough.

Ling Shan, can we use smaller value here?

Thanks

Quoted 16 lines

In a similar driver, we did

config VMXNET3

         tristate "VMware VMXNET3 ethernet driver"
         depends on PCI && INET
         depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \
                      IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \
                      PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES)

I think we should probably make PAGE_SIZE_64KB a global symbol in arch/Kconfig and have it selected by the other symbols so drivers like yours can add a dependency for it.

Arnd

#45 lore raw

Re: [PATCH V9 9/9] virtio: Intel IFC VF driver for VDPA

Quoted 46 lines · Jason Wang
Quoted 39 lines · Arnd Bergmann
Quoted 15 lines · Jason Wang

From: Zhu Lingshan <[email protected]>

This commit introduced two layers to drive IFC VF:

(1) ifcvf_base layer, which handles IFC VF NIC hardware operations and configurations.

(2) ifcvf_main layer, which complies to VDPA bus framework, implemented device operations for VDPA bus, handles device probe, bus attaching, vring operations, etc.

drivers/virtio/vdpa/ifcvf/ifcvf_main.c line 234

Quoted 7 lines
drivers/virtio/vdpa/ifcvf/ifcvf_main.c new file +7 -0
+
+#define IFCVF_QUEUE_ALIGNMENT  PAGE_SIZE
+#define IFCVF_QUEUE_MAX                32768
+static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
+{
+       return IFCVF_QUEUE_ALIGNMENT;
+}

This fails to build on arm64 with 64kb page size (found in linux-next):

/drivers/vdpa/ifcvf/ifcvf_main.c: In function 'ifcvf_vdpa_get_vq_align':
arch/arm64/include/asm/page-def.h:17:20: error: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Werror=overflow]
    17 | #define PAGE_SIZE  (_AC(1, UL) << PAGE_SHIFT)
       |                    ^ drivers/vdpa/ifcvf/ifcvf_base.h:37:31: note: in expansion of macro 'PAGE_SIZE' 37 | #define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
       |                               ^~~~~~~~~ drivers/vdpa/ifcvf/ifcvf_main.c:231:9: note: in expansion of macro 'IFCVF_QUEUE_ALIGNMENT'
   231 |  return IFCVF_QUEUE_ALIGNMENT;
       |         ^~~~~~~~~~~~~~~~~~~~~

Quoted 3 lines

It's probably good enough to just not allow the driver to be built in that configuration as it's fairly rare but unfortunately there is no simple Kconfig symbol for it.

Quoted 5 lines

Or I think the 64KB alignment is probably more than enough.

Ling Shan, can we use smaller value here?

Thanks

sure, we just need it page aligned, this value is only used in get_vq_align(). I will try to find a arm64 machine and debug on this issue

Thanks!

Quoted 19 lines
Quoted 18 lines

In a similar driver, we did

config VMXNET3
         tristate "VMware VMXNET3 ethernet driver"
         depends on PCI && INET
         depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \
                      IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \
                      PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES)

I think we should probably make PAGE_SIZE_64KB a global symbol in arch/Kconfig and have it selected by the other symbols so drivers like yours can add a dependency for it.

          Arnd

#46 lore raw

Re: [PATCH V9 9/9] virtio: Intel IFC VF driver for VDPA

In reply to Arnd Bergmann
Quoted 55 lines · Arnd Bergmann
Quoted 17 lines · Jason Wang

From: Zhu Lingshan <[email protected]>

This commit introduced two layers to drive IFC VF:

(1) ifcvf_base layer, which handles IFC VF NIC hardware operations and configurations.

(2) ifcvf_main layer, which complies to VDPA bus framework, implemented device operations for VDPA bus, handles device probe, bus attaching, vring operations, etc.

drivers/virtio/vdpa/ifcvf/ifcvf_main.c line 234

Quoted 7 lines
drivers/virtio/vdpa/ifcvf/ifcvf_main.c new file +7 -0
+
+#define IFCVF_QUEUE_ALIGNMENT  PAGE_SIZE
+#define IFCVF_QUEUE_MAX                32768
+static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
+{
+       return IFCVF_QUEUE_ALIGNMENT;
+}

This fails to build on arm64 with 64kb page size (found in linux-next):

/drivers/vdpa/ifcvf/ifcvf_main.c: In function 'ifcvf_vdpa_get_vq_align':
arch/arm64/include/asm/page-def.h:17:20: error: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Werror=overflow]

   17 | #define PAGE_SIZE  (_AC(1, UL) << PAGE_SHIFT)
      |                    ^

drivers/vdpa/ifcvf/ifcvf_base.h:37:31: note: in expansion of macro 'PAGE_SIZE'
37 | #define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
| ^~~~~~~~~
drivers/vdpa/ifcvf/ifcvf_main.c:231:9: note: in expansion of macro 'IFCVF_QUEUE_ALIGNMENT'

  231 |  return IFCVF_QUEUE_ALIGNMENT;
      |         ^~~~~~~~~~~~~~~~~~~~~

It's probably good enough to just not allow the driver to be built in that configuration as it's fairly rare but unfortunately there is no simple Kconfig symbol for it.

In a similar driver, we did

config VMXNET3

        tristate "VMware VMXNET3 ethernet driver"
        depends on PCI && INET
        depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \
                     IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \
                     PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES)
Quoted 5 lines

I think we should probably make PAGE_SIZE_64KB a global symbol in arch/Kconfig and have it selected by the other symbols so drivers like yours can add a dependency for it.

Arnd

It's probably easier to make the alignment u32 - I don't really know why it's u16, all callers seem to assign the result to a u32 value.

#47 lore raw

Re: [PATCH V9 9/9] virtio: Intel IFC VF driver for VDPA

Quoted 53 lines · Michael S. Tsirkin
Quoted 52 lines · Arnd Bergmann
Quoted 15 lines · Jason Wang

From: Zhu Lingshan <[email protected]>

This commit introduced two layers to drive IFC VF:

(1) ifcvf_base layer, which handles IFC VF NIC hardware operations and configurations.

(2) ifcvf_main layer, which complies to VDPA bus framework, implemented device operations for VDPA bus, handles device probe, bus attaching, vring operations, etc.

Review

Quoted 7 lines
(quoted diff) +7 -0
+
+#define IFCVF_QUEUE_ALIGNMENT  PAGE_SIZE
+#define IFCVF_QUEUE_MAX                32768
+static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
+{
+       return IFCVF_QUEUE_ALIGNMENT;
+}

This fails to build on arm64 with 64kb page size (found in linux-next):

/drivers/vdpa/ifcvf/ifcvf_main.c: In function 'ifcvf_vdpa_get_vq_align':
arch/arm64/include/asm/page-def.h:17:20: error: conversion from 'long unsigned int' to 'u16' {aka 'short unsigned int'} changes value from '65536' to '0' [-Werror=overflow]

    17 | #define PAGE_SIZE  (_AC(1, UL) << PAGE_SHIFT)
       |                    ^

drivers/vdpa/ifcvf/ifcvf_base.h:37:31: note: in expansion of macro 'PAGE_SIZE'
37 | #define IFCVF_QUEUE_ALIGNMENT PAGE_SIZE
| ^~~~~~~~~
drivers/vdpa/ifcvf/ifcvf_main.c:231:9: note: in expansion of macro 'IFCVF_QUEUE_ALIGNMENT'

   231 |  return IFCVF_QUEUE_ALIGNMENT;
       |         ^~~~~~~~~~~~~~~~~~~~~

It's probably good enough to just not allow the driver to be built in that configuration as it's fairly rare but unfortunately there is no simple Kconfig symbol for it.

In a similar driver, we did

config VMXNET3

         tristate "VMware VMXNET3 ethernet driver"
         depends on PCI && INET
         depends on !(PAGE_SIZE_64KB || ARM64_64K_PAGES || \
                      IA64_PAGE_SIZE_64KB || MICROBLAZE_64K_PAGES || \
                      PARISC_PAGE_SIZE_64KB || PPC_64K_PAGES)
Quoted 7 lines
Quoted 5 lines

I think we should probably make PAGE_SIZE_64KB a global symbol in arch/Kconfig and have it selected by the other symbols so drivers like yours can add a dependency for it.

Arnd

It's probably easier to make the alignment u32 - I don't really know why it's u16, all callers seem to assign the result to a u32 value.

Thanks Michael!

@ Arnd, would you please kindly have a try on the attached patch? I failed to find an armv8 or above platform for now.

Thanks
BR
Zhu Lingshan

From bb2019f0620609fbbdc6854bccc5fefdb53f3d9d Mon Sep 17 00:00:00 2001
From: Zhu Lingshan <[email protected]>
Date: Fri, 10 Apr 2020 11:04:38 +0800
Subject: [PATCH] vdpa: change get_vq_align() to u32 alignment

This commit change the return value of get_vq_align() to u32. this can help resolve a build issue of arm64 platform, and adapting to the callers.

---
 drivers/vdpa/ifcvf/ifcvf_main.c  | 2 +-
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +-
 include/linux/vdpa.h             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/vdpa/ifcvf/ifcvf_main.c +1 -1
index 8d54dc5..970895c 100644
@@ -228,7 +228,7 @@ static u32 ifcvf_vdpa_get_vendor_id(struct vdpa_device *vdpa_dev)
 	return IFCVF_SUBSYS_VENDOR_ID;
 }
 
-static u16 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
+static u32 ifcvf_vdpa_get_vq_align(struct vdpa_device *vdpa_dev)
 {
 	return IFCVF_QUEUE_ALIGNMENT;
 }
drivers/vdpa/vdpa_sim/vdpa_sim.c +1 -1
index 6e8a0cf..a4b3f0d 100644
@@ -435,7 +435,7 @@ static u64 vdpasim_get_vq_state(struct vdpa_device *vdpa, u16 idx)
 	return vrh->last_avail_idx;
 }
 
-static u16 vdpasim_get_vq_align(struct vdpa_device *vdpa)
+static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)
 {
 	return VDPASIM_QUEUE_ALIGN;
 }
include/linux/vdpa.h +1 -1
index 733acfb..5453af8 100644
@@ -164,7 +164,7 @@ struct vdpa_config_ops {
 	u64 (*get_vq_state)(struct vdpa_device *vdev, u16 idx);
 
 	/* Device ops */
-	u16 (*get_vq_align)(struct vdpa_device *vdev);
+	u32 (*get_vq_align)(struct vdpa_device *vdev);
 	u64 (*get_features)(struct vdpa_device *vdev);
 	int (*set_features)(struct vdpa_device *vdev, u64 features);
 	void (*set_config_cb)(struct vdpa_device *vdev,
Signature · 1 line
1.8.3.1
#48 lore raw
In reply to Jason Wang
Quoted 3 lines · Jason Wang

Hi all:

This is an update version of vDPA support in kernel.

OK I put these in my next tree, with an eye towards merging them in 5.7. Many thanks to everyone who reviewed the patches, especially to Jason Gunthorpe for reviewing multiple versions of the patches, helping locate and address the issues.

Quoted 249 lines

vDPA device is a device that uses a datapath which complies with the virtio specifications with vendor specific control path. vDPA devices can be both physically located on the hardware or emulated by software. vDPA hardware devices are usually implemented through PCIE with the following types:

- PF (Physical Function) - A single Physical Function
- VF (Virtual Function) - Device that supports single root I/O virtualization (SR-IOV). Its Virtual Function (VF) represents a virtualized instance of the device that can be assigned to different partitions
- ADI (Assignable Device Interface) and its equivalents - With technologies such as Intel Scalable IOV, a virtual device (VDEV) composed by host OS utilizing one or more ADIs. Or its equivalent like SF (Sub function) from Mellanox.

Quoted 1 line

From a driver's perspective, depends on how and where the DMA

translation is done, vDPA devices are split into two types:

- Platform specific DMA translation - From the driver's perspective, the device can be used on a platform where device access to data in memory is limited and/or translated. An example is a PCIE vDPA whose DMA request was tagged via a bus (e.g PCIE) specific way. DMA translation and protection are done at PCIE bus IOMMU level.
- Device specific DMA translation - The device implements DMA isolation and protection through its own logic. An example is a vDPA device which uses on-chip IOMMU.

To hide the differences and complexity of the above types for a vDPA device/IOMMU options and in order to present a generic virtio device to the upper layer, a device agnostic framework is required.

This series introduces a software vDPA bus which abstracts the common attributes of vDPA device, vDPA bus driver and the communication method, the bus operations (vdpa_config_ops) between the vDPA device abstraction and the vDPA bus driver. This allows multiple types of drivers to be used for vDPA device like the virtio_vdpa and vhost_vdpa driver to operate on the bus and allow vDPA device could be used by either kernel virtio driver or userspace vhost drivers as:

virtio drivers vhost drivers

          |             |
    [virtio bus]   [vhost uAPI]
          |             |
   virtio device   vhost device
   virtio_vdpa drv vhost_vdpa drv
             \       /
            [vDPA bus]
                 |
            vDPA device
            hardware drv
                 |
            [hardware bus]
                 |
            vDPA hardware

virtio_vdpa driver is a transport implementation for kernel virtio drivers on top of vDPA bus operations. An alternative is to refactor virtio bus which is sub-optimal since the bus and drivers are designed to be use by kernel subsystem, a non-trivial major refactoring is needed which may impact a brunches of drivers and devices implementation inside the kernel. Using a new transport may grealy simply both the design and changes.

vhost_vdpa driver is a new type of vhost device which allows userspace vhost drivers to use vDPA devices via vhost uAPI (with minor extension). This help to minimize the changes of existed vhost drivers for using vDPA devices.

With the abstraction of vDPA bus and vDPA bus operations, the difference and complexity of the under layer hardware is hidden from upper layer. The vDPA bus drivers on top can use a unified vdpa_config_ops to control different types of vDPA device.

Two drivers were implemented with the framework introduced in this series:

- Intel IFC VF driver which depends on the platform IOMMU for DMA translation
- VDPA simulator which is a software test device with an emulated onchip IOMMU

Future work:

- direct doorbell mapping support
- control virtqueue support
- dirty page tracking support
- direct interrupt support
- management API (devlink)

Please review.

Thanks

Changes from V8:

- switch to use devres for PCI resoureces of IFCVF (Jason)
- require the caller of vdap_alloc_device() to use "struct foo" instead of foo (Jason)
- some tweaks on the IFCVF driver

Changes from V7:

- refine kconfig to solve the dependency issues on archs that lacks of CONFIG_VIRTUALIZATION (kbuild)

Changes from V6:

- vdpa_alloc_device() will allocate parent strcture (Jason)
- remove the vdpa core dev info in IFCVF patch (Jason)
- provide a free method in the vdpa bus operations for drivet to free private data
- switch to use new layout in vdapsim and IFCVF
- make IFCVF depends on PCI_MSI (kbuild)
- some tweaks on the IFCVF driver

Changes from V5:

- include Intel IFCVF driver and vhost-vdpa drivers
- add the platform IOMMU support for vhost-vdpa
- check the return value of dev_set_name() (Jason)
- various tweaks and fixes

Changes from V4:

- use put_device() instead of kfree when fail to register virtio device (Jason)
- simplify the error handling when allocating vdpasim device (Jason)
- don't use device_for_each_child() during module exit (Jason)
- correct the error checking for vdpa_alloc_device() (Harpreet, Lingshan)

Changes from V3:

- various Kconfig fixes (Randy)

Changes from V2:

- release idr in the release function for put_device() unwind (Jason)
- don't panic when fail to register vdpa bus (Jason)
- use unsigned int instead of int for ida (Jason)
- fix the wrong commit log in virito_vdpa patches (Jason)
- make vdpa_sim depends on RUNTIME_TESTING_MENU (Michael)
- provide a bus release function for vDPA device (Jason)
- fix the wrong unwind when creating devices for vDPA simulator (Jason)
- move vDPA simulator to a dedicated directory (Lingshan)
- cancel the work before release vDPA simulator

Changes from V1:

- drop sysfs API, leave the management interface to future development (Michael)
- introduce incremental DMA ops (dma_map/dma_unmap) (Michael)
- introduce dma_device and use it instead of parent device for doing IOMMU or DMA from bus driver (Michael, Jason, Ling Shan, Tiwei)
- accept parent device and dma device when register vdpa device
- coding style and compile fixes (Randy)
- using vdpa_xxx instead of xxx_vdpa (Jason)
- ove vDPA accessors to header and make it static inline (Jason)
- split vdp_register_device() into two helpers vdpa_init_device() and vdpa_register_device() which allows intermediate step to be done (Jason)
- warn on invalidate queue state when fail to creating virtqueue (Jason)
- make to_virtio_vdpa_device() static (Jason)
- use kmalloc/kfree instead of devres for virtio vdpa device (Jason)
- avoid using cast in vdpa bus function (Jason)
- introduce module_vdpa_driver and fix module refcnt (Jason)
- fix returning freed address in vdapsim coherent DMA addr allocation (Dan)
- various other fixes and tweaks

V8: https://lkml.org/lkml/2020/3/25/125
V7: https://lkml.org/lkml/2020/3/24/21
V6: https://lkml.org/lkml/2020/3/18/88
V5: https://lkml.org/lkml/2020/2/26/58
V4: https://lkml.org/lkml/2020/2/20/59
V3: https://lkml.org/lkml/2020/2/19/1347
V2: https://lkml.org/lkml/2020/2/9/275
V1: https://lkml.org/lkml/2020/1/16/353

Jason Wang (7):
vhost: refine vhost and vringh kconfig
vhost: allow per device message handler
vhost: factor out IOTLB
vringh: IOTLB support
vDPA: introduce vDPA bus
virtio: introduce a vDPA based transport
vdpasim: vDPA device simulator

Tiwei Bie (1):
vhost: introduce vDPA-based backend

Zhu Lingshan (1):
virtio: Intel IFC VF driver for VDPA

 MAINTAINERS                             |   2 +
 arch/arm/kvm/Kconfig                    |   2 -
 arch/arm64/kvm/Kconfig                  |   2 -
 arch/mips/kvm/Kconfig                   |   2 -
 arch/powerpc/kvm/Kconfig                |   2 -
 arch/s390/kvm/Kconfig                   |   4 -
 arch/x86/kvm/Kconfig                    |   4 -
 drivers/Kconfig                         |   2 +
 drivers/misc/mic/Kconfig                |   4 -
 drivers/net/caif/Kconfig                |   4 -
 drivers/vhost/Kconfig                   |  42 +-
 drivers/vhost/Kconfig.vringh            |   6 -
 drivers/vhost/Makefile                  |   6 +
 drivers/vhost/iotlb.c                   | 177 +++++
 drivers/vhost/net.c                     |   5 +-
 drivers/vhost/scsi.c                    |   2 +-
 drivers/vhost/vdpa.c                    | 883 ++++++++++++++++++++++++
 drivers/vhost/vhost.c                   | 233 +++----
 drivers/vhost/vhost.h                   |  45 +-
 drivers/vhost/vringh.c                  | 421 ++++++++++-
 drivers/vhost/vsock.c                   |   2 +-
 drivers/virtio/Kconfig                  |  15 +
 drivers/virtio/Makefile                 |   2 +
 drivers/virtio/vdpa/Kconfig             |  37 +
 drivers/virtio/vdpa/Makefile            |   4 +
 drivers/virtio/vdpa/ifcvf/Makefile      |   3 +
 drivers/virtio/vdpa/ifcvf/ifcvf_base.c  | 389 +++++++++++
 drivers/virtio/vdpa/ifcvf/ifcvf_base.h  | 118 ++++
 drivers/virtio/vdpa/ifcvf/ifcvf_main.c  | 435 ++++++++++++
 drivers/virtio/vdpa/vdpa.c              | 180 +++++
 drivers/virtio/vdpa/vdpa_sim/Makefile   |   2 +
 drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c | 629 +++++++++++++++++
 drivers/virtio/virtio_vdpa.c            | 396 +++++++++++
 include/linux/vdpa.h                    | 253 +++++++
 include/linux/vhost_iotlb.h             |  47 ++
 include/linux/vringh.h                  |  36 +
 include/uapi/linux/vhost.h              |  24 +
 include/uapi/linux/vhost_types.h        |   8 +
 38 files changed, 4180 insertions(+), 248 deletions(-)
 delete mode 100644 drivers/vhost/Kconfig.vringh
 create mode 100644 drivers/vhost/iotlb.c
 create mode 100644 drivers/vhost/vdpa.c
 create mode 100644 drivers/virtio/vdpa/Kconfig
 create mode 100644 drivers/virtio/vdpa/Makefile
 create mode 100644 drivers/virtio/vdpa/ifcvf/Makefile
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_base.c
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_base.h
 create mode 100644 drivers/virtio/vdpa/ifcvf/ifcvf_main.c
 create mode 100644 drivers/virtio/vdpa/vdpa.c
 create mode 100644 drivers/virtio/vdpa/vdpa_sim/Makefile
 create mode 100644 drivers/virtio/vdpa/vdpa_sim/vdpa_sim.c
 create mode 100644 drivers/virtio/virtio_vdpa.c
 create mode 100644 include/linux/vdpa.h
 create mode 100644 include/linux/vhost_iotlb.h
Signature · 1 line
2.20.1