Skip to content

Commit c8a6153

Browse files
YongjiXiemstsirkin
authored andcommitted
vduse: Introduce VDUSE - vDPA Device in Userspace
This VDUSE driver enables implementing software-emulated vDPA devices in userspace. The vDPA device is created by ioctl(VDUSE_CREATE_DEV) on /dev/vduse/control. Then a char device interface (/dev/vduse/$NAME) is exported to userspace for device emulation. In order to make the device emulation more secure, the device's control path is handled in kernel. A message mechnism is introduced to forward some dataplane related control messages to userspace. And in the data path, the DMA buffer will be mapped into userspace address space through different ways depending on the vDPA bus to which the vDPA device is attached. In virtio-vdpa case, the MMU-based software IOTLB is used to achieve that. And in vhost-vdpa case, the DMA buffer is reside in a userspace memory region which can be shared to the VDUSE userspace processs via transferring the shmfd. For more details on VDUSE design and usage, please see the follow-on Documentation commit. NB(mst): when merging this with b542e38 ("eventfd: Make signal recursion protection a task bit") replace eventfd_signal_count with eventfd_signal_allowed, and drop the previous ("eventfd: Export eventfd_wake_count to modules"). Signed-off-by: Xie Yongji <[email protected]> Acked-by: Jason Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 8c773d5 commit c8a6153

File tree

6 files changed

+1969
-0
lines changed

6 files changed

+1969
-0
lines changed

Documentation/userspace-api/ioctl/ioctl-number.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ Code Seq# Include File Comments
300300
'z' 10-4F drivers/s390/crypto/zcrypt_api.h conflict!
301301
'|' 00-7F linux/media.h
302302
0x80 00-1F linux/fb.h
303+
0x81 00-1F linux/vduse.h
303304
0x89 00-06 arch/x86/include/asm/sockios.h
304305
0x89 0B-DF linux/sockios.h
305306
0x89 E0-EF linux/sockios.h SIOCPROTOPRIVATE range

drivers/vdpa/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ config VDPA_SIM_BLOCK
3333
vDPA block device simulator which terminates IO request in a
3434
memory buffer.
3535

36+
config VDPA_USER
37+
tristate "VDUSE (vDPA Device in Userspace) support"
38+
depends on EVENTFD && MMU && HAS_DMA
39+
select DMA_OPS
40+
select VHOST_IOTLB
41+
select IOMMU_IOVA
42+
help
43+
With VDUSE it is possible to emulate a vDPA Device
44+
in a userspace program.
45+
3646
config IFCVF
3747
tristate "Intel IFC VF vDPA driver"
3848
depends on PCI_MSI

drivers/vdpa/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_VDPA) += vdpa.o
33
obj-$(CONFIG_VDPA_SIM) += vdpa_sim/
4+
obj-$(CONFIG_VDPA_USER) += vdpa_user/
45
obj-$(CONFIG_IFCVF) += ifcvf/
56
obj-$(CONFIG_MLX5_VDPA) += mlx5/
67
obj-$(CONFIG_VP_VDPA) += virtio_pci/

drivers/vdpa/vdpa_user/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
vduse-y := vduse_dev.o iova_domain.o
4+
5+
obj-$(CONFIG_VDPA_USER) += vduse.o

0 commit comments

Comments
 (0)