pub struct Container { /* private fields */ }Implementations§
Source§impl Container
impl Container
pub fn new() -> Result<Self>
pub fn set_iommu(&self, iommu: IommuType) -> Result<()>
Sourcepub unsafe fn map_dma(
&self,
iova: u64,
vaddr: *const u8,
size: u64,
writable: bool,
) -> Result<()>
pub unsafe fn map_dma( &self, iova: u64, vaddr: *const u8, size: u64, writable: bool, ) -> Result<()>
Map a host virtual address range into the IOMMU for device DMA access.
iova is the IO virtual address the device will use (typically the
guest physical address). vaddr is the host virtual address backing
the memory. size is the length in bytes. All three must be
page-aligned.
Only valid when the container uses a Type1v2 IOMMU.
§Safety
vaddr must point to valid, backed memory for size bytes. The
memory must not be unmapped while the IOMMU mapping is live (until
a corresponding unmap_dma call).
Sourcepub fn unmap_dma(&self, iova: u64, size: u64) -> Result<()>
pub fn unmap_dma(&self, iova: u64, size: u64) -> Result<()>
Unmap a previously mapped IOVA range from the IOMMU.
For Type1v2, the unmap range must not bisect any previous mapping:
if a mapping exists at iova, it must start exactly at iova, and
if a mapping exists at iova + size - 1, it must end there.
Multiple mappings may be unmapped in one call as long as these
boundary conditions hold. Gaps within the range are fine.