CHROMIUM: vfio/type1: add memory efficient iommu type
This patch adds a VFIO_TYPE1v3_IOMMU variant to vfio type1 that is more
memory efficient for page-granular, relatively dense mappings. The new
type gives up support for more advanced vfio features (e.g. dirty bits,
mediated devices, mapping replay) and tracks metadata per-page instead
of per-mapping. This allows tracking of only 2 bits per page The
metadata is tracked in a sparse xarray based bitmap, which adds some
overhead. However, the worst case memory consumption is ~100KiB/1GiB,
versus ~20MiB/GiB for existing implementations.
The reduction in memory overhead is particularly important for coiommu,
which may end up doing per-page pinning for a large fraction of the
guest's memory due to lazy unpinning. It is also nice-to-have for
virtio-iommu, although virtio-iommu generally won't simultaneously pin
too many pages at any given point in time.
This VFIO IOMMU feature is not something that upstream will take -
rather the support should be added as part of the ongoing iommufd
project. However, that project is still at a relatively early stage, so
it will not be ready in the near to mid-term. For ManaTEE's timeline, we
need a CHROMIUM solution.
BUG=b:217479627
TEST=Boot volteer-manatee with virtio-iommu
Signed-off-by: David Stevens <stevensd@chromium.org>
Change-Id: Idec66a02cc19fffe2c5e497183e49a901e08e417
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3593528
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
1 file changed