Skip to contentSkip to conversation

Add VIRTIO_F_DMB (Device Memory Buffer)

PATCH Superseded Alexander Graf 2 participants 2 messages Jul 2 – Jul 16

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add VIRTIO_F_DMB (Device Memory Buffer)

A confidential-computing device sits outside the driver's trust domain and must operate with no mapping to driver memory. VIRTIO_F_ACCESS_PLATFORM alone does not express this, and neither does a platform restricted-DMA
pool: both still reach driver memory through platform translation. While a global bounce buffer works for some environments, I want to have dedicated shared memory buffers for confidential computing *per device*, which triggered this virtio spec extension.

VIRTIO_F_DMB adds a Device Memory Buffer: a single device-owned shared memory region that holds the virtqueues (Descriptor, Driver and Device Areas) and the buffers they reference. Every address the driver places in a virtqueue becomes an offset into this region rather than a physical or bus address, so the device is confined to memory the driver has explicitly published.

The region reuses the existing Shared Memory Regions facility, is located with the transport-specific enumeration mechanism (so it is available only on transports that define one), and is identified by the reserved shmid 2. VIRTIO_F_DMB refines VIRTIO_F_ACCESS_PLATFORM and is negotiated only together with it.

To provide the confinement guarantee, the device MUST bounds-check every driver-supplied offset against the region and set DEVICE_NEEDS_RESET on violation.

---

Two items for discussion:

* Feature bit number: this uses bit 44. Bits 41/42 are the virtio-net legacy RSC bits and 43 is VIRTIO_F_SUSPEND, so 44 is the first free reserved bit. Happy to take whatever the TC prefers to allocate.

* Shared memory region id: DMB needs a well-known shmid so the driver can locate the region independent of device type. This draft reserves shmid 2 and adds a "Reserved Shared Memory Region IDs" registry. However shmid is currently a per-device-type namespace, and at least one device type (virtio-scmi) documents the entire shmid space as its own. Guidance requested on the preferred mechanism: (a) a small transport-reserved shmid range with device types adjusted to exclude it, or (b) identifying the DMB region by a means other than a fixed shmid. The exact number is not fixed pending this decision.

 conformance.tex |   2 +
 content.tex     |  19 +++++++
 shared-mem.tex  | 130 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 151 insertions(+)
conformance.tex +2 -0
index 9af31e2..cf4259d 100644
@@ -104,6 +104,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{drivernormative:General Initialization And Device Operation / Device Initialization}
 \item \ref{drivernormative:General Initialization And Device Operation / Device Cleanup}
 \item \ref{drivernormative:Reserved Feature Bits}
+\item \ref{drivernormative:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}
 \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device and driver capabilities}
 \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device resource objects}
 \item \ref{drivernormative:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device parts}
@@ -191,6 +192,7 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{devicenormative:Basic Facilities of a Virtio Device / Packed Virtqueues / The Virtqueue Descriptor Table}
 \item \ref{devicenormative:Basic Facilities of a Virtio Device / Packed Virtqueues / Scatter-Gather Support}
 \item \ref{devicenormative:Basic Facilities of a Virtio Device / Shared Memory Regions}
+\item \ref{devicenormative:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}
 \item \ref{devicenormative:Reserved Feature Bits}
 \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device and driver capabilities}
 \item \ref{devicenormative:Basic Facilities of a Virtio Device / Device groups / Group administration commands / Device resource objects}
content.tex +19 -0
index 243ce2d..1311042 100644
@@ -946,6 +946,15 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
    suspend the device by set the SUSPEND bit to 1.
    See \ref{sec:Basic Facilities of a Virtio Device / Device Status Field}.
 
+  \item[VIRTIO_F_DMB(44)] This feature indicates that the device offers a
+  Device Memory Buffer: a shared memory region, owned by the device,
+  that holds the virtqueues and the buffers they reference.  When this feature
+  is negotiated, every address that the driver places in a virtqueue is an
+  offset into the Device Memory Buffer region rather than a physical address
+  or a bus address.  The device is thereby confined to memory the driver has
+  published in that region.
+  See \ref{sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}~\nameref{sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}.
+
 \end{description}
 
 \drivernormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
@@ -982,6 +991,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
 A driver SHOULD accept VIRTIO_F_NOTIF_CONFIG_DATA if it is offered.
 
+A driver MUST NOT accept VIRTIO_F_DMB unless it also accepts
+VIRTIO_F_ACCESS_PLATFORM.  For the driver requirements that apply once
+VIRTIO_F_DMB has been negotiated, see
+\ref{sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}~\nameref{sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}.
+
 \devicenormative{\section}{Reserved Feature Bits}{Reserved Feature Bits}
 
 A device MUST offer VIRTIO_F_VERSION_1.  A device MAY fail to operate further
@@ -1011,6 +1025,11 @@ \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 and presents a PCI SR-IOV capability structure, otherwise
 it MUST NOT offer VIRTIO_F_SR_IOV.
 
+A device that offers VIRTIO_F_DMB MUST also offer VIRTIO_F_ACCESS_PLATFORM.
+For the device requirements that apply once VIRTIO_F_DMB has been
+negotiated, see
+\ref{sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}~\nameref{sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Device Memory Buffer}.
+
 \section{Legacy Interface: Reserved Feature Bits}\label{sec:Reserved Feature Bits / Legacy Interface: Reserved Feature Bits}
 
 Transitional devices MAY offer the following:
shared-mem.tex +130 -0

133 lines not on this page · raw message

Signature · 12 lines
2.47.1




Amazon Web Services Development Center Germany GmbH
Tamara-Danz-Str. 13
10243 Berlin
Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger
Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B
Sitz: Berlin
Ust-ID: DE 365 538 597
#1 lore raw
Quoted 9 lines · Alexander Graf

* Shared memory region id: DMB needs a well-known shmid so the driver can locate the region independent of device type. This draft reserves shmid 2 and adds a "Reserved Shared Memory Region IDs" registry. However shmid is currently a per-device-type namespace, and at least one device type (virtio-scmi) documents the entire shmid space as its own. Guidance requested on the preferred mechanism: (a) a small transport-reserved shmid range with device types adjusted to exclude it, or (b) identifying the DMB region by a means other than a fixed shmid. The exact number is not fixed pending this decision.

Hi Alex,
VIRTIO Transports could provide a way to fetch the DMB shmid. For example, the MMIO transport would get a new read-only DMBSHMId register that contains a valid shmid when VIRTIO_F_DMB has been negotiated.

Allowing the device to report an arbitrary shmid is flexible - it won't interfere with device-specific Shared Memory Regions or future Transport-specific Shared Memory Regions.

Stefan