Skip to contentSkip to conversation

hw/arm/smmuv3: Fix addr_mask for range-based invalidation

PATCH Applied Zenghui Yu 3 participants 3 messages Jan 30, 2021 – Feb 2, 2021

lore
Share & tools
lore

Zenghui Yu

author
#0 lore raw

PATCH v2 1/1 hw/arm/smmuv3: Fix addr_mask for range-based invalidation

When handling guest range-based IOTLB invalidation, we should decode the TG field into the corresponding translation granule size so that we can pass the correct invalidation range to backend. Set @granule to (tg * 2 + 10) to properly emulate the architecture.

Fixes d52915616c05 ("hw/arm/smmuv3: Get prepared for range invalidation")

---
* From v1:
- Fix the compilation error

 hw/arm/smmuv3.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/arm/smmuv3.c +3 -1
index bbca0e9f20..98b99d4fe8 100644
@@ -801,7 +801,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
 {
     SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
     IOMMUTLBEvent event;
-    uint8_t granule = tg;
+    uint8_t granule;
 
     if (!tg) {
         SMMUEventInfo event = {.inval_ste_allowed = true};
@@ -821,6 +821,8 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
             return;
         }
         granule = tt->granule_sz;
+    } else {
+        granule = tg * 2 + 10;
     }
 
     event.type = IOMMU_NOTIFIER_UNMAP;
Signature · 1 line
2.19.1
Acked-by on v2 1/1
#1 lore raw

Hi Zenghui,

Quoted 29 lines · Zenghui Yu

When handling guest range-based IOTLB invalidation, we should decode the TG field into the corresponding translation granule size so that we can pass the correct invalidation range to backend. Set @granule to (tg * 2 + 10) to properly emulate the architecture.

Fixes d52915616c05 ("hw/arm/smmuv3: Get prepared for range invalidation")

---
* From v1:
- Fix the compilation error

 hw/arm/smmuv3.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/arm/smmuv3.c +1 -1
index bbca0e9f20..98b99d4fe8 100644
@@ -801,7 +801,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
 {
     SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
     IOMMUTLBEvent event;
-    uint8_t granule = tg;
+    uint8_t granule;
 
     if (!tg) {
         SMMUEventInfo event = {.inval_ste_allowed = true};

hw/arm/smmuv3.c static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, · line 828

Quoted 8 lines
hw/arm/smmuv3.c +2 -0
@@ -821,6 +821,8 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
             return;
         }
         granule = tt->granule_sz;
+    } else {
+        granule = tg * 2 + 10;
     }
 
     event.type = IOMMU_NOTIFIER_UNMAP;

Thanks

Eric

#2 lore raw
In reply to Zenghui Yu
Quoted 29 lines · Zenghui Yu

When handling guest range-based IOTLB invalidation, we should decode the TG field into the corresponding translation granule size so that we can pass the correct invalidation range to backend. Set @granule to (tg * 2 + 10) to properly emulate the architecture.

Fixes d52915616c05 ("hw/arm/smmuv3: Get prepared for range invalidation")

---
* From v1:
- Fix the compilation error

 hw/arm/smmuv3.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/arm/smmuv3.c +1 -1
index bbca0e9f20..98b99d4fe8 100644
@@ -801,7 +801,7 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
 {
     SMMUDevice *sdev = container_of(mr, SMMUDevice, iommu);
     IOMMUTLBEvent event;
-    uint8_t granule = tg;
+    uint8_t granule;
 
     if (!tg) {
         SMMUEventInfo event = {.inval_ste_allowed = true};

hw/arm/smmuv3.c static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, · line 828

Quoted 8 lines
hw/arm/smmuv3.c +2 -0
@@ -821,6 +821,8 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr,
             return;
         }
         granule = tt->granule_sz;
+    } else {
+        granule = tg * 2 + 10;
     }
 
     event.type = IOMMU_NOTIFIER_UNMAP;

Applied to target-arm.next, thanks.

-- PMM