Skip to contentSkip to conversation

xen/amd/iommu: Don't swap the IVMD read and write permissions

PATCH In review Stefano Stabellini 3 participants 3 messages Oct 20 – Oct 26

lore
Share & tools
lore
#0 lore raw

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
index 4688908824..fe3dee872c 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw

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_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 +0 -0
index 4688908824..fe3dee872c 100644

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.

Fixes e941abd7cab1 ("ACPI: eliminate duplicate IVRS definitions")

With that,

Teddy

#2 lore raw
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_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 +0 -0
index 4688908824..fe3dee872c 100644

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.

Quoted 1 line
Fixes e941abd7cab1 ("ACPI: eliminate duplicate IVRS definitions")

Argh, I did screw up there.

Quoted 2 lines

With that,

This was committed with an A-b of Roger's, but such an ack was never (publicly) provided.

Jan