Hi,

On 7/16/25 7:45 PM, Jason Gunthorpe wrote:
> On Wed, Jul 16, 2025 at 10:35:25AM -0700, Nicolin Chen wrote:
>> On Wed, Jul 16, 2025 at 08:51:23AM -0300, Jason Gunthorpe wrote:
>>> On Tue, Jul 15, 2025 at 07:57:57PM -0700, Nicolin Chen wrote:
>>>>> +    val = FIELD_EX32(s_accel->info.idr[5], IDR5, GRAN4K);
>>>>> +    if (val < FIELD_EX32(s->idr[5], IDR5, GRAN4K)) {
>>>>> +        s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN4K, val);
>>>>> +    }
>>>>> +    val = FIELD_EX32(s_accel->info.idr[5], IDR5, GRAN16K);
>>>>> +    if (val < FIELD_EX32(s->idr[5], IDR5, GRAN16K)) {
>>>>> +        s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN16K, val);
>>>>> +    }
>>>>> +    val = FIELD_EX32(s_accel->info.idr[5], IDR5, GRAN64K);
>>>>> +    if (val < FIELD_EX32(s->idr[5], IDR5, GRAN64K)) {
>>>>> +        s->idr[5] = FIELD_DP32(s->idr[5], IDR5, GRAN64K, val);
>>>> Unless there is some conflicts between the QEMU emulation and the
>>>> SMMU HW, I think we should probably just override these fields to
>>>> the HW values,
>>> The qemu model should be fully independent of the underlying HW, it
>>> should not override from HW.
>>>
>>> It should check if the underlying supports the model and fail if it
>>> doesn't.
>> For every bit? If there is a conflict at a certain field (e.g.
>> VMM only supports little endian while HW supports big endian),
>> it must fail.
> Yes every bit.
>
>> But here, I mean for these specific fields such as GRANxK and
>> RIL (range-based invalidation), we should override them with
>> the HW values. Otherwise, the guest OS seeing RIL for example
>> will issue TLBI commands that the host can't support. Right?
> No.
>
> If the SMMU model does not include RIL then RIL is not available to
> the guest.

For virtio-iommu several parameters are dynamically computed: the pgsize
mask, the aw (using ReservedRegion info). They are computed according to
the assigned device requirements, if not conflicting with anything else.

For instance you can have a look at 5c3cfe33f418 ("virtio-iommu: Set
supported page size mask"). I don't quite remember but intel-iommu might
also have such dynamic settings depending on the host.

However I am unsure we enforce the computed granule/aw on dest (VFIO mig
was not supported when the feature were implemented). as this is part of
the device config it may be but it would be worth to check.

Thanks

Eric
>
> If the SMMU model only supports GRAN4K, then the guest only uses 4k.
>
> This exactness is critical for live migration. We cannot have the IDRs
> change during live migration.
>
> So there should be some built in models in qemu that define exactly
> what kind of SMMU you get, and things like if 4k/16k/64k or RIL are
> included in that model or not should be command line parameters/etc
> like everything else in qemu..
>
> Jason
>


Reply via email to