Skip to contentSkip to conversation

virtio-dmabuf: Add specification details for this device

PATCH In review Vivek Kasireddy 3 participants 7 messages Feb 3, 2021 – Feb 4, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio-dmabuf: Add specification details for this device

The virtio dmabuf device provides a way to share a page backed dmabuf created in the Guest with the Host. The actual sharing is accomplished by recreating the dmabuf on the Host using the page metadata shared by the guest.

---
 conformance.tex    |  30 ++++++++++--
 content.tex        |   3 ++
 virtio-vdmabuf.tex | 120 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 4 deletions(-)
 create mode 100644 virtio-vdmabuf.tex
conformance.tex +26 -4
index e78adfd..1f972ae 100644
@@ -28,8 +28,9 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \ref{sec:Conformance / Driver Conformance / RPMB Driver Conformance},
 \ref{sec:Conformance / Driver Conformance / IOMMU Driver Conformance},
 \ref{sec:Conformance / Driver Conformance / Sound Driver Conformance}
-\ref{sec:Conformance / Driver Conformance / Memory Driver Conformance} or
-\ref{sec:Conformance / Driver Conformance / I2C Adapter Driver Conformance}.
+\ref{sec:Conformance / Driver Conformance / Memory Driver Conformance}
+\ref{sec:Conformance / Driver Conformance / I2C Adapter Driver Conformance} or
+\ref{sec:Conformance / Driver Conformance / Dmabuf Driver Conformance}.
 
     \item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}.
   \end{itemize}
@@ -50,8 +51,9 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \ref{sec:Conformance / Device Conformance / RPMB Device Conformance},
 \ref{sec:Conformance / Device Conformance / IOMMU Device Conformance},
 \ref{sec:Conformance / Device Conformance / Sound Device Conformance}
-\ref{sec:Conformance / Device Conformance / Memory Device Conformance} or
-\ref{sec:Conformance / Device Conformance / I2C Adapter Device Conformance}.
+\ref{sec:Conformance / Device Conformance / Memory Device Conformance}
+\ref{sec:Conformance / Device Conformance / I2C Adapter Device Conformance} or
+\ref{sec:Conformance / Driver Conformance / Dmabuf Driver Conformance}.
 
     \item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}.
   \end{itemize}
@@ -276,6 +278,16 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{drivernormative:Device Types / I2C Adapter Device / Device Operation}
 \end{itemize}
 
+\conformance{\subsection}{Dmabuf Driver Conformance}\label{sec:Conformance / Driver Conformance / Dmabuf Driver Conformance}
+
+A Dmabuf driver MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / VM ID}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Export}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Release}
+\end{itemize}
+
 \conformance{\section}{Device Conformance}\label{sec:Conformance / Device Conformance}
 
 A device MUST conform to the following normative statements:
@@ -503,6 +515,16 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{devicenormative:Device Types / I2C Adapter Device / Device Operation}
 \end{itemize}
 
+\conformance{\subsection}{Dmabuf Device Conformance}\label{sec:Conformance / Device Conformance / Dmabuf Device Conformance}
+
+A Dmabuf device MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / VM ID}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Export}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Release}
+\end{itemize}
+
 \conformance{\section}{Legacy Interface: Transitional Device and Transitional Driver Conformance}\label{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}
 A conformant implementation MUST be either transitional or
 non-transitional, see \ref{intro:Legacy
content.tex +3 -0
index 1ca24c1..b6ea383 100644
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}
 \hline
 35         &   Watchdog \\
 \hline
+36         &   Dmabuf device \\
+\hline
 \end{tabular}
 
 Some of the devices above are unspecified by this document,
@@ -6508,6 +6510,7 @@ \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
 \input{virtio-sound.tex}
 \input{virtio-mem.tex}
 \input{virtio-i2c.tex}
+\input{virtio-vdmabuf.tex}
 
 \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
virtio-vdmabuf.tex new file +120 -0

120 lines not on this page · raw message

Signature · 18 lines
2.26.2


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/
#1 lore raw
Quoted 14 lines · On Wed, 3 Feb 2021 00:40:58 -0800 Vivek Kasireddy <[email protected]>…

