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

Stefano Stabellini posted 1 patch 1 month ago
xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] xen/amd/iommu: Don't swap the IVMD read and write permissions
Posted by Stefano Stabellini 1 month ago
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.

Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 4688908824..fe3dee872c 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -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
     {
-- 
2.43.0
Re: [PATCH] xen/amd/iommu: Don't swap the IVMD read and write permissions
Posted by Teddy Astie 1 month ago
Le 21/10/2026 à 00:10, Stefano Stabellini a écrit :
> 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.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
> ---
>   xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
> index 4688908824..fe3dee872c 100644
> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
> @@ -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,
Reviewed-by: Teddy Astie <teddy.astie@vates.tech>

Teddy
Re: [PATCH] xen/amd/iommu: Don't swap the IVMD read and write permissions
Posted by Jan Beulich 4 weeks ago
On 21.10.2026 10:36, Teddy Astie wrote:
> Le 21/10/2026 à 00:10, Stefano Stabellini a écrit :
>> 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.
>>
>> Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
>> ---
>>   xen/drivers/passthrough/amd/iommu_acpi.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
>> index 4688908824..fe3dee872c 100644
>> --- a/xen/drivers/passthrough/amd/iommu_acpi.c
>> +++ b/xen/drivers/passthrough/amd/iommu_acpi.c
>> @@ -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")

Argh, I did screw up there.

> With that,
> Reviewed-by: Teddy Astie <teddy.astie@vates.tech>

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

Jan