Skip to content

RFC Support kernel buffers in vhost

Vincent Whitchurch kvm lkml netdev virtualization 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest10 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10vhost: scsi: use copy_to_iter()drivers/vhost/scsi.c+13 -110 replies
2/10vhost: push virtqueue area pointers into a user structdrivers/vhost/vdpa.c drivers/vhost/vhost.c drivers/vhost/vhost.h+53 -510 replies
3/10vhost: add iov wrapperdrivers/vhost/net.c drivers/vhost/scsi.c drivers/vhost/test.c +3 more+81 -450 replies
4/10vhost: add support for kernel buffersdrivers/vhost/Kconfig drivers/vhost/vhost.c drivers/vhost/vhost.h+257 -50 replies
5/10vhost: extract common code for file_operations handlingdrivers/vhost/Makefile drivers/vhost/common.c drivers/vhost/net.c +2 more+197 -1090 replies
6/10vhost: extract ioctl locking to common codedrivers/vhost/common.c drivers/vhost/net.c drivers/vhost/vhost.c +2 more+16 -280 replies
7/10vhost: add support for kernel controldrivers/vhost/common.c drivers/vhost/vhost.c drivers/vhost/vhost.h +1 more+310 -90 replies
8/10vhost: net: add support for kernel controldrivers/vhost/net.c+98 -80 replies
9/10vdpa: add test driver for kernel buffers in vhostdrivers/vdpa/Kconfig drivers/vdpa/Makefile drivers/vdpa/vhost_kernel_test/Makefile +1 more+586 -00 replies
10/10selftests: add vhost_kernel teststools/testing/selftests/Makefile tools/testing/selftests/vhost_kernel/vhost_kernel_test.c tools/testing/selftests/vhost_kernel/vhost_kernel_test.sh+413 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 00/10] Support kernel buffers in vhost

vhost currently expects that the virtqueues and the queued buffers are accessible from a userspace process' address space. However, when using vhost to communicate between two Linux systems running on two physical CPUs in an AMP configuration (on a single SoC or via something like PCIe), it is undesirable from a security perspective to make the entire kernel memory of the other Linux system accessible from userspace.

To remedy this, this series adds support to vhost for placing the virtqueues and queued buffers in kernel memory. Since userspace should not be allowed to control the placement and attributes of these virtqueues, a mechanism to do this from kernel space is added. A vDPA-based test driver is added which uses this support to allow virtio-net and vhost-net to communicate with each other on the same system without exposing kernel memory to userspace via /dev/mem or similar.

This vDPA-based test driver is intended to be used as the basis for the implementation of driver which will allow Linux-Linux communication between physical CPUs on SoCs using virtio and vhost, for instance by using information from the device tree to indicate the location of shared memory, and the mailbox API to trigger interrupts between the CPUs.

This patchset is also available at:

https://github.com/vwax/linux/tree/vhost/rfc

Vincent Whitchurch (10):
vhost: scsi: use copy_to_iter()
vhost: push virtqueue area pointers into a user struct
vhost: add iov wrapper
vhost: add support for kernel buffers
vhost: extract common code for file_operations handling
vhost: extract ioctl locking to common code
vhost: add support for kernel control
vhost: net: add support for kernel control
vdpa: add test driver for kernel buffers in vhost
selftests: add vhost_kernel tests

 drivers/vdpa/Kconfig                          |   8 +
 drivers/vdpa/Makefile                         |   1 +
 drivers/vdpa/vhost_kernel_test/Makefile       |   2 +
 .../vhost_kernel_test/vhost_kernel_test.c     | 575 ++++++++++++++++++
 drivers/vhost/Kconfig                         |   6 +
 drivers/vhost/Makefile                        |   3 +
 drivers/vhost/common.c                        | 340 +++++++++++
 drivers/vhost/net.c                           | 212 ++++---
 drivers/vhost/scsi.c                          |  50 +-
 drivers/vhost/test.c                          |   2 +-
 drivers/vhost/vdpa.c                          |   6 +-
 drivers/vhost/vhost.c                         | 437 ++++++++++---
 drivers/vhost/vhost.h                         | 109 +++-
 drivers/vhost/vsock.c                         |  95 +--
 include/linux/vhost.h                         |  23 +
 tools/testing/selftests/Makefile              |   1 +
 .../vhost_kernel/vhost_kernel_test.c          | 287 +++++++++
 .../vhost_kernel/vhost_kernel_test.sh         | 125 ++++
 18 files changed, 2020 insertions(+), 262 deletions(-)
 create mode 100644 drivers/vdpa/vhost_kernel_test/Makefile
 create mode 100644 drivers/vdpa/vhost_kernel_test/vhost_kernel_test.c
 create mode 100644 drivers/vhost/common.c
 create mode 100644 include/linux/vhost.h
 create mode 100644 tools/testing/selftests/vhost_kernel/vhost_kernel_test.c
 create mode 100755 tools/testing/selftests/vhost_kernel/vhost_kernel_test.sh
Signature · 1 line
2.28.0