The virtio dmabuf device provides a way to share a page backed dmabuf created in the Guest with the Host. The actual sharing is accomplished by recreating the dmabuf on the Host using the page metadata shared by the guest.

---
 conformance.tex    |  30 ++++++++++--
 content.tex        |   3 ++
 virtio-vdmabuf.tex | 120 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 4 deletions(-)
 create mode 100644 virtio-vdmabuf.tex

(...)

content.tex \chapter{Device Types}\label{sec:Device Types} · line 2849

Quoted 9 lines
content.tex +1 -0
index 1ca24c1..b6ea383 100644
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}
 \hline
 35         &   Watchdog \\
 \hline
+36         &   Dmabuf device \\

Please split off reserving a device id into a separate issue that can be voted upon independently.

Also, there was already a request on-list to reserve 36 for CAN (although no issue has yet been opened); maybe bump the id to 37 regardless?

content.tex \chapter{Device Types}\label{sec:Device Types} · line 2853

Quoted 4 lines
content.tex +1 -0
+\hline
 \end{tabular}
 
 Some of the devices above are unspecified by this document,

(...)

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#2 lore raw

PATCH 1/1 content: Request to reserve device ID 37 for Dmabuf device

The Dmabuf device can be used to share a dmabuf created in the Guest with the Host.

---
 content.tex | 2 ++
 1 file changed, 2 insertions(+)
content.tex +2 -0
index 1ca24c1..c1ba683 100644
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}
 \hline
 35         &   Watchdog \\
 \hline
+37         &   Dmabuf device \\
+\hline
 \end{tabular}
 
 Some of the devices above are unspecified by this document,
Signature · 18 lines
2.26.2


This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/
Reviewed-by on v1 1/1
#3 lore raw

Re: [virtio-comment] [PATCH] content: Request to reserve device ID 37 for Dmabuf device

Quoted 14 lines · On Wed, 3 Feb 2021 23:46:00 -0800 Vivek Kasireddy <[email protected]>…

The Dmabuf device can be used to share a dmabuf created in the Guest with the Host.

---
 content.tex | 2 ++
 1 file changed, 2 insertions(+)
content.tex +0 -0
index 1ca24c1..c1ba683 100644

content.tex \chapter{Device Types}\label{sec:Device Types} · line 2853

Quoted 8 lines
content.tex +2 -0
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}
 \hline
 35         &   Watchdog \\
 \hline
+37         &   Dmabuf device \\
+\hline
 \end{tabular}
 
 Some of the devices above are unspecified by this document,

In order to request a vote, please follow the process outlined at
https://github.com/oasis-tcs/virtio-spec#use-of-github-issues.

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#4 lore raw

RE: [virtio-comment] [PATCH] content: Request to reserve device ID 37 for Dmabuf device

Thank you for the review Cornelia; we'll request a vote soon.

Thanks,
Vivek

Quoted 31 lines

-----Original Message-----
From: Cornelia Huck <[email protected]>
Sent: Thursday, February 04, 2021 2:16 AM
To: Kasireddy, Vivek <[email protected]>
Cc: [email protected]; Kim, Dongwon <[email protected]>
Subject: Re: [virtio-comment] [PATCH] content: Request to reserve device ID 37 for Dmabuf device

Quoted 20 lines · On Wed, 3 Feb 2021 23:46:00 -0800 Vivek Kasireddy <[email protected]>…

The Dmabuf device can be used to share a dmabuf created in the Guest with the Host.

---
 content.tex | 2 ++
 1 file changed, 2 insertions(+)
content.tex +0 -0
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}

\hline
35 & Watchdog \\
\hline
+37 & Dmabuf device \\
+\hline
\end{tabular}

Quoted 6 lines
Quoted 1 line

Some of the devices above are unspecified by this document,

In order to request a vote, please follow the process outlined at https://github.com/oasis-
tcs/virtio-spec#use-of-github-issues.

This publicly archived list offers a means to provide input to the OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and to minimize spam in the list archive, subscription is required before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/

#5 lore raw
In reply to Vivek Kasireddy
Quoted 4 lines · Vivek Kasireddy

The virtio dmabuf device provides a way to share a page backed dmabuf created in the Guest with the Host. The actual sharing is accomplished by recreating the dmabuf on the Host using the page metadata shared by the guest.

What's the use case for this?

Jan

