[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210831025923.15812-4-nicolinc@nvidia.com>
Date: Mon, 30 Aug 2021 19:59:13 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: <will@...nel.org>, <robin.murphy@....com>, <joro@...tes.org>,
<alex.williamson@...hat.com>, <cohuck@...hat.com>, <corbet@....net>
CC: <nicoleotsuka@...il.com>, <vdumpa@...dia.com>,
<thierry.reding@...il.com>, <linux-tegra@...r.kernel.org>,
<nwatterson@...dia.com>, <Jonathan.Cameron@...wei.com>,
<jean-philippe@...aro.org>, <song.bao.hua@...ilicon.com>,
<eric.auger@...hat.com>, <thunder.leizhen@...wei.com>,
<yuzenghui@...wei.com>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<iommu@...ts.linux-foundation.org>, <kvm@...r.kernel.org>,
<linux-doc@...r.kernel.org>
Subject: [RFC][PATCH v2 03/13] vfio: Document VMID control for IOMMU Virtualization
The VFIO API was enhanced to support VMID control with two
new iotcls to set and get VMID between the kernel and the
virtual machine hypervisor. So updating the document.
Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
---
Documentation/driver-api/vfio.rst | 34 +++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/Documentation/driver-api/vfio.rst b/Documentation/driver-api/vfio.rst
index c663b6f97825..a76a17065cdd 100644
--- a/Documentation/driver-api/vfio.rst
+++ b/Documentation/driver-api/vfio.rst
@@ -239,6 +239,40 @@ group and can access them as follows::
/* Gratuitous device reset and go... */
ioctl(device, VFIO_DEVICE_RESET);
+IOMMU Virtual Machine Identifier (VMID)
+------------------------
+In case of virtualization, each VM is assigned a Virtual Machine Identifier
+(VMID). This VMID is used to tag translation lookaside buffer (TLB) entries,
+to identify which VM each entry belongs to. This tagging allows translations
+for multiple different VMs to be present in the TLBs at the same time.
+
+The IOMMU Kernel driver is responsible for allocating a VMID. However, only
+a hypervisor knows what physical devices get assigned to the same VM. Thus,
+when the first physical device gets assigned to the VM, once the hypervisor
+finishes its IOCTL call of VFIO_SET_IOMMU, it should call the following:
+
+struct vm {
+ int iommu_type;
+ uint32_t vmid; /* initial value is VFIO_IOMMU_VMID_INVALID */
+} vm0;
+
+ /* ... */
+ ioctl(container->fd, VFIO_SET_IOMMU, vm0->iommu_type);
+ /* ... */
+ if (vm0->vmid == VFIO_IOMMU_VMID_INVALID)
+ ioctl(container->fd, VFIO_IOMMU_GET_VMID, &vm0->vmid);
+
+This VMID would be the shared value, across the entire VM, between all the
+physical devices that are assigned to it. So, when other physical devices
+get assigned to the VM, before the hypervisor runs into the IOCTL call of
+VFIO_IOMMU_SET_VMID, it should call the following:
+
+ /* ... */
+ ioctl(container->fd, VFIO_SET_IOMMU, vm0->iommu_type);
+ /* ... */
+ if (vm0->vmid != VFIO_IOMMU_VMID_INVALID)
+ ioctl(container->fd, VFIO_IOMMU_SET_VMID, vmid);
+
VFIO User API
-------------------------------------------------------------------------------
--
2.17.1
Powered by blists - more mailing lists