RFC vhost-user: isolated memory
Get series with b4
b4 am [email protected] change-id 20260604-vhost-user-isolated-memory-070ed4833ee7Versions newest first
- v2 RFC Latest13 patches 27 repliesIn review
- v1 RFC15 patches 83 repliesSuperseded
Changes in v2 from the cover letter
Series:
- Updates to svq address translation moved to a different patch series.
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/13 | vhost-user: Consolidate chardev property definitionshw/ hw/ hw/ +6 more | +9 | 0 replies | |
| 2/13 | util/iova-tree: g_tree_foreach wrapperinclude/ util/ | +26 | 0 replies | |
| 3/13 | hw/virtio: iova_tree_foreach wrapperhw/ hw/ | +17 | 0 replies | |
| 4/13 | hw/virtio/vhost-shadow-virtqueue: used callbackhw/ hw/ | +25 | 5 replies | |
| 5/13 | hw/virtio/vhost-shadow-virtqueue: specified vring placementhw/ hw/ | +66 | 4 replies | |
| 6/13 | vhost-user: add memory_isolation to VhostUserStatebackends/ backends/ hw/ +12 more | +45 | 0 replies | |
| 7/13 | hw/virtio/vhost-user: create isolation regionhw/ | +136 | 3 replies | |
| 8/13 | hw/virtio/vhost-user: send isolation regions to devicehw/ | +117 | 3 replies | |
| 9/13 | hw/virtio/vhost-user: add shadow virtqueues and eventfd interceptshw/ | +119 | 3 replies | |
| 10/13 | hw/virtio/vhost-user: handle data movement with shadow vqshw/ hw/ hw/ | +286 | 2 replies | |
| 11/13 | vhost-user: Add memory-isolation qdev property to vhost-user deviceshw/ hw/ hw/ +11 more | +27 | 0 replies | |
| 12/13 | backends/cryptodev-vhost-user: add memory isolation boolbackends/ qapi/ | +34 | 1 reply | |
| 13/13 | net/vhost-user: add memory isolationnet/ net/ qapi/ | +20 | 6 replies |
Reviews trailers per patch
3 of 13 patches have a Reviewed-by or Acked-by.
| Patch | Stefan Hajnoczi |
|---|---|
| 1/13 | R-b |
| 2/13 | R-b |
| 3/13 | |
| 4/13 | |
| 5/13 | |
| 6/13 | |
| 7/13 | |
| 8/13 | |
| 9/13 | |
| 10/13 | |
| 11/13 | R-b |
| 12/13 | |
| 13/13 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH RFC v2 00/13] vhost-user: isolated memory
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.
Based-on: [email protected]
---
Changelog:
V2:
Series:
- Updates to svq address translation moved to a different patch series.
- The "shadow vq cleanup" has been merged into the earlier patch
handling svq setup.
- Link to v1: https://lore.kernel.org/qemu-devel/[email protected]
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,
Signature · 1 line
Connor Kite <[email protected]>