>>> +{
>>> + MachineState *ms = MACHINE(qdev_get_machine());
>>> +
>>> + /*
>>> + * 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, ms->ram_size);
>>
>> Is it a good idea to take the whole machine ram-size here?
>> Could it be better to pass it as qdev property?
>
> I think we want all guest RAM, just like ordinary vfio on !s390x without a
> viommu would do.
>
> Matthew, I assume to handle virtio-mem, we would actually pass in here the
> result from s390_get_memory_limit(), which will cover initial+device RAM,
> correct? Until then, this would map initial RAM only.
>
Good point. Using s390_get_memory_limit() sounds good to me; That will make v3
of this series dependent on the s390x virtio-mem series but sounds like you're
sending that sometime this week anyway.
I'll start testing on top of that with something like..
memory_region_init_alias(&iommu->dm_mr, OBJECT(&iommu->mr), name, ms->ram,
0, s390_get_memory_limit(s390ms));