Blame SOURCES/kvm-hw-arm-smmuv3-Introduce-smmuv3_s1_range_inval-helper.patch

c687bc
From c4ae2dbb8ee406f0a015b35fb76b3d6d131900d6 Mon Sep 17 00:00:00 2001
c687bc
From: eperezma <eperezma@redhat.com>
c687bc
Date: Tue, 12 Jan 2021 14:36:31 -0500
c687bc
Subject: [PATCH 07/17] hw/arm/smmuv3: Introduce smmuv3_s1_range_inval() helper
c687bc
MIME-Version: 1.0
c687bc
Content-Type: text/plain; charset=UTF-8
c687bc
Content-Transfer-Encoding: 8bit
c687bc
c687bc
RH-Author: eperezma <eperezma@redhat.com>
c687bc
Message-id: <20210112143638.374060-7-eperezma@redhat.com>
c687bc
Patchwork-id: 100599
c687bc
O-Subject: [RHEL-8.4.0 qemu-kvm PATCH v2 06/13] hw/arm/smmuv3: Introduce smmuv3_s1_range_inval() helper
c687bc
Bugzilla: 1843852
c687bc
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
c687bc
RH-Acked-by: Peter Xu <peterx@redhat.com>
c687bc
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
c687bc
c687bc
From: Eric Auger <eric.auger@redhat.com>
c687bc
c687bc
Let's introduce an helper for S1 IOVA range invalidation.
c687bc
This will be used for NH_VA and NH_VAA commands. It decodes
c687bc
the same fields, trace, calls the UNMAP notifiers and
c687bc
invalidate the corresponding IOTLB entries.
c687bc
c687bc
At the moment, we do not support 3.2 range invalidation yet.
c687bc
So it reduces to a single IOVA invalidation.
c687bc
c687bc
Note the leaf bit now is also decoded for the CMD_TLBI_NH_VAA
c687bc
command. At the moment it is only used for tracing.
c687bc
c687bc
Signed-off-by: Eric Auger <eric.auger@redhat.com>
c687bc
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
c687bc
Message-id: 20200728150815.11446-7-eric.auger@redhat.com
c687bc
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
c687bc
(cherry picked from commit c0f9ef70377cfcbd0fa6559d5dc729a930d71b7c)
c687bc
Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com>
c687bc
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
c687bc
---
c687bc
 hw/arm/smmuv3.c     | 36 +++++++++++++++++-------------------
c687bc
 hw/arm/trace-events |  3 +--
c687bc
 2 files changed, 18 insertions(+), 21 deletions(-)
c687bc
c687bc
diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c
c687bc
index 067c9480a03..ae2b769f891 100644
c687bc
--- a/hw/arm/smmuv3.c
c687bc
+++ b/hw/arm/smmuv3.c
c687bc
@@ -824,6 +824,22 @@ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova)
c687bc
     }
c687bc
 }
c687bc
 
c687bc
+static void smmuv3_s1_range_inval(SMMUState *s, Cmd *cmd)
c687bc
+{
c687bc
+    dma_addr_t addr = CMD_ADDR(cmd);
c687bc
+    uint8_t type = CMD_TYPE(cmd);
c687bc
+    uint16_t vmid = CMD_VMID(cmd);
c687bc
+    bool leaf = CMD_LEAF(cmd);
c687bc
+    int asid = -1;
c687bc
+
c687bc
+    if (type == SMMU_CMD_TLBI_NH_VA) {
c687bc
+        asid = CMD_ASID(cmd);
c687bc
+    }
c687bc
+    trace_smmuv3_s1_range_inval(vmid, asid, addr, leaf);
c687bc
+    smmuv3_inv_notifiers_iova(s, asid, addr);
c687bc
+    smmu_iotlb_inv_iova(s, asid, addr);
c687bc
+}
c687bc
+
c687bc
 static int smmuv3_cmdq_consume(SMMUv3State *s)
c687bc
 {
c687bc
     SMMUState *bs = ARM_SMMU(s);
c687bc
@@ -954,27 +970,9 @@ static int smmuv3_cmdq_consume(SMMUv3State *s)
c687bc
             smmu_iotlb_inv_all(bs);
c687bc
             break;
c687bc
         case SMMU_CMD_TLBI_NH_VAA:
c687bc
-        {
c687bc
-            dma_addr_t addr = CMD_ADDR(&cmd);
c687bc
-            uint16_t vmid = CMD_VMID(&cmd);
c687bc
-
c687bc
-            trace_smmuv3_cmdq_tlbi_nh_vaa(vmid, addr);
c687bc
-            smmuv3_inv_notifiers_iova(bs, -1, addr);
c687bc
-            smmu_iotlb_inv_iova(bs, -1, addr);
c687bc
-            break;
c687bc
-        }
c687bc
         case SMMU_CMD_TLBI_NH_VA:
c687bc
-        {
c687bc
-            uint16_t asid = CMD_ASID(&cmd);
c687bc
-            uint16_t vmid = CMD_VMID(&cmd);
c687bc
-            dma_addr_t addr = CMD_ADDR(&cmd);
c687bc
-            bool leaf = CMD_LEAF(&cmd);
c687bc
-
c687bc
-            trace_smmuv3_cmdq_tlbi_nh_va(vmid, asid, addr, leaf);
c687bc
-            smmuv3_inv_notifiers_iova(bs, asid, addr);
c687bc
-            smmu_iotlb_inv_iova(bs, asid, addr);
c687bc
+            smmuv3_s1_range_inval(bs, &cmd);
c687bc
             break;
c687bc
-        }
c687bc
         case SMMU_CMD_TLBI_EL3_ALL:
c687bc
         case SMMU_CMD_TLBI_EL3_VA:
c687bc
         case SMMU_CMD_TLBI_EL2_ALL:
c687bc
diff --git a/hw/arm/trace-events b/hw/arm/trace-events
c687bc
index f74d3e920f1..c219fe9e828 100644
c687bc
--- a/hw/arm/trace-events
c687bc
+++ b/hw/arm/trace-events
c687bc
@@ -45,8 +45,7 @@ smmuv3_cmdq_cfgi_ste_range(int start, int end) "start=0x%d - end=0x%d"
c687bc
 smmuv3_cmdq_cfgi_cd(uint32_t sid) "streamid = %d"
c687bc
 smmuv3_config_cache_hit(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache HIT for sid %d (hits=%d, misses=%d, hit rate=%d)"
c687bc
 smmuv3_config_cache_miss(uint32_t sid, uint32_t hits, uint32_t misses, uint32_t perc) "Config cache MISS for sid %d (hits=%d, misses=%d, hit rate=%d)"
c687bc
-smmuv3_cmdq_tlbi_nh_va(int vmid, int asid, uint64_t addr, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" leaf=%d"
c687bc
-smmuv3_cmdq_tlbi_nh_vaa(int vmid, uint64_t addr) "vmid =%d addr=0x%"PRIx64
c687bc
+smmuv3_s1_range_inval(int vmid, int asid, uint64_t addr, bool leaf) "vmid =%d asid =%d addr=0x%"PRIx64" leaf=%d"
c687bc
 smmuv3_cmdq_tlbi_nh(void) ""
c687bc
 smmuv3_cmdq_tlbi_nh_asid(uint16_t asid) "asid=%d"
c687bc
 smmuv3_config_cache_inv(uint32_t sid) "Config cache INV for sid %d"
c687bc
-- 
c687bc
2.27.0
c687bc