[PATCH intel_iommu 3/7] intel_iommu: make types match

CLEMENT MATHIEU--DRIF posted 7 patches 1 year, 9 months ago
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>, Jason Wang <jasowang@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
[PATCH intel_iommu 3/7] intel_iommu: make types match
Posted by CLEMENT MATHIEU--DRIF 1 year, 9 months ago
The 'level' field in vtd_iotlb_key is an uint8_t.
We don't need to store level as an int in vtd_lookup_iotlb

Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
---
 hw/i386/intel_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 6f1364b3fd..ba545590b1 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -333,7 +333,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
 {
     struct vtd_iotlb_key key;
     VTDIOTLBEntry *entry;
-    int level;
+    uint8_t level;
 
     for (level = VTD_SL_PT_LEVEL; level < VTD_SL_PML4_LEVEL; level++) {
         key.gfn = vtd_get_iotlb_gfn(addr, level);
-- 
2.44.0
Re: [PATCH intel_iommu 3/7] intel_iommu: make types match
Posted by Philippe Mathieu-Daudé 1 year, 9 months ago
On 22/4/24 17:52, CLEMENT MATHIEU--DRIF wrote:
> The 'level' field in vtd_iotlb_key is an uint8_t.
> We don't need to store level as an int in vtd_lookup_iotlb
> 
> Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
> ---
>   hw/i386/intel_iommu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index 6f1364b3fd..ba545590b1 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -333,7 +333,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
>   {
>       struct vtd_iotlb_key key;
>       VTDIOTLBEntry *entry;
> -    int level;
> +    uint8_t level;

Or simply 'unsigned' up to vtd_slpt_level_shift()?


Re: [PATCH intel_iommu 3/7] intel_iommu: make types match
Posted by CLEMENT MATHIEU--DRIF 1 year, 9 months ago
On 22/04/2024 19:03, Philippe Mathieu-Daudé wrote:
> On 22/4/24 17:52, CLEMENT MATHIEU--DRIF wrote:
>> The 'level' field in vtd_iotlb_key is an uint8_t.
>> We don't need to store level as an int in vtd_lookup_iotlb
>>
>> Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
>> ---
>>   hw/i386/intel_iommu.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>> index 6f1364b3fd..ba545590b1 100644
>> --- a/hw/i386/intel_iommu.c
>> +++ b/hw/i386/intel_iommu.c
>> @@ -333,7 +333,7 @@ static VTDIOTLBEntry 
>> *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
>>   {
>>       struct vtd_iotlb_key key;
>>       VTDIOTLBEntry *entry;
>> -    int level;
>> +    uint8_t level;
>
> Or simply 'unsigned' up to vtd_slpt_level_shift()?
vtd_iotlb_key.level is an uint8_t, just avoiding a warning here
Re: [PATCH intel_iommu 3/7] intel_iommu: make types match
Posted by Philippe Mathieu-Daudé 1 year, 9 months ago
On 23/4/24 07:05, CLEMENT MATHIEU--DRIF wrote:
> 
> On 22/04/2024 19:03, Philippe Mathieu-Daudé wrote:
>> On 22/4/24 17:52, CLEMENT MATHIEU--DRIF wrote:
>>> The 'level' field in vtd_iotlb_key is an uint8_t.
>>> We don't need to store level as an int in vtd_lookup_iotlb
>>>
>>> Signed-off-by: Clément Mathieu--Drif <clement.mathieu--drif@eviden.com>
>>> ---
>>>    hw/i386/intel_iommu.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>>> index 6f1364b3fd..ba545590b1 100644
>>> --- a/hw/i386/intel_iommu.c
>>> +++ b/hw/i386/intel_iommu.c
>>> @@ -333,7 +333,7 @@ static VTDIOTLBEntry
>>> *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
>>>    {
>>>        struct vtd_iotlb_key key;
>>>        VTDIOTLBEntry *entry;
>>> -    int level;
>>> +    uint8_t level;
>>
>> Or simply 'unsigned' up to vtd_slpt_level_shift()?
> vtd_iotlb_key.level is an uint8_t, just avoiding a warning here

What warning?

Re: [PATCH intel_iommu 3/7] intel_iommu: make types match
Posted by CLEMENT MATHIEU--DRIF 1 year, 9 months ago
On 23/04/2024 10:19, Philippe Mathieu-Daudé wrote:
>
> On 23/4/24 07:05, CLEMENT MATHIEU--DRIF wrote:
>>
>> On 22/04/2024 19:03, Philippe Mathieu-Daudé wrote:
>>> On 22/4/24 17:52, CLEMENT MATHIEU--DRIF wrote:
>>>> The 'level' field in vtd_iotlb_key is an uint8_t.
>>>> We don't need to store level as an int in vtd_lookup_iotlb
>>>>
>>>> Signed-off-by: Clément Mathieu--Drif 
>>>> <clement.mathieu--drif@eviden.com>
>>>> ---
>>>>    hw/i386/intel_iommu.c | 2 +-
>>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
>>>> index 6f1364b3fd..ba545590b1 100644
>>>> --- a/hw/i386/intel_iommu.c
>>>> +++ b/hw/i386/intel_iommu.c
>>>> @@ -333,7 +333,7 @@ static VTDIOTLBEntry
>>>> *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id,
>>>>    {
>>>>        struct vtd_iotlb_key key;
>>>>        VTDIOTLBEntry *entry;
>>>> -    int level;
>>>> +    uint8_t level;
>>>
>>> Or simply 'unsigned' up to vtd_slpt_level_shift()?
>> vtd_iotlb_key.level is an uint8_t, just avoiding a warning here
>
> What warning?
A linter warning, but it's not a big deal in our case because we know 
the value is lower than 5