yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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