xen/amd/iommu: Don't swap the IVMD read and write permissions
PATCH 1/1 xen/amd/iommu: Don't swap the IVMD read and write permissions
Per the IVMD Flags definition, bit 1 is IR and bit 2 is IW, matching ACPI_IVMD_READ and ACPI_IVMD_WRITE. parse_ivmd_block() takes iw from the former and ir from the latter, so a unity range firmware declares read-only is mapped write-only, and vice versa.
Ranges with both permissions, including Xen's own, are unaffected.
--- xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
xen/drivers/passthrough/amd/iommu_acpi.c +2 -2
@@ -414,8 +414,8 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block) exclusion = true; else if ( ivmd_block->header.flags & ACPI_IVMD_UNITY ) { - iw = ivmd_block->header.flags &ACPI_IVMD_READ ; - ir = ivmd_block->header.flags &ACPI_IVMD_WRITE ; + iw = ivmd_block->header.flags &ACPI_IVMD_WRITE ; + ir = ivmd_block->header.flags &ACPI_IVMD_READ ; } else {
Signature · 1 line
2.43.0
Le 21/10/2026 à 00:10, Stefano Stabellini a écrit :
Quoted 17 lines
Per the IVMD Flags definition, bit 1 is IR and bit 2 is IW, matching
ACPI_IVMD_READandACPI_IVMD_WRITE.parse_ivmd_block()takes iw from the former and ir from the latter, so a unity range firmware declares read-only is mapped write-only, and vice versa.Ranges with both permissions, including Xen's own, are unaffected.
Signed-off-by Stefano Stabellini <[email protected]>--- xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)xen/drivers/passthrough/amd/iommu_acpi.c +0
-0
xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block) · line 421
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +2
-2@@ -414,8 +414,8 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block) exclusion = true; else if ( ivmd_block->header.flags & ACPI_IVMD_UNITY ) { - iw = ivmd_block->header.flags &ACPI_IVMD_READ ; - ir = ivmd_block->header.flags &ACPI_IVMD_WRITE ; + iw = ivmd_block->header.flags &ACPI_IVMD_WRITE ; + ir = ivmd_block->header.flags &ACPI_IVMD_READ ; } else {
That probably wants a Fixes: note.
With that,
Teddy
Quoted 30 lines · Teddy Astie
Le 21/10/2026 à 00:10, Stefano Stabellini a écrit :
Quoted 17 lines
Per the IVMD Flags definition, bit 1 is IR and bit 2 is IW, matching
ACPI_IVMD_READandACPI_IVMD_WRITE.parse_ivmd_block()takes iw from the former and ir from the latter, so a unity range firmware declares read-only is mapped write-only, and vice versa.Ranges with both permissions, including Xen's own, are unaffected.
Signed-off-by Stefano Stabellini <[email protected]>--- xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)xen/drivers/passthrough/amd/iommu_acpi.c +0
-0xen/drivers/passthrough/amd/iommu_acpi.c static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block) · line 421
Quoted 10 lines
xen/drivers/passthrough/amd/iommu_acpi.c +2
-2@@ -414,8 +414,8 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block) exclusion = true; else if ( ivmd_block->header.flags & ACPI_IVMD_UNITY ) { - iw = ivmd_block->header.flags &ACPI_IVMD_READ ; - ir = ivmd_block->header.flags &ACPI_IVMD_WRITE ; + iw = ivmd_block->header.flags &ACPI_IVMD_WRITE ; + ir = ivmd_block->header.flags &ACPI_IVMD_READ ; } else {That probably wants a Fixes: note.
Quoted 1 line
Fixes e941abd7cab1 ("ACPI: eliminate duplicate IVRS definitions")
Argh, I did screw up there.
Quoted 2 lines
With that,
Reviewed-by Teddy Astie <[email protected]>
This was committed with an A-b of Roger's, but such an ack was never (publicly) provided.
Jan