Quoted 220 lines
---
 conformance.tex    |  30 ++++++++++--
 content.tex        |   3 ++
 virtio-vdmabuf.tex | 120 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 4 deletions(-)
 create mode 100644 virtio-vdmabuf.tex
conformance.tex +26 -4
index e78adfd..1f972ae 100644
@@ -28,8 +28,9 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \ref{sec:Conformance / Driver Conformance / RPMB Driver Conformance},
 \ref{sec:Conformance / Driver Conformance / IOMMU Driver Conformance},
 \ref{sec:Conformance / Driver Conformance / Sound Driver Conformance}
-\ref{sec:Conformance / Driver Conformance / Memory Driver Conformance} or
-\ref{sec:Conformance / Driver Conformance / I2C Adapter Driver Conformance}.
+\ref{sec:Conformance / Driver Conformance / Memory Driver Conformance}
+\ref{sec:Conformance / Driver Conformance / I2C Adapter Driver Conformance} or
+\ref{sec:Conformance / Driver Conformance / Dmabuf Driver Conformance}.
 
     \item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}.
   \end{itemize}
@@ -50,8 +51,9 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \ref{sec:Conformance / Device Conformance / RPMB Device Conformance},
 \ref{sec:Conformance / Device Conformance / IOMMU Device Conformance},
 \ref{sec:Conformance / Device Conformance / Sound Device Conformance}
-\ref{sec:Conformance / Device Conformance / Memory Device Conformance} or
-\ref{sec:Conformance / Device Conformance / I2C Adapter Device Conformance}.
+\ref{sec:Conformance / Device Conformance / Memory Device Conformance}
+\ref{sec:Conformance / Device Conformance / I2C Adapter Device Conformance} or
+\ref{sec:Conformance / Driver Conformance / Dmabuf Driver Conformance}.
 
     \item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}.
   \end{itemize}
@@ -276,6 +278,16 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{drivernormative:Device Types / I2C Adapter Device / Device Operation}
 \end{itemize}
 
+\conformance{\subsection}{Dmabuf Driver Conformance}\label{sec:Conformance / Driver Conformance / Dmabuf Driver Conformance}
+
+A Dmabuf driver MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / VM ID}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Export}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Release}
+\end{itemize}
+
 \conformance{\section}{Device Conformance}\label{sec:Conformance / Device Conformance}
 
 A device MUST conform to the following normative statements:
@@ -503,6 +515,16 @@ \section{Conformance Targets}\label{sec:Conformance / Conformance Targets}
 \item \ref{devicenormative:Device Types / I2C Adapter Device / Device Operation}
 \end{itemize}
 
+\conformance{\subsection}{Dmabuf Device Conformance}\label{sec:Conformance / Device Conformance / Dmabuf Device Conformance}
+
+A Dmabuf device MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / VM ID}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Export}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device Operation / Release}
+\end{itemize}
+
 \conformance{\section}{Legacy Interface: Transitional Device and Transitional Driver Conformance}\label{sec:Conformance / Legacy Interface: Transitional Device and Transitional Driver Conformance}
 A conformant implementation MUST be either transitional or
 non-transitional, see \ref{intro:Legacy
content.tex +3 -0
index 1ca24c1..b6ea383 100644
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}
 \hline
 35         &   Watchdog \\
 \hline
+36         &   Dmabuf device \\
+\hline
 \end{tabular}
 
 Some of the devices above are unspecified by this document,
@@ -6508,6 +6510,7 @@ \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device
 \input{virtio-sound.tex}
 \input{virtio-mem.tex}
 \input{virtio-i2c.tex}
+\input{virtio-vdmabuf.tex}
 
 \chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}
 
