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

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