On 09/12/2024 20.29, Matthew Rosato wrote:
When receiving a guest mpcifc(4) or mpcifc(6) instruction without the T
bit set, treat this as a request to perform direct mapping instead of
address translation. In order to facilitiate this, pin the entirety of
s/facilitiate/facilitate/
guest memory into the host iommu.
...
+void s390_pci_iommu_dm_enable(S390PCIIOMMU *iommu)
+{
+ MachineState *ms = MACHINE(qdev_get_machine());
+
+ /*
+ * For direct-mapping we must map the entire guest address space. Because
+ * the mappings are contiguous we are not restricted to individual 4K
+ * mappings via vfio, so let's not worry about the DMA limit when
+ * calculating the range.
+ */
+ char *name = g_strdup_printf("iommu-s390-%04x", iommu->pbdev->uid);
FWIW, you could use g_autofree to get rid of the g_free() at the end of the
function.
+ memory_region_init_iommu(&iommu->iommu_mr, sizeof(iommu->iommu_mr),
+ TYPE_S390_IOMMU_MEMORY_REGION, OBJECT(&iommu->mr),
+ name, iommu->pba + ms->ram_size);
+ iommu->enabled = true;
+ iommu->direct_map = true;
memory_region_add_subregion(&iommu->mr, 0,
MEMORY_REGION(&iommu->iommu_mr));
g_free(name);
}
Thomas