>> +void s390_pci_iommu_dm_enable(S390PCIIOMMU *iommu) >> +{ >> + MachineState *ms = MACHINE(qdev_get_machine()); >> + S390CcwMachineState *s390ms = S390_CCW_MACHINE(ms); >> + >> + /* >> + * For direct-mapping we must map the entire guest address space. >> Rather >> + * than using an iommu, create a memory region alias that maps GPA X to >> + * iova X + SDMA. VFIO will handle pinning via its memory listener. >> + */ >> + g_autofree char *name = g_strdup_printf("iommu-dm-s390-%04x", >> + iommu->pbdev->uid); >> + memory_region_init_alias(&iommu->dm_mr, OBJECT(&iommu->mr), name, >> ms->ram, >> + 0, s390_get_memory_limit(s390ms)); > > Hm, the memory limit can exceed ms->ram. > > Would it be possible to use get_system_memory() here, such that whatever is > mapped into physical address space (including virtio-mem devices etc) would > simply be aliased with an offset? > > Or does that blow up elsewhere?
Testing with memory_region_init_alias(&iommu->dm_mr, OBJECT(&iommu->mr), name, get_system_memory(), 0, s390_get_memory_limit(s390ms)); Looks good so far, will change for next version > > target/i386/kvm/kvm.c seems to do that: > > memory_region_init_alias(&smram_as_mem, OBJECT(kvm_state), "mem-smram", > get_system_memory(), 0, ~0ull); > > and target/i386/tcg/system/tcg-cpu.c >