virtio-vdmabuf.tex new file +120 -0
new file mode 100644
index 0000000..18a4e2c
@@ -0,0 +1,120 @@
+\section{Dmabuf Device}\label{sec:Device Types / Dmabuf Device}
+
+The virtio dmabuf device is a virtual dmabuf transfer device that provides
+a way to share a page-backed dmabuf created in the Guest with the device.
+Once shared, the driver and the device would use the same underlying memory
+associated with the original dmabuf but not at the same time.
+
+\subsection{Device ID}\label{sec:Device Types / Dmabuf Device / Device ID}
+  36
+
+\subsection{Virtqueues}\label{sec:Device Types / Dmabuf Device / Virtqueues}
+\begin{description}
+\item[0] recv
+\item[1] send
+\end{description}
+
+\subsection{Feature bits}\label{sec:Device Types / Dmabuf Device / Feature bits}
+
+No specific feature bits defined for this device.
+
+\subsection{Device configuration layout}\label{sec:Device Types / Dmabuf Device / Device configuration layout}
+
+No specific layout defined for this device.
+
+\subsection{Device Initialization}\label{sec:Device Types / Dmabuf Device / Device Initialization}
+
+\begin{enumerate}
+\item Both the send and recv virtqueues are initialized to handle messages.
+\end{enumerate}
+
+\subsection{Device Operation}\label{sec:Device Types / Dmabuf Device / Device Operation}
+
+Messages that are sent or received are of the following format:
+
+\begin{lstlisting}
+struct virtio_vdmabuf_msg {
+        le32 cmd;
+        le32 op[64];
+};
+\end{lstlisting}
+
+The field \field{cmd} is initialized with one of the following:
+
+\begin{lstlisting}
+enum virtio_vdmabuf_cmd {
+        VIRTIO_VDMABUF_CMD_NEED_VMID = 1,
+        VIRTIO_VDMABUF_CMD_EXPORT = 2,
+        VIRTIO_VDMABUF_CMD_DMABUF_REL =3,
+};
+\end{lstlisting}
+
+Based on the field \field{cmd}, the 256 bytes represented by the field
+\field{op} are either zeroed out or contain metadata. They are zeroed out
+if \field{cmd} is VIRTIO_VDMABUF_CMD_NEED_VMID. In other cases, the metadata
+is formatted as below.
+
+The first 16 bytes contains a unique 128-bit Identifier of the following
+format:
+\begin{lstlisting}
+struct virtio_vdmabuf_buf_id_t{
+        le64 id;
+        le32 rng_key[2];
+};
+\end{lstlisting}
+
+The first 4 bytes of \field{id} contain an ID associated with the device and
+the other 4 bytes contain a counter. The last 8 bytes of the above structure
+represented by \field{rng_key} contain random data to ensure that the 128-bit
+identifier is indeed unique at any given time.
+
+The remaining 240 bytes contain private data shared between the driver and
+the device.
+
+\subsubsection{Virtqueue Flow Control}\label{sec:Device Types / Dmabuf Device / Device Operation / Virtqueue Flow Control}
+
+The send virtqueue carries messages initiated by an application running in the
+Guest and responses to previously sent messages. The recv virtqueue carries
+messages initiated by the device.
+
+\subsubsection{VM ID}\label{sec:Device Types / Dmabuf Device / Device Operation / VM ID}
+
+The driver sends a VM ID message to the device via the send virtqueue
+after setting the \field{cmd} to VIRTIO_VDMABUF_CMD_NEED_VMID.
+
+In response, the device would queue up a message on the recv virtqueue with
+the \field{cmd} set to VIRTIO_VDMABUF_CMD_NEED_VMID and the first 4 bytes of
+\field{op} containing the ID associated with the device.
+
+\drivernormative{\paragraph}{Device Operation: VM ID}{Device Types / Dmabuf Device / Device Operation / VM ID}
+
+The rest of the message MUST be zeroed out.
+
+\subsubsection{Export}\label{sec:Device Types / Dmabuf Device / Device Operation / Export}
+
+The driver sends an Export message to the device via the send virtqueue
+after populating the message as follows:
+
+\drivernormative{\paragraph}{Device Operation: Export}{Device Types / Dmabuf Device / Device Operation / Export}
+
+The driver MUST set \field{cmd} to VIRTIO_VDMABUF_CMD_EXPORT.
+
+The driver MUST set the first 16 bytes of \field{op} to a new unique ID.
+
+The driver MUST populate the next 20 bytes of \field{op} with valid meta data
+associated with the buffer represented by the ID.
+
+\subsubsection{Release}\label{sec:Device Types / Dmabuf Device / Device Operation / Release}
+
+The device sends a Release message to the driver via the recv virtqueue
+after populating the message as follows:
+
+\drivernormative{\paragraph}{Device Operation: Release}{Device Types / Dmabuf Device / Device Operation / Release}
+
+The device MUST set \field{cmd} to VIRTIO_VDMABUF_CMD_RELEASE.
+
+The device MUST set the first 16 bytes of \field{op} to a valid unique ID
+that was previously shared by the driver.
+
+The device must zero out the remaining part of the message.
+
Signature · 18 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux

