[PATCH v3 14/14] intel_iommu: Expose flag VIOMMU_FLAG_PASID_SUPPORTED when configured

Zhenzhong Duan posted 14 patches 1 week, 1 day ago
[PATCH v3 14/14] intel_iommu: Expose flag VIOMMU_FLAG_PASID_SUPPORTED when configured
Posted by Zhenzhong Duan 1 week, 1 day ago
VFIO device will check flag VIOMMU_FLAG_PASID_SUPPORTED and expose PASID
capability, or else guest could not enable PASID of this device even if
vIOMMU's pasid is configured.

This is the final knob to enable PASID.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Tested-by: Xudong Hao <xudong.hao@intel.com>
---
 hw/i386/intel_iommu.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index abcb0df5d9..3cb8a547c7 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -4794,6 +4794,7 @@ static uint64_t vtd_get_viommu_flags(void *opaque)
     uint64_t flags;
 
     flags = s->fsts ? VIOMMU_FLAG_WANT_NESTING_PARENT : 0;
+    flags |= s->pasid ? VIOMMU_FLAG_PASID_SUPPORTED : 0;
 
     return flags;
 }
-- 
2.47.3
Re: [PATCH v3 14/14] intel_iommu: Expose flag VIOMMU_FLAG_PASID_SUPPORTED when configured
Posted by Cédric Le Goater 1 week, 1 day ago
On 4/3/26 05:55, Zhenzhong Duan wrote:
> VFIO device will check flag VIOMMU_FLAG_PASID_SUPPORTED and expose PASID
> capability, or else guest could not enable PASID of this device even if
> vIOMMU's pasid is configured.
> 
> This is the final knob to enable PASID.
> 
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> Tested-by: Xudong Hao <xudong.hao@intel.com>
> ---
>   hw/i386/intel_iommu.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index abcb0df5d9..3cb8a547c7 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -4794,6 +4794,7 @@ static uint64_t vtd_get_viommu_flags(void *opaque)
>       uint64_t flags;
>   
>       flags = s->fsts ? VIOMMU_FLAG_WANT_NESTING_PARENT : 0;
> +    flags |= s->pasid ? VIOMMU_FLAG_PASID_SUPPORTED : 0;

The '|=' operator is unexpected. Anyhow, the code has changed since.
Needs a rebase.

Thanks,

C.


>   
>       return flags;
>   }
RE: [PATCH v3 14/14] intel_iommu: Expose flag VIOMMU_FLAG_PASID_SUPPORTED when configured
Posted by Duan, Zhenzhong 4 days, 16 hours ago

>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Subject: Re: [PATCH v3 14/14] intel_iommu: Expose flag
>VIOMMU_FLAG_PASID_SUPPORTED when configured
>
>On 4/3/26 05:55, Zhenzhong Duan wrote:
>> VFIO device will check flag VIOMMU_FLAG_PASID_SUPPORTED and expose
>PASID
>> capability, or else guest could not enable PASID of this device even if
>> vIOMMU's pasid is configured.
>>
>> This is the final knob to enable PASID.
>>
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>> Tested-by: Xudong Hao <xudong.hao@intel.com>
>> ---
>>   hw/i386/intel_iommu.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>> index abcb0df5d9..3cb8a547c7 100644
>> --- a/hw/i386/intel_iommu.c
>> +++ b/hw/i386/intel_iommu.c
>> @@ -4794,6 +4794,7 @@ static uint64_t vtd_get_viommu_flags(void *opaque)
>>       uint64_t flags;
>>
>>       flags = s->fsts ? VIOMMU_FLAG_WANT_NESTING_PARENT : 0;
>> +    flags |= s->pasid ? VIOMMU_FLAG_PASID_SUPPORTED : 0;
>
>The '|=' operator is unexpected.

Not get, do you see any issue here?

The flags is firstly assigned to VIOMMU_FLAG_WANT_NESTING_PARENT if s->fsts=true,
Then VIOMMU_FLAG_PASID_SUPPORTED is appended if s->pasid=true.

Thanks
Zhenzhong

> Anyhow, the code has changed since.
>Needs a rebase.
>
>Thanks,
>
>C.
>
>
>>
>>       return flags;
>>   }

Re: [PATCH v3 14/14] intel_iommu: Expose flag VIOMMU_FLAG_PASID_SUPPORTED when configured
Posted by Cédric Le Goater 2 days, 6 hours ago
On 4/7/26 04:18, Duan, Zhenzhong wrote:
> 
> 
>> -----Original Message-----
>> From: Cédric Le Goater <clg@redhat.com>
>> Subject: Re: [PATCH v3 14/14] intel_iommu: Expose flag
>> VIOMMU_FLAG_PASID_SUPPORTED when configured
>>
>> On 4/3/26 05:55, Zhenzhong Duan wrote:
>>> VFIO device will check flag VIOMMU_FLAG_PASID_SUPPORTED and expose
>> PASID
>>> capability, or else guest could not enable PASID of this device even if
>>> vIOMMU's pasid is configured.
>>>
>>> This is the final knob to enable PASID.
>>>
>>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>>> Tested-by: Xudong Hao <xudong.hao@intel.com>
>>> ---
>>>    hw/i386/intel_iommu.c | 1 +
>>>    1 file changed, 1 insertion(+)
>>>
>>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>>> index abcb0df5d9..3cb8a547c7 100644
>>> --- a/hw/i386/intel_iommu.c
>>> +++ b/hw/i386/intel_iommu.c
>>> @@ -4794,6 +4794,7 @@ static uint64_t vtd_get_viommu_flags(void *opaque)
>>>        uint64_t flags;
>>>
>>>        flags = s->fsts ? VIOMMU_FLAG_WANT_NESTING_PARENT : 0;
>>> +    flags |= s->pasid ? VIOMMU_FLAG_PASID_SUPPORTED : 0;
>>
>> The '|=' operator is unexpected.
> 
> Not get, do you see any issue here?
> 
> The flags is firstly assigned to VIOMMU_FLAG_WANT_NESTING_PARENT if s->fsts=true,
> Then VIOMMU_FLAG_PASID_SUPPORTED is appended if s->pasid=true.

My eyes/brain tricked me. I was "seeing" a line removal just
above this additional line ...  sorry for the noise.

Thank,

C.