VT-d minor fixes
v3 cover VT-d minor fixes
From: Clément Mathieu--Drif <[email protected]>
Various fixes for VT-d
This series contains fixes that will be necessary when adding in-guest (fully emulated) SVM support.
v3
FRCD construction macro :
- Longer sha1 for the 'Fixes' tag
- Add '.' at the end of the sentence
Make types match :
- Split into 2 patches (one for the fix and one for type matching)
Remove patch for wait descriptor handling (will be in the PRI series)
v2
Make commit author consistent
Clément Mathieu--Drif (3):
intel_iommu: fix FRCD construction macro.
intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
intel_iommu: make types match
hw/i386/intel_iommu.c | 2 +- hw/i386/intel_iommu_internal.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.45.2
PATCH v3 1/3 intel_iommu: fix FRCD construction macro.
From: Clément Mathieu--Drif <[email protected]>
The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present.
--- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu_internal.h +1 -1
@@ -267,7 +267,7 @@/* For the low 64-bit of 128-bit */ #define VTD_FRCD_FI (val) ((val) & ~0xfffULL)#define VTD_FRCD_PV (val) (((val) & 0xffffULL) << 40) -#define VTD_FRCD_PP (val) (((val) & 0x1) << 31) +#define VTD_FRCD_PP (val) (((val) & 0x1ULL) << 31)#define VTD_FRCD_IR_IDX (val) (((val) & 0xffffULL) << 48)/* DMA Remapping Fault Conditions */
Signature · 1 line
2.45.2
RE: [PATCH v3 1/3] intel_iommu: fix FRCD construction macro.
Quoted 25 lines
-----Original Message-----
From: CLEMENT MATHIEU--DRIF <[email protected]>
Subject: [PATCH v3 1/3]intel_iommu: fix FRCD construction macro.From: Clément Mathieu--Drif <[email protected]>
The constant must be unsigned, otherwise the two's complement overrides the other fields when a PASID is present.
Fixes 1b2b12376c8a ("intel-iommu: PASID support")Signed-off-by Clément Mathieu--Drif <[email protected]>Reviewed-by Yi Liu <[email protected]>---
hw/i386/intel_iommu_internal.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/intel_iommu_internal.h +0
-0
hw/i386/intel_iommu_internal.h line 270
Quoted 5 lines
hw/i386/intel_iommu_internal.h +1
-1@@ -267,7 +267,7 @@/* For the low 64-bit of 128-bit */ #define VTD_FRCD_FI (val) ((val) & ~0xfffULL)#define VTD_FRCD_PV (val) (((val) & 0xffffULL) << 40) -#define VTD_FRCD_PP (val) (((val) & 0x1) << 31) +#define VTD_FRCD_PP (val) (((val) & 0x1ULL) << 31)
VTD_FRCD_PV and VTD_FRCD_PP are MACROs for high 64-bit. By this chance, maybe we can move them under:
/* For the high 64-bit of 128-bit */
Thanks
Zhenzhong
Quoted 5 lines
hw/i386/intel_iommu_internal.h +0
-1#define VTD_FRCD_IR_IDX (val) (((val) & 0xffffULL) << 48)/* DMA Remapping Fault Conditions */ --2.45.2
PATCH v3 2/3 intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
In reply to CLEMENT MATHIEU--DRIFFrom: Clément Mathieu--Drif <[email protected]>
VTDIOTLBPageInvInfo.mask might not fit in an uint8_t. Moreover, this field is used in binary operations with 64-bit addresses.
--- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu_internal.h +1 -1
@@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo {uint16_t domain_id;uint32_t pasid;uint64_t addr; -uint8_t mask; +uint64_t mask; };typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo ;
Signature · 1 line
2.45.2
RE: [PATCH v3 2/3] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
Quoted 7 lines
-----Original Message-----
From: CLEMENT MATHIEU--DRIF <[email protected]>
Subject: [PATCH v3 2/3]intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
Quoted 6 lines
From: Clément Mathieu--Drif <[email protected]>
VTDIOTLBPageInvInfo.mask might not fit in an
uint8_t. Moreover, this field is used in binary operations with 64-bit addresses.Signed-off-by Clément Mathieu--Drif <[email protected]>
Thanks
Zhenzhong
Quoted 20 lines
---
hw/i386/intel_iommu_internal.h| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/intel_iommu_internal.h +1
-2@@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo {uint16_t domain_id;uint32_t pasid;uint64_t addr; -uint8_t mask; +uint64_t mask; };typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo ; --2.45.2
Re: [PATCH v3 2/3] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
In reply to CLEMENT MATHIEU--DRIFQuoted 3 lines · CLEMENT MATHIEU--DRIF
From: Clément Mathieu--Drif <[email protected]>
VTDIOTLBPageInvInfo.mask might not fit in an
uint8_t.
I think what you mean is that is assigned values that might not fit .... it's u8 ATM so of course it fits.
Quoted 1 line
Moreover, this field is used in binary operations with 64-bit addresses.
So what?
Quoted 21 lines
Signed-off-by Clément Mathieu--Drif <[email protected]>--- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/intel_iommu_internal.h +1
-1@@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo {uint16_t domain_id;uint32_t pasid;uint64_t addr; -uint8_t mask; +uint64_t mask; };typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo ;Signature · 1 line
2.45.2
Re: [PATCH v3 2/3] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
On 05/07/2024 10:51, Michael S. Tsirkin wrote:
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
On Fri, Jul 05, 2024 at 05:03:17AM +0000, CLEMENT MATHIEU--DRIF wrote:
From: Clément Mathieu--Drif <[email protected]><mailto:[email protected]>
VTDIOTLBPageInvInfo.mask might not fit in an uint8_t.
I think what you mean is that is assigned values that might not fit .... it's u8 ATM so of course it fits.
What about :
"The mask stored into VTDIOTLBPageInvInfo.mask might not fit in an uint8_t. Use uint64_t to avoid overflows"
Moreover, this field is used in binary operations with 64-bit addresses.
So what?
I thing the first part of the message is enough, the issue comes from the fact that the mask does not fit into the type
--- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu_internal.h +1 -1
@@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo {uint16_t domain_id;uint32_t pasid;uint64_t addr; -uint8_t mask; +uint64_t mask; };typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo ;
--
2.45.2
Re: [PATCH v3 2/3] intel_iommu: fix type of the mask field in VTDIOTLBPageInvInfo
Quoted 11 lines · CLEMENT MATHIEU--DRIF
On 05/07/2024 10:51, Michael S. Tsirkin wrote:
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
On Fri, Jul 05, 2024 at 05:03:17AM +0000, CLEMENT MATHIEU--DRIF wrote:
From: Clément Mathieu--Drif <[email protected]>
Quoted 8 lines
VTDIOTLBPageInvInfo.mask might not fit in an
uint8_t.I think what you mean is that is assigned values that might not fit .... it's u8 ATM so of course it fits.
What about :
"The mask stored into VTDIOTLBPageInvInfo.mask might not fit in anuint8_t. Useuint64_tto avoid overflows"
No, the mask stored there is u8.
You mean "that we are trying to store into ".
Quoted 33 lines
Moreover, this field is used in binary operations with 64-bit addresses.
So what?
I thing the first part of the message is enough, the issue comes from the fact that the mask does not fit into the type
Signed-off-by: Clément Mathieu--Drif <[email protected]> --- hw/i386/intel_iommu_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/intel_iommu_internal.h b/hw/i386/intel_iommu_internal.h index cbc4030031..5fcbe2744f 100644 --- a/hw/i386/intel_iommu_internal.h +++ b/hw/i386/intel_iommu_internal.h @@ -436,7 +436,7 @@ struct VTDIOTLBPageInvInfo { uint16_t domain_id; uint32_t pasid; uint64_t addr; - uint8_t mask; + uint64_t mask; }; typedef struct VTDIOTLBPageInvInfo VTDIOTLBPageInvInfo; -- 2.45.2
PATCH v3 3/3 intel_iommu: make types match
In reply to CLEMENT MATHIEU--DRIFFrom: Clément Mathieu--Drif <[email protected]>
The 'level' field in vtd_iotlb_key is an unsigned integer. We don't need to store level as an int in vtd_lookup_iotlb.
--- hw/i386/intel_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/intel_iommu.c +1 -1
@@ -358,7 +358,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, {struct vtd_iotlb_key key;VTDIOTLBEntry *entry; -int level; +unsigned level;for (level =VTD_SL_PT_LEVEL ; level <VTD_SL_PML4_LEVEL ; level++) { key.gfn =vtd_get_iotlb_gfn (addr, level);
Signature · 1 line
2.45.2
RE: [PATCH v3 3/3] intel_iommu: make types match
Quoted 21 lines
-----Original Message-----
From: CLEMENT MATHIEU--DRIF <[email protected]>
Subject: [PATCH v3 3/3]intel_iommu: make types matchFrom: Clément Mathieu--Drif <[email protected]>
The 'level' field in
vtd_iotlb_keyis an unsigned integer. We don't need to store level as an int invtd_lookup_iotlb.Signed-off-by Clément Mathieu--Drif <[email protected]>---
hw/i386/intel_iommu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)hw/i386/intel_iommu.c +0
-0
hw/i386/intel_iommu.c static VTDIOTLBEntry · line 362
Quoted 6 lines
hw/i386/intel_iommu.c +1
-1@@ -358,7 +358,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, { struct vtd_iotlb_key key; VTDIOTLBEntry *entry; - int level; + unsigned level;
Will it bring any issue if int is used?
Quoted 5 lines
hw/i386/intel_iommu.c +0
-1for (level =VTD_SL_PT_LEVEL ; level <VTD_SL_PML4_LEVEL ; level++) { key.gfn =vtd_get_iotlb_gfn (addr, level); --2.45.2
Re: [PATCH v3 3/3] intel_iommu: make types match
Quoted 17 lines · Zhenzhong
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Quoted 14 lines
-----Original Message-----
From: CLEMENT MATHIEU--DRIF <[email protected]>
Subject: [PATCH v3 3/3]intel_iommu: make types matchFrom: Clément Mathieu--Drif <[email protected]>
The 'level' field in
vtd_iotlb_keyis an unsigned integer. We don't need to store level as an int invtd_lookup_iotlb.Signed-off-by Clément Mathieu--Drif <[email protected]>---
hw/i386/intel_iommu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines
hw/i386/intel_iommu.c static VTDIOTLBEntry · line 362
Quoted 11 lines
hw/i386/intel_iommu.c +1
-1@@ -358,7 +358,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, { struct vtd_iotlb_key key; VTDIOTLBEntry *entry; - int level; + unsigned level;Will it bring any issue if int is used?
It shouldn't, but it might trigger static analyzer warnings. Do you want me to drop the patch?
Quoted 5 lines
Quoted 5 lines
hw/i386/intel_iommu.c +0
-1for (level =VTD_SL_PT_LEVEL ; level <VTD_SL_PML4_LEVEL ; level++) { key.gfn =vtd_get_iotlb_gfn (addr, level); --2.45.2
Re: [PATCH v3 3/3] intel_iommu: make types match
Quoted 32 lines · CLEMENT MATHIEU--DRIF
Quoted 17 lines · Zhenzhong
Caution: External email. Do not open attachments or click links, unless this email comes from a known sender and you know the content is safe.
Quoted 14 lines
-----Original Message-----
From: CLEMENT MATHIEU--DRIF <[email protected]>
Subject: [PATCH v3 3/3]intel_iommu: make types matchFrom: Clément Mathieu--Drif <[email protected]>
The 'level' field in
vtd_iotlb_keyis an unsigned integer. We don't need to store level as an int invtd_lookup_iotlb.Signed-off-by Clément Mathieu--Drif <[email protected]>---
hw/i386/intel_iommu.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)Quoted 12 lines
hw/i386/intel_iommu.c static VTDIOTLBEntry · line 362
Quoted 11 lines
hw/i386/intel_iommu.c +1
-1@@ -358,7 +358,7 @@ static VTDIOTLBEntry *vtd_lookup_iotlb(IntelIOMMUState *s, uint16_t source_id, { struct vtd_iotlb_key key; VTDIOTLBEntry *entry; - int level; + unsigned level;Will it bring any issue if int is used?
Quoted 2 lines
It shouldn't, but it might trigger static analyzer warnings. Do you want me to drop the patch?
just write a better commit log.
"Not an issue by itself, but using unsigned here seems cleaner".
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
hw/i386/intel_iommu.c +0
-1for (level =VTD_SL_PT_LEVEL ; level <VTD_SL_PML4_LEVEL ; level++) { key.gfn =vtd_get_iotlb_gfn (addr, level); --2.45.2