This publicly archived list offers a means to provide input to the
OASIS Virtual I/O Device (VIRTIO) TC.

In order to verify user consent to the Feedback License terms and
to minimize spam in the list archive, subscription is required
before posting.

Subscribe: [email protected]
Unsubscribe: [email protected]
List help: [email protected]
List archive: https://lists.oasis-open.org/archives/virtio-comment/
Feedback License: https://www.oasis-open.org/who/ipr/feedback_license.pdf
List Guidelines: https://www.oasis-open.org/policies-guidelines/mailing-lists
Committee: https://www.oasis-open.org/committees/virtio/
Join OASIS: https://www.oasis-open.org/join/
#6 lore raw

Hi Jan,
I have detailed some of the use-cases here:
https://lists.linuxfoundation.org/pipermail/virtualization/2021-February/052233.html

We expect more use-cases to come up as new hardware (Discrete GPUs from Intel and other OEMs) with advanced features becomes available and there would be a need to access data/buffers created in the Guest on the Host in a standard (Dmabuf) way.

Thanks,
Vivek

Quoted 265 lines

-----Original Message-----
From: Jan Kiszka <[email protected]>
Sent: Thursday, February 04, 2021 2:24 AM
To: Kasireddy, Vivek <[email protected]>; [email protected] open.org; [email protected]
Cc: [email protected]; Kim, Dongwon <[email protected]>
Subject: Re: [virtio-comment] [PATCH] virtio-dmabuf: Add specification details for this device

Quoted 4 lines · Vivek Kasireddy

The virtio dmabuf device provides a way to share a page backed dmabuf created in the Guest with the Host. The actual sharing is accomplished by recreating the dmabuf on the Host using the page metadata shared by the guest.

What's the use case for this?

Jan

Quoted 16 lines
---
 conformance.tex    |  30 ++++++++++--
 content.tex        |   3 ++
 virtio-vdmabuf.tex | 120
+++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+), 4 deletions(-)  create mode

100644 virtio-vdmabuf.tex

conformance.tex index e78adfd..1f972ae renamed from conformance.tex +0 -0

100644

conformance.tex +0 -0
@@ -28,8 +28,9 @@ \section{Conformance Targets}\label{sec:Conformance
Quoted 5 lines

/ Conformance Targets} \ref{sec:Conformance / Driver Conformance / RPMB Driver Conformance}, \ref{sec:Conformance / Driver Conformance / IOMMU Driver Conformance}, \ref{sec:Conformance / Driver Conformance / Sound Driver Conformance} -\ref{sec:Conformance / Driver Conformance / Memory Driver Conformance} or -\ref{sec:Conformance / Driver Conformance / I2C

Adapter Driver Conformance}.

conformance.tex

Quoted 3 lines

+\ref{sec:Conformance / Driver Conformance / Memory Driver

conformance.tex +2 -0
+Conformance} \ref{sec:Conformance / Driver Conformance / I2C Adapter
+Driver Conformance} or \ref{sec:Conformance / Driver Conformance / Dmabuf Driver

Conformance}.

Quoted 2 lines

\item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and

Transitional Driver Conformance}.

Quoted 7 lines
   \end{itemize}
conformance.tex +0 -0
@@ -50,8 +51,9 @@ \section{Conformance Targets}\label{sec:Conformance

/ Conformance Targets} \ref{sec:Conformance / Device Conformance / RPMB Device Conformance}, \ref{sec:Conformance / Device Conformance / IOMMU Device Conformance}, \ref{sec:Conformance / Device Conformance / Sound Device Conformance} -\ref{sec:Conformance / Device Conformance / Memory Device Conformance} or -\ref{sec:Conformance / Device Conformance / I2C

Adapter Device Conformance}.

conformance.tex

Quoted 3 lines

