amd-vi: ATS fix and SUPPORT.md update
cover amd-vi: ATS fix and SUPPORT.md update
Fix a AMD IOMMU bug in ATS and update SUPPORT.md to state ATS is out of scope.
Jason Andryuk (1):
SUPPORT.md: State that ATS is unsupported
Stefano Stabellini (1):
amd-vi: set the size flag in the IOTLB page invalidation command
SUPPORT.md | 3 +++ xen/drivers/passthrough/amd/iommu_cmd.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.56.0
PATCH 1/2 amd-vi: set the size flag in the IOTLB page invalidation command
From: Stefano Stabellini <[email protected]>
The S bit of an INVALIDATE_IOTLB_PAGES command selects between the two sizes the command can name: cleared, the invalidation covers 4 Kbytes; set, it covers the range encoded by the first zero bit of the address, counting from bit 12. invalidate_iotlb_pages() builds that encoding whenever it is given a non-zero order or the all-pages address, and then passes the field's mask where set_field_in_reg_u32() expects the shift. The correct mask is 1 and the shift is 0. When mask (1) is passed for both, the value is shifted out of the field it was to occupy and the bit is left clear. i.e. (x << 1) & 1 is always 0.
An endpoint holding translations of its own is therefore told to drop one page where it should have dropped a range. The rest of the range is kept in its cache after the page tables backing it have changed.
Pass the shift, as the sibling INVALIDATE_IOMMU_PAGES builder does.
---
This was submitted to the security list, but it is out of scope. Xenia reviewed internally and Jan reviewed from the security list.
xen/drivers/passthrough/amd/iommu_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/amd/iommu_cmd.c +1 -1
@@ -212,7 +212,7 @@ static void invalidate_iotlb_pages(struct amd_iommu *iommu,set_field_in_reg_u32 (sflag,0 ,IOMMU_INV_IOTLB_PAGES_S_FLAG_MASK , -IOMMU_INV_IOTLB_PAGES_S_FLAG_MASK , &entry); +IOMMU_INV_IOTLB_PAGES_S_FLAG_SHIFT , &entry); set_field_in_reg_u32((u32)addr_lo >> PAGE_SHIFT, entry, IOMMU_INV_IOTLB_PAGES_ADDR_LOW_MASK,
Signature · 1 line
2.56.0
Re: [PATCH 1/2] amd-vi: set the size flag in the IOTLB page invalidation command
Quoted 35 lines · Jason Andryuk
From: Stefano Stabellini <[email protected]>
The S bit of an
INVALIDATE_IOTLB_PAGEScommand selects between the two sizes the command can name: cleared, the invalidation covers 4 Kbytes; set, it covers the range encoded by the first zero bit of the address, counting from bit 12.invalidate_iotlb_pages()builds that encoding whenever it is given a non-zero order or the all-pages address, and then passes the field's mask whereset_field_in_reg_u32()expects the shift. The correct mask is 1 and the shift is 0. When mask (1) is passed for both, the value is shifted out of the field it was to occupy and the bit is left clear. i.e. (x << 1) & 1 is always 0.An endpoint holding translations of its own is therefore told to drop one page where it should have dropped a range. The rest of the range is kept in its cache after the page tables backing it have changed.
Pass the shift, as the sibling
INVALIDATE_IOMMU_PAGESbuilder does.Signed-off-by Stefano Stabellini <[email protected]>Reviewed-by Xenia Ragiadakou <[email protected]>[ Reword commit message. ]Signed-off-by Jason Andryuk <[email protected]>Reviewed-by Jan Beulich <[email protected]>---
This was submitted to the security list, but it is out of scope. Xenia reviewed internally and Jan reviewed from the security list.xen/drivers/passthrough/amd/iommu_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/drivers/passthrough/amd/iommu_cmd.c +0
-0
xen/drivers/passthrough/amd/iommu_cmd.c static void invalidate_iotlb_pages(struct amd_iommu *iommu, · line 218
Quoted 8 lines
xen/drivers/passthrough/amd/iommu_cmd.c +1
-1@@ -212,7 +212,7 @@ static void invalidate_iotlb_pages(struct amd_iommu *iommu,set_field_in_reg_u32 (sflag,0 ,IOMMU_INV_IOTLB_PAGES_S_FLAG_MASK , -IOMMU_INV_IOTLB_PAGES_S_FLAG_MASK , &entry); +IOMMU_INV_IOTLB_PAGES_S_FLAG_SHIFT , &entry); set_field_in_reg_u32((u32)addr_lo >> PAGE_SHIFT, entry, IOMMU_INV_IOTLB_PAGES_ADDR_LOW_MASK,
As said on the security list, this is probably fine for a fix wanting backporting, but can we please purge the use of set_field_in_reg_u32() entirely.
It is horrible for code legibility and generated code, and very fragile for mistakes such as this.
~Andrew
PATCH 2/2 SUPPORT.md: State that ATS is unsupported
In reply to Jason AndryukThe command line documentation specifies that ATS is unsafe. Make it explicitly unsupported in SUPPORT.md as well.
--- SUPPORT.md | 3 +++ 1 file changed, 3 insertions(+)
SUPPORT.md +3 -0
@@ -96,6 +96,9 @@ For the Cortex A77 r0p0 - r1p0, see Errata 1508412. Status, ARM SMMUv3: Tech Preview Status, Renesas IPMMU-VMSA: Supported, not security supported +PCI Address Translation Services (ATS), enabled by the ats= command line +option, is not security supported. + ### ARM/GICv3 GICv3 is an interrupt controller specification designed by Arm.
Signature · 1 line
2.56.0
Re: [PATCH 2/2] SUPPORT.md: State that ATS is unsupported
SUPPORT.md For the Cortex A77 r0p0 - r1p0, see Errata 1508412. · line 104
Quoted 12 lines · Jason Andryuk
SUPPORT.md +3
-0@@ -96,6 +96,9 @@ For the Cortex A77 r0p0 - r1p0, see Errata 1508412. Status, ARM SMMUv3: Tech Preview Status, Renesas IPMMU-VMSA: Supported, not security supported +PCI Address Translation Services (ATS), enabled by the ats= command line +option, is not security supported. + ### ARM/GICv3 GICv3 is an interrupt controller specification designed by Arm.
Wouldn't this better go in the "x86/PCI Device Passthrough" section?
Jan
Re: [PATCH 2/2] SUPPORT.md: State that ATS is unsupported
Quoted 7 lines · Jan Beulich
Quoted 6 lines · Jason Andryuk
SUPPORT.md +0
-0@@ -96,6 +96,9 @@ For the Cortex A77 r0p0 - r1p0, see Errata 1508412. Status, ARM SMMUv3: Tech Preview Status, Renesas IPMMU-VMSA: Supported, not security supported
Quoted 8 lines
SUPPORT.md For the Cortex A77 r0p0 - r1p0, see Errata 1508412. · line 104
Quoted 6 lines
SUPPORT.md +3
-0+PCI Address Translation Services (ATS), enabled by the ats= command line +option, is not security supported. + ### ARM/GICv3 GICv3 is an interrupt controller specification designed by Arm.Wouldn't this better go in the "x86/PCI Device Passthrough" section?
I guess I thought of ATS as more of an IOMMU feature, but PCI is in the name. I'm happy to move it.
Thanks,
Jason
Re: [PATCH 2/2] SUPPORT.md: State that ATS is unsupported
Quoted 13 lines · Jason Andryuk
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Jason Andryuk
SUPPORT.md +3
-0@@ -96,6 +96,9 @@ For the Cortex A77 r0p0 - r1p0, see Errata 1508412. Status, ARM SMMUv3: Tech Preview Status, Renesas IPMMU-VMSA: Supported, not security supported +PCI Address Translation Services (ATS), enabled by the ats= command line +option, is not security supported. + ### ARM/GICv3
Quoted 6 lines
Quoted 3 lines
SUPPORT.md For the Cortex A77 r0p0 - r1p0, see Errata 1508412. · line 104
Quoted 1 line
SUPPORT.md +0
-0GICv3 is an interrupt controller specification designed by Arm.Wouldn't this better go in the "x86/PCI Device Passthrough" section?
I guess I thought of ATS as more of an IOMMU feature, but PCI is in the name. I'm happy to move it.
I wonder what others think; it's certainly not clear cut.
Jan