[PATCH 2/3] transport-pci: VIRTIO_F_SHM_PAGE_SIZE support

Sergio Lopez
2025-02-17T11:52:37Z

Introduce VIRTIO_F_SHM_PAGE_SIZE support by borrowing 8 bits from the 16
bit padding in virtio_pci_cap to hold a page_shift field which can be
used to derive the page size supported by the device.

Signed-off-by: Sergio Lopez <slp@redhat.com>
---
transport-pci.tex | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/transport-pci.tex b/transport-pci.tex
index a5c6719..1b91d8a 100644
--- a/transport-pci.tex
+++ b/transport-pci.tex
@@ -147,7 +147,8 @@ \subsection{Virtio Structure PCI Capabilities}\label{sec:Virtio Transport Option
u8 cfg_type; /* Identifies the structure. */
u8 bar; /* Where to find it. */
u8 id; /* Multiple capabilities of the same type */
- u8 padding[2]; /* Pad to full dword. */
+ u8 page_shift; /* Page shift for this shared memory region. */
+ u8 padding[1]; /* Pad to full dword. */
le32 offset; /* Offset within bar. */
le32 length; /* Length of the structure, in bytes. */
};
@@ -222,6 +223,13 @@ \subsection{Virtio Structure PCI Capabilities}\label{sec:Virtio Transport Option
of a certain type. If the device type does not specify the meaning of
this field, its contents are undefined.

+\item[\field{page_shift}]
+ If VIRTIO_F_SHM_PAGE_SIZE has been negotiated and \field{cfg_type} is set
+ to VIRTIO_PCI_CAP_SHARED_MEMORY_CFG, the device MUST provide the page
+ shift derived from the supported page size for this shared memory region.
+ The page shift is derived from the page size by using this formula:
+ $page size = 1 << (page shift + 12)$.
+ See also \ref {sec:Basic Facilities of a Virtio Device / Shared Memory Regions / Page alignment restrictions}.

\item[\field{offset}]
indicates where the structure begins relative to the base address associated
--
2.48.1