iommu/amd: Fix "Guest Virtual APIC Table Root Pointer" configuration in IRTE
Subsystems (2)
PATCH 1/1 iommu/amd: Fix "Guest Virtual APIC Table Root Pointer" configuration in IRTE
commit b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activation code") while refactoring guest virtual APIC activation/de-activation code, stored information for activate/de-activate in "struct amd_ir_data". It used 32-bit integer data type for storing the "Guest Virtual APIC Table Root Pointer" (ga_root_ptr), though the "ga_root_ptr" is actually a 40-bit field in IRTE (Interrupt Remapping Table Entry).
This causes interrupts from PCIe devices to not reach the guest in the case of PCIe passthrough with SME (Secure Memory Encryption) enabled as _SME_ bit in the "ga_root_ptr" is lost before writing it to the IRTE.
Fix it by using 64-bit data type for storing the "ga_root_ptr".
--- drivers/iommu/amd/amd_iommu_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/amd/amd_iommu_types.h +1 -1
@@ -1001,7 +1001,7 @@ struct amd_ir_data {*/ struct irq_cfg *cfg;int ga_vector; -int ga_root_ptr; +u64 ga_root_ptr;int ga_tag; };
Signature · 1 line
2.34.1
Suthikulpanit, Suravee
reviewerKishon,
Quoted 12 lines · Kishon Vijay Abraham I
commit
b9c6ff94e43a("iommu/amd: Re-factor guest virtual APIC (de-)activation code") while refactoring guest virtual APIC activation/de-activation code, stored information for activate/de-activate in "structamd_ir_data". It used 32-bit integer data type for storing the "Guest Virtual APIC Table Root Pointer" (ga_root_ptr), though the "ga_root_ptr" is actually a 40-bit field in IRTE (Interrupt Remapping Table Entry).This causes interrupts from PCIe devices to not reach the guest in the case of PCIe passthrough with SME (Secure Memory Encryption) enabled as _SME_ bit in the "
ga_root_ptr" is lost before writing it to the IRTE.
Quoted 6 lines
Fix it by using 64-bit data type for storing the "
ga_root_ptr".Fixes b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activation code")Cc [email protected] # v5.4+Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>
Please also add
Thanks,
Suravee
Quoted 34 lines · Suravee
Kishon,
Quoted 12 lines · Kishon Vijay Abraham I
commit
b9c6ff94e43a("iommu/amd: Re-factor guest virtual APIC (de-)activation code") while refactoring guest virtual APIC activation/de-activation code, stored information for activate/de-activate in "structamd_ir_data". It used 32-bit integer data type for storing the "Guest Virtual APIC Table Root Pointer" (ga_root_ptr), though the "ga_root_ptr" is actually a 40-bit field in IRTE (Interrupt Remapping Table Entry).This causes interrupts from PCIe devices to not reach the guest in the case of PCIe passthrough with SME (Secure Memory Encryption) enabled as _SME_ bit in the "
ga_root_ptr" is lost before writing it to the IRTE.Quoted 7 lines
Fix it by using 64-bit data type for storing the "
ga_root_ptr".Fixes b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activationcode")
Cc [email protected] # v5.4+Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>Please also add
Reported-by Alejandro Jimenez <[email protected]>--- drivers/iommu/amd/amd_iommu_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/amd_iommu_types.h +0
-0
drivers/iommu/amd/amd_iommu_types.h struct amd_ir_data { · line 1006
Quoted 7 lines
drivers/iommu/amd/amd_iommu_types.h +1
-1@@ -1001,7 +1001,7 @@ struct amd_ir_data {*/ struct irq_cfg *cfg;int ga_vector; -int ga_root_ptr; +u64 ga_root_ptr;int ga_tag; };
Nice catch. While at it I noticed the following:
* ga_tag: The conversion of uint (in kvm as they use proper u32 for gatag) to int will miss a bit thus at least VM IDs with the msb set will be stripped from vCPU wake ups? Fortunately the 24 bits for VCPU ID wouldn't be affected. But ga_tag should probably be a u32.
* ga_vector: this in principle should be u8 per spec, maybe it is OK to stay as is to prevent compiler warnings as IOMMU intremap struct vcpu_data is using a u32.
Joao
Hi Joao,
Quoted 45 lines · Joao Martins
Quoted 34 lines · Suravee
Kishon,
Quoted 12 lines · Kishon Vijay Abraham I
commit
b9c6ff94e43a("iommu/amd: Re-factor guest virtual APIC (de-)activation code") while refactoring guest virtual APIC activation/de-activation code, stored information for activate/de-activate in "structamd_ir_data". It used 32-bit integer data type for storing the "Guest Virtual APIC Table Root Pointer" (ga_root_ptr), though the "ga_root_ptr" is actually a 40-bit field in IRTE (Interrupt Remapping Table Entry).This causes interrupts from PCIe devices to not reach the guest in the case of PCIe passthrough with SME (Secure Memory Encryption) enabled as _SME_ bit in the "
ga_root_ptr" is lost before writing it to the IRTE.Quoted 7 lines
Fix it by using 64-bit data type for storing the "
ga_root_ptr".Fixes b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activationcode")
Cc [email protected] # v5.4+Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>Please also add
Reported-by Alejandro Jimenez <[email protected]>--- drivers/iommu/amd/amd_iommu_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/amd/amd_iommu_types.h +0
-0drivers/iommu/amd/amd_iommu_types.h struct amd_ir_data { · line 1006
Quoted 7 lines
drivers/iommu/amd/amd_iommu_types.h +1
-1@@ -1001,7 +1001,7 @@ struct amd_ir_data {*/ struct irq_cfg *cfg;int ga_vector; -int ga_root_ptr; +u64 ga_root_ptr;int ga_tag; };Nice catch. While at it I noticed the following:
Quoted 7 lines
*
ga_tag: The conversion of uint (in kvm as they use proper u32 for gatag) to int will miss a bit thus at least VM IDs with the msb set will be stripped from vCPU wake ups? Fortunately the 24 bits for VCPU ID wouldn't be affected. Butga_tagshould probably be a u32.*
ga_vector: this in principle should be u8 per spec, maybe it is OK to stay as is to prevent compiler warnings as IOMMU intremap structvcpu_datais using a u32.
Thank you for reviewing. Will add fix for other data types in my v2 of this patch.
Regards,
Kishon
Hi Suravee,
Quoted 17 lines · Suravee
Kishon,
Quoted 14 lines · Kishon Vijay Abraham I
commit
b9c6ff94e43a("iommu/amd: Re-factor guest virtual APIC (de-)activation code") while refactoring guest virtual APIC activation/de-activation code, stored information for activate/de-activate in "structamd_ir_data". It used 32-bit integer data type for storing the "Guest Virtual APIC Table Root Pointer" (ga_root_ptr), though the "ga_root_ptr" is actually a 40-bit field in IRTE (Interrupt Remapping Table Entry).This causes interrupts from PCIe devices to not reach the guest in the case of PCIe passthrough with SME (Secure Memory Encryption) enabled as _SME_ bit in the "
ga_root_ptr" is lost before writing it to the IRTE.Fix it by using 64-bit data type for storing the "
ga_root_ptr".
Quoted 7 lines
Quoted 4 lines
Fixes b9c6ff94e43a ("iommu/amd: Re-factor guest virtual APIC (de-)activation code")Cc [email protected] # v5.4+Reviewed-by Suravee Suthikulpanit <[email protected]>Signed-off-by Kishon Vijay Abraham I <[email protected]>Please also add
Reported-by Alejandro Jimenez <[email protected]>
sure, will add it in v2 of this patch.
Regards,
Kishon