All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC v2 00/13] vhost-user: isolated memory
@ 2026-08-18  5:12 Connor Kite
  2026-08-18  5:12 ` [PATCH RFC v2 01/13] vhost-user: Consolidate chardev property definitions Connor Kite
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Connor Kite @ 2026-08-18  5:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: Michael S. Tsirkin, Stefano Garzarella, Alex Bennée,
	Viresh Kumar, Gerd Hoffmann, Mathieu Poirier, Manos Pitsidianakis,
	Raphael Norwitz, Kevin Wolf, Hanna Reitz, Marc-André Lureau,
	Paolo Bonzini, Fam Zheng, Stefan Hajnoczi, Milan Zamazal,
	Akihiko Odaki, Dmitry Osipenko, qemu-block, virtio-fs,
	Gonglei (Arei), zhenwei pi, Daniel P. Berrangé, Eric Blake,
	Markus Armbruster, Jason Wang, Peter Xu, Eugenio Pérez,
	Alyssa Ross, Demi Marie Obenour, Connor Kite,
	20260817233147.2867623-1-connorkite

This patch series implements a memory isolation mode in vhost-user. The
purpose of this mode is to provide the option of additional security by
eliminating direct access of guest memory by vhost-user devices.
At a high level this works by:

1. Adding qdev and qapi properties required to enable isolation mode for
   various devices.
2. Allocating an isolation memory region in an anonymous file and mapping it
   to host memory.  This isolation region will hold the bounce buffers and
   vrings necessary to move data.
3. Using a vhost-iova-tree to allocate and track the mapping between
   guest regions and their corresponding bounce buffers in the isolation
   memory.
4. Creating shadow virtqueues to intercept request notifications.  As
   kick and call events are received by an svq, it copies buffer
   contents and descriptors between isolation and guest memory before
   notifying the backend or guest.   

Note: This project is currently in a partially functional state.
While the overall method will stay the same, the implementation
is planned to move up into vhost to simplify some elements of
initializing and using the shadow virtqueues.
However, the desire is to make this work public at this stage
for comment on the overall approach.

To: qemu-devel@nongnu.org
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Stefano Garzarella <sgarzare@redhat.com>
Cc: Alex Bennée <alex.bennee@linaro.org>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
Cc: Raphael Norwitz <rnorwitz@nvidia.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Hanna Reitz <hreitz@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Fam Zheng <fam@euphon.net>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Milan Zamazal <mzamazal@redhat.com>
Cc: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Cc: qemu-block@nongnu.org
Cc: virtio-fs@lists.linux.dev
Cc: Gonglei (Arei) <arei.gonglei@huawei.com>
Cc: zhenwei pi <zhenwei.pi@linux.dev>
Cc: Daniel P. Berrangé <berrange@redhat.com>
Cc: Eric Blake <eblake@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>
Cc: Jason Wang <jasowangio@gmail.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Eugenio Pérez <eperezma@redhat.com>
Cc: Alyssa Ross <hi@alyssa.is>
Cc: Demi Marie Obenour <demiobenour@gmail.com>
Signed-off-by: Connor Kite <connorkite@gmail.com>

Based-on: 20260817233147.2867623-1-connorkite@gmail.com
---
Changelog:
V2:
Series:
- Updates to svq address translation moved to a different patch series.
  Link: https://lore.kernel.org/qemu-devel/20260817233147.2867623-1-connorkite@gmail.com 
- The "shadow vq cleanup" has been merged into the earlier patch
  handling svq setup.
- Link to v1: https://lore.kernel.org/qemu-devel/20260723-vhost-user-isolated-memory-v1-0-6b97c439eb28@gmail.com

Individual Patches:
vhost-user: Consolidate chardev property definitions
- Patch author updated from ConKite to Connor Kite

util/iova-tree: g_tree_foreach wrapper
- Added clarification comments about the function passed to
  iova_tree_foreach

hw/virtio: iova_tree_foreach wrapper
- Corrected comment about GTraverseFUnc end condition

hw/virtio/vhost-shadow-virtqueue: used callback
- Changed name of "used_handler" to "used_callback"
- Added handling if callback returns with error value
- Comments added clarifying callback return values

hw/virtio/vhost-shadow-virtqueue: specified vring placement
- Formatting improvements
- Change hwaddr to void * for pointers to host memory
- Bounds checking added when allocating vrings

vhost-user: add memory_isolation to VhostUserState
- Updated net_passt_vhost_user_init signature that is active when
  !defined(CONFIG_VHOST_USER)
- Comment updates for clarity

hw/virtio/vhost-user: create isolation region
- Formatting fixes
- Many comments added
- Read-after-zeroing bug fixed in cleanup_isolation_regions
- User-after-free bug in init_isolation_regions fixed by removing
  duplicate calls, and consolidating those steps in
  cleanup_isolation_regions
- Data unique to isolation mode consolidated in IsolationModeCtx struct
- Vring memory size calculations now only done via an API exposed by
  vhost-shadow-virtqueue
- Isolation region memfd file given a unique name
- Iova-tree IOVA space now starts at 0 + page_size to avoid exposing
  qemu addresses
- buffer_regions array moved changed from GArray to dynamically
  allocated array of predetermined size.  Avoids GArray formatting
  ugliness

  Note: Devicies implemented with multiple vhost threads, like
  virtio-net, are not currently supported.  Work is still required to
  update the vring allocation code to run only for vq_index=0 and
  propagate to the other vhost-user instances.

hw/virtio/vhost-user: send isolation regions to device
- Formatting improvements
- Vring region combined with contiguous buffer region in IOVA space to
  avoid wasting one of the available region slots that can be sent to
  the back-end
- Traversal callback for filling out msg regions renamed to
  vhost_user_fill_msg_reg_from_tree and simplified
- Check added if postcopy is in use as it is not currently supported

hw/virtio/vhost-user: add shadow virtqueues and eventfd intercepts
- Vring mapping now occurs during the vhost_user_set_mem_tables call,
  which means that vring addresses can be sent to the backend when
  expected by vhost
- The svq's device-facing event notifiers are now cleaned up in case of
  error or reset
- Bounds checking on vq index added in various locations
- SVQ cleanup code added

hw/virtio/vhost-user: handle data movement with shadow vqs
- Removed unecessary changes to elements during handling
- Fixed incorrect memcpy of used buffers in reverse direction
- Formatting improvements
- Bounds and error checking to handle mapping failures or buffers with
  invalid ranges
- Add error if isolation mode is used while IOMMU is active
- Add error if isolation mode is used with packed vrings

vhost-user: Add memory-isolation qdev property to vhost-user devices
- Patch moved to end of patch series
- Fixed overlong lines

backends/cryptodev-vhost-user: add memory isolation bool
- Fixed style in qapi and added "since" field
- Clarification added to comments
- The memory_isolation bool can no longer be set in vhost-cryptodev once
  initialization finishes

net/vhost-user: add memory isolation
- Moved to the back of the patch series
- Dead code removed by hard-coding memory_isolation args to vhost_user_init

---
Connor Kite (13):
      vhost-user: Consolidate chardev property definitions
      util/iova-tree: g_tree_foreach wrapper
      hw/virtio: iova_tree_foreach wrapper
      hw/virtio/vhost-shadow-virtqueue: used callback
      hw/virtio/vhost-shadow-virtqueue: specified vring placement
      vhost-user: add memory_isolation to VhostUserState
      hw/virtio/vhost-user: create isolation region
      hw/virtio/vhost-user: send isolation regions to device
      hw/virtio/vhost-user: add shadow virtqueues and eventfd intercepts
      hw/virtio/vhost-user: handle data movement with shadow vqs
      vhost-user: Add memory-isolation qdev property to vhost-user devices
      backends/cryptodev-vhost-user: add memory isolation bool
      net/vhost-user: add memory isolation

 backends/cryptodev-vhost-user.c      |  28 +-
 backends/vhost-user.c                |   4 +-
 hw/block/vhost-user-blk.c            |   4 +-
 hw/display/vhost-user-gpu.c          |   4 +-
 hw/scsi/vhost-user-scsi.c            |   5 +-
 hw/virtio/vhost-iova-tree.c          |  15 +
 hw/virtio/vhost-iova-tree.h          |   2 +
 hw/virtio/vhost-shadow-virtqueue.c   |  80 ++++-
 hw/virtio/vhost-shadow-virtqueue.h   |  25 +-
 hw/virtio/vhost-stub.c               |   3 +-
 hw/virtio/vhost-user-base.c          |  14 +-
 hw/virtio/vhost-user-fs.c            |   5 +-
 hw/virtio/vhost-user-gpio.c          |   4 -
 hw/virtio/vhost-user-i2c.c           |   5 -
 hw/virtio/vhost-user-input.c         |   5 -
 hw/virtio/vhost-user-rng.c           |   5 -
 hw/virtio/vhost-user-rtc.c           |   4 -
 hw/virtio/vhost-user-scmi.c          |   5 +-
 hw/virtio/vhost-user-snd.c           |   1 -
 hw/virtio/vhost-user-spi.c           |   5 -
 hw/virtio/vhost-user-test-device.c   |   1 -
 hw/virtio/vhost-user-vsock.c         |   5 +-
 hw/virtio/vhost-user.c               | 657 ++++++++++++++++++++++++++++++++++-
 include/hw/virtio/vhost-user-base.h  |   1 +
 include/hw/virtio/vhost-user-blk.h   |   1 +
 include/hw/virtio/vhost-user-fs.h    |   1 +
 include/hw/virtio/vhost-user-scmi.h  |   1 +
 include/hw/virtio/vhost-user-vsock.h |   1 +
 include/hw/virtio/vhost-user.h       |   6 +-
 include/hw/virtio/virtio-gpu.h       |   1 +
 include/hw/virtio/virtio-scsi.h      |   1 +
 include/qemu/iova-tree.h             |  21 ++
 include/system/vhost-user-backend.h  |   3 +-
 net/passt.c                          |  19 +-
 net/vhost-user.c                     |  11 +-
 qapi/net.json                        |  16 +-
 qapi/qom.json                        |   8 +-
 util/iova-tree.c                     |   5 +
 38 files changed, 903 insertions(+), 79 deletions(-)
---
base-commit: 88aac004fb1bef50277d8484f4aeacf2e8cb9e38
change-id: 20260604-vhost-user-isolated-memory-070ed4833ee7

Best regards,
-- 
Connor Kite <connorkite@gmail.com>


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-08-18 11:32 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-18  5:12 [PATCH RFC v2 00/13] vhost-user: isolated memory Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 01/13] vhost-user: Consolidate chardev property definitions Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 02/13] util/iova-tree: g_tree_foreach wrapper Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 03/13] hw/virtio: iova_tree_foreach wrapper Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 04/13] hw/virtio/vhost-shadow-virtqueue: used callback Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 05/13] hw/virtio/vhost-shadow-virtqueue: specified vring placement Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 06/13] vhost-user: add memory_isolation to VhostUserState Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 07/13] hw/virtio/vhost-user: create isolation region Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 08/13] hw/virtio/vhost-user: send isolation regions to device Connor Kite
2026-08-18 11:31   ` Akihiko Odaki
2026-08-18  5:12 ` [PATCH RFC v2 09/13] hw/virtio/vhost-user: add shadow virtqueues and eventfd intercepts Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 10/13] hw/virtio/vhost-user: handle data movement with shadow vqs Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 11/13] vhost-user: Add memory-isolation qdev property to vhost-user devices Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 12/13] backends/cryptodev-vhost-user: add memory isolation bool Connor Kite
2026-08-18  5:12 ` [PATCH RFC v2 13/13] net/vhost-user: add memory isolation Connor Kite

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.