+\ref{sec:Conformance / Device Conformance / Memory Device

conformance.tex +2 -0
+Conformance} \ref{sec:Conformance / Device Conformance / I2C Adapter
+Device Conformance} or \ref{sec:Conformance / Driver Conformance / Dmabuf Driver

Conformance}.

Quoted 2 lines

\item Clause \ref{sec:Conformance / Legacy Interface: Transitional Device and

Transitional Driver Conformance}.

Quoted 188 lines
   \end{itemize}
conformance.tex +0 -0
@@ -276,6 +278,16 @@ \section{Conformance

Targets}\label{sec:Conformance / Conformance Targets} \item \ref{drivernormative:Device Types / I2C Adapter Device / Device Operation} \end{itemize}

+\conformance{\subsection}{Dmabuf Driver

conformance.tex +11 -0
+Conformance}\label{sec:Conformance / Driver Conformance / Dmabuf
+Driver Conformance}
+
+A Dmabuf driver MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device
+Operation / VM ID} \item \ref{drivernormative:Device Types / Dmabuf
+Device / Device Operation / Export} \item \ref{drivernormative:Device
+Types / Dmabuf Device / Device Operation / Release} \end{itemize}
+
 \conformance{\section}{Device Conformance}\label{sec:Conformance /

Device Conformance}

A device MUST conform to the following normative statements:

conformance.tex +0 -0
@@ -503,6 +515,16 @@ \section{Conformance

Targets}\label{sec:Conformance / Conformance Targets} \item \ref{devicenormative:Device Types / I2C Adapter Device / Device Operation} \end{itemize}

