Skip to content

Commit 87210b1

Browse files
nicolincjgunthorpe
authored andcommitted
Documentation: userspace-api: iommufd: Update vIOMMU
With the introduction of the new object and its infrastructure, update the doc to reflect that and add a new graph. Link: https://patch.msgid.link/r/7e4302064e0d02137c1b1e139342affc0485ed3f.1730836219.git.nicolinc@nvidia.com Reviewed-by: Jason Gunthorpe <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Signed-off-by: Nicolin Chen <[email protected]> Reviewed-by: Bagas Sanjaya <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 7156cd9 commit 87210b1

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

Documentation/userspace-api/iommufd.rst

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,39 @@ Following IOMMUFD objects are exposed to userspace:
6363
space usually has mappings from guest-level I/O virtual addresses to guest-
6464
level physical addresses.
6565

66+
- IOMMUFD_OBJ_VIOMMU, representing a slice of the physical IOMMU instance,
67+
passed to or shared with a VM. It may be some HW-accelerated virtualization
68+
features and some SW resources used by the VM. For examples:
69+
70+
* Security namespace for guest owned ID, e.g. guest-controlled cache tags
71+
* Non-device-affiliated event reporting, e.g. invalidation queue errors
72+
* Access to a sharable nesting parent pagetable across physical IOMMUs
73+
* Virtualization of various platforms IDs, e.g. RIDs and others
74+
* Delivery of paravirtualized invalidation
75+
* Direct assigned invalidation queues
76+
* Direct assigned interrupts
77+
78+
Such a vIOMMU object generally has the access to a nesting parent pagetable
79+
to support some HW-accelerated virtualization features. So, a vIOMMU object
80+
must be created given a nesting parent HWPT_PAGING object, and then it would
81+
encapsulate that HWPT_PAGING object. Therefore, a vIOMMU object can be used
82+
to allocate an HWPT_NESTED object in place of the encapsulated HWPT_PAGING.
83+
84+
.. note::
85+
86+
The name "vIOMMU" isn't necessarily identical to a virtualized IOMMU in a
87+
VM. A VM can have one giant virtualized IOMMU running on a machine having
88+
multiple physical IOMMUs, in which case the VMM will dispatch the requests
89+
or configurations from this single virtualized IOMMU instance to multiple
90+
vIOMMU objects created for individual slices of different physical IOMMUs.
91+
In other words, a vIOMMU object is always a representation of one physical
92+
IOMMU, not necessarily of a virtualized IOMMU. For VMMs that want the full
93+
virtualization features from physical IOMMUs, it is suggested to build the
94+
same number of virtualized IOMMUs as the number of physical IOMMUs, so the
95+
passed-through devices would be connected to their own virtualized IOMMUs
96+
backed by corresponding vIOMMU objects, in which case a guest OS would do
97+
the "dispatch" naturally instead of VMM trappings.
98+
6699
All user-visible objects are destroyed via the IOMMU_DESTROY uAPI.
67100

68101
The diagrams below show relationships between user-visible objects and kernel
@@ -101,6 +134,28 @@ creating the objects and links::
101134
|------------>|iommu_domain|<----|iommu_domain|<----|device|
102135
|____________| |____________| |______|
103136

137+
_______________________________________________________________________
138+
| iommufd (with vIOMMU) |
139+
| |
140+
| [5] |
141+
| _____________ |
142+
| | | |
143+
| |----------------| vIOMMU | |
144+
| | | | |
145+
| | | | |
146+
| | [1] | | [4] [2] |
147+
| | ______ | | _____________ ________ |
148+
| | | | | [3] | | | | | |
149+
| | | IOAS |<---|(HWPT_PAGING)|<---| HWPT_NESTED |<--| DEVICE | |
150+
| | |______| |_____________| |_____________| |________| |
151+
| | | | | | |
152+
|______|________|______________|__________________|_______________|_____|
153+
| | | | |
154+
______v_____ | ______v_____ ______v_____ ___v__
155+
| struct | | PFN | (paging) | | (nested) | |struct|
156+
|iommu_device| |------>|iommu_domain|<----|iommu_domain|<----|device|
157+
|____________| storage|____________| |____________| |______|
158+
104159
1. IOMMUFD_OBJ_IOAS is created via the IOMMU_IOAS_ALLOC uAPI. An iommufd can
105160
hold multiple IOAS objects. IOAS is the most generic object and does not
106161
expose interfaces that are specific to single IOMMU drivers. All operations
@@ -132,7 +187,8 @@ creating the objects and links::
132187
flag is set.
133188

134189
4. IOMMUFD_OBJ_HWPT_NESTED can be only manually created via the IOMMU_HWPT_ALLOC
135-
uAPI, provided an hwpt_id via @pt_id to associate the new HWPT_NESTED object
190+
uAPI, provided an hwpt_id or a viommu_id of a vIOMMU object encapsulating a
191+
nesting parent HWPT_PAGING via @pt_id to associate the new HWPT_NESTED object
136192
to the corresponding HWPT_PAGING object. The associating HWPT_PAGING object
137193
must be a nesting parent manually allocated via the same uAPI previously with
138194
an IOMMU_HWPT_ALLOC_NEST_PARENT flag, otherwise the allocation will fail. The
@@ -149,6 +205,18 @@ creating the objects and links::
149205
created via the same IOMMU_HWPT_ALLOC uAPI. The difference is at the type
150206
of the object passed in via the @pt_id field of struct iommufd_hwpt_alloc.
151207

208+
5. IOMMUFD_OBJ_VIOMMU can be only manually created via the IOMMU_VIOMMU_ALLOC
209+
uAPI, provided a dev_id (for the device's physical IOMMU to back the vIOMMU)
210+
and an hwpt_id (to associate the vIOMMU to a nesting parent HWPT_PAGING). The
211+
iommufd core will link the vIOMMU object to the struct iommu_device that the
212+
struct device is behind. And an IOMMU driver can implement a viommu_alloc op
213+
to allocate its own vIOMMU data structure embedding the core-level structure
214+
iommufd_viommu and some driver-specific data. If necessary, the driver can
215+
also configure its HW virtualization feature for that vIOMMU (and thus for
216+
the VM). Successful completion of this operation sets up the linkages between
217+
the vIOMMU object and the HWPT_PAGING, then this vIOMMU object can be used
218+
as a nesting parent object to allocate an HWPT_NESTED object described above.
219+
152220
A device can only bind to an iommufd due to DMA ownership claim and attach to at
153221
most one IOAS object (no support of PASID yet).
154222

@@ -161,6 +229,7 @@ User visible objects are backed by following datastructures:
161229
- iommufd_device for IOMMUFD_OBJ_DEVICE.
162230
- iommufd_hwpt_paging for IOMMUFD_OBJ_HWPT_PAGING.
163231
- iommufd_hwpt_nested for IOMMUFD_OBJ_HWPT_NESTED.
232+
- iommufd_viommu for IOMMUFD_OBJ_VIOMMU.
164233

165234
Several terminologies when looking at these datastructures:
166235

0 commit comments

Comments
 (0)