+\conformance{\subsection}{Dmabuf Device

conformance.tex +11 -0
+Conformance}\label{sec:Conformance / Device Conformance / Dmabuf
+Device Conformance}
+
+A Dmabuf device MUST conform to the following normative statements:
+
+\begin{itemize}
+\item \ref{drivernormative:Device Types / Dmabuf Device / Device
+Operation / VM ID} \item \ref{drivernormative:Device Types / Dmabuf
+Device / Device Operation / Export} \item \ref{drivernormative:Device
+Types / Dmabuf Device / Device Operation / Release} \end{itemize}
+
 \conformance{\section}{Legacy Interface: Transitional Device and

Transitional Driver Conformance}\label{sec:Conformance / Legacy
Interface: Transitional Device and Transitional Driver Conformance} A conformant implementation MUST be either transitional or non-transitional, see \ref{intro:Legacy diff --git a/content.tex b/content.tex index 1ca24c1..b6ea383 100644

content.tex +0 -0
@@ -2846,6 +2846,8 @@ \chapter{Device Types}\label{sec:Device Types}

\hline
35 & Watchdog \\
\hline
+36 & Dmabuf device \\
+\hline
\end{tabular}

Some of the devices above are unspecified by this document, @@
-6508,6 +6510,7 @@ \subsubsection{Legacy Interface: Framing Requirements}\label{sec:Device \input{virtio-sound.tex} \input{virtio-mem.tex} \input{virtio-i2c.tex} +\input{virtio-vdmabuf.tex}

\chapter{Reserved Feature Bits}\label{sec:Reserved Feature Bits}

virtio-vdmabuf.tex new file mode renamed from virtio-vdmabuf.tex +0 -0

100644 index 0000000..18a4e2c

virtio-vdmabuf.tex new file +119 -0
@@ -0,0 +1,120 @@
+\section{Dmabuf Device}\label{sec:Device Types / Dmabuf Device}
+
+The virtio dmabuf device is a virtual dmabuf transfer device that
+provides a way to share a page-backed dmabuf created in the Guest with the device.
+Once shared, the driver and the device would use the same underlying
+memory associated with the original dmabuf but not at the same time.
+
+\subsection{Device ID}\label{sec:Device Types / Dmabuf Device /
+Device ID}
+  36
+
+\subsection{Virtqueues}\label{sec:Device Types / Dmabuf Device /
+Virtqueues} \begin{description} \item[0] recv \item[1] send
+\end{description}
+
+\subsection{Feature bits}\label{sec:Device Types / Dmabuf Device /
+Feature bits}
+
+No specific feature bits defined for this device.
+
+\subsection{Device configuration layout}\label{sec:Device Types /
+Dmabuf Device / Device configuration layout}
+
+No specific layout defined for this device.
+
+\subsection{Device Initialization}\label{sec:Device Types / Dmabuf
+Device / Device Initialization}
+
+\begin{enumerate}
+\item Both the send and recv virtqueues are initialized to handle messages.
+\end{enumerate}
+
+\subsection{Device Operation}\label{sec:Device Types / Dmabuf Device
+/ Device Operation}
+
+Messages that are sent or received are of the following format:
+
+\begin{lstlisting}
+struct virtio_vdmabuf_msg {
+        le32 cmd;
+        le32 op[64];
+};
+\end{lstlisting}
+
+The field \field{cmd} is initialized with one of the following:
+
+\begin{lstlisting}
+enum virtio_vdmabuf_cmd {
+        VIRTIO_VDMABUF_CMD_NEED_VMID = 1,
+        VIRTIO_VDMABUF_CMD_EXPORT = 2,
+        VIRTIO_VDMABUF_CMD_DMABUF_REL =3, }; \end{lstlisting}
+
+Based on the field \field{cmd}, the 256 bytes represented by the
+field \field{op} are either zeroed out or contain metadata. They are
+zeroed out if \field{cmd} is VIRTIO_VDMABUF_CMD_NEED_VMID. In other
+cases, the metadata is formatted as below.
+
+The first 16 bytes contains a unique 128-bit Identifier of the
+following
+format:
+\begin{lstlisting}
+struct virtio_vdmabuf_buf_id_t{
+        le64 id;
+        le32 rng_key[2];
+};
+\end{lstlisting}
+
+The first 4 bytes of \field{id} contain an ID associated with the
+device and the other 4 bytes contain a counter. The last 8 bytes of
+the above structure represented by \field{rng_key} contain random
+data to ensure that the 128-bit identifier is indeed unique at any given time.
+
+The remaining 240 bytes contain private data shared between the
+driver and the device.
+
+\subsubsection{Virtqueue Flow Control}\label{sec:Device Types /
+Dmabuf Device / Device Operation / Virtqueue Flow Control}
+
+The send virtqueue carries messages initiated by an application
+running in the Guest and responses to previously sent messages. The
+recv virtqueue carries messages initiated by the device.
+
+\subsubsection{VM ID}\label{sec:Device Types / Dmabuf Device / Device
+Operation / VM ID}
+
+The driver sends a VM ID message to the device via the send virtqueue
+after setting the \field{cmd} to VIRTIO_VDMABUF_CMD_NEED_VMID.
+
+In response, the device would queue up a message on the recv
+virtqueue with the \field{cmd} set to VIRTIO_VDMABUF_CMD_NEED_VMID
+and the first 4 bytes of \field{op} containing the ID associated with the device.
+
+\drivernormative{\paragraph}{Device Operation: VM ID}{Device Types /
+Dmabuf Device / Device Operation / VM ID}
+
+The rest of the message MUST be zeroed out.
+
+\subsubsection{Export}\label{sec:Device Types / Dmabuf Device /
+Device Operation / Export}
+
+The driver sends an Export message to the device via the send
+virtqueue after populating the message as follows:
+
+\drivernormative{\paragraph}{Device Operation: Export}{Device Types /
+Dmabuf Device / Device Operation / Export}
+
+The driver MUST set \field{cmd} to VIRTIO_VDMABUF_CMD_EXPORT.
+
+The driver MUST set the first 16 bytes of \field{op} to a new unique ID.
+
+The driver MUST populate the next 20 bytes of \field{op} with valid
+meta data associated with the buffer represented by the ID.
+
+\subsubsection{Release}\label{sec:Device Types / Dmabuf Device /
+Device Operation / Release}
+
+The device sends a Release message to the driver via the recv
+virtqueue after populating the message as follows:
+

virtio-vdmabuf.tex line 120

Quoted 10 lines
virtio-vdmabuf.tex new file +10 -0
+\drivernormative{\paragraph}{Device Operation: Release}{Device Types
+/ Dmabuf Device / Device Operation / Release}
+
+The device MUST set \field{cmd} to VIRTIO_VDMABUF_CMD_RELEASE.
+
+The device MUST set the first 16 bytes of \field{op} to a valid
+unique ID that was previously shared by the driver.
+
+The device must zero out the remaining part of the message.
+

--
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux