[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] arm/smmuv3: invalidate L1 descriptors after publishing L2 tables


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykola Kvach <Mykola_Kvach@xxxxxxxx>
  • Date: Thu, 3 Dec 2026 15:29:11 +0000
  • Accept-language: en-US, uk-UA
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=agqhlRu/W+iq3FeWEbTXMthKx85gRnWy/tMOcGP8Wg0=; b=L3HSh5vmwfYBlAdZZvFlShET/1dI0z6CrAxJ5DyJodxqtxevPueIy2/G005fPjByLWJ0ETY1ypD/ugJVAc2JgjFPheufqWWfIB/PIlEGMVJy84Yj3D3oD/nus5uJnZY4TmDP59NCxoiFxPkHdyKDV2/W423QLKu1Xtux14Zq5jrq7HqQeEtfvJeU4J0ejaGxYeW/GIzt74VcdXdfEqa67C5dvbtAMb5zJyYkQTQ1FxnB8Gg2ZoZHltAyoQmpbSvb60HbaRQ8t9fMpV794e07L1vAuSLnuhp2WY8CPlTrU0rvusMQ+YfjjemTuurUwzJMjJr9DysVrQkPGNKuEAt+Iw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=te+Kv1GBRIeO/xCZeSETnb942xfm/Y8LC0eoef1guR3PyXsdZQ58SGp7RUbDn3+0Et4ZYkqPa6XjRKfAPmRRKjmmTxO+4zckUKJ6zeRQ5shGFmR2zmEVlMn27dGRIC3z53w2Hql6AYdISndbCearsK5MxRxJgplgaPGEnIbHzfxeTis94x4D+s5uaBjvx5/cJY/3Dg49awwaQSHHL2QcgZ5uJkqSf8VU4ea2Y/RqC7bru5QVPYX2yliJHCHGTy3ARg1yy3WTZz1ROuljYEdUP364kuaUP1C6s/KPfzcxaHi82lFUdI5htVQjp0b6wmf454/I497zmB9uwJSOQXe8yw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Client-request-id: 99d6327e-659c-4a0b-9c6a-b08ec090345a
  • Delivery-date: Thu, 03 Dec 2026 15:29:33 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Request-id: bc062b88-b2ed-4253-9b23-08df51522e32
  • Thread-index: AQHdgzsLrmUHjv/WnkGkRgYrvDS6Sw==
  • Thread-topic: [PATCH] arm/smmuv3: invalidate L1 descriptors after publishing L2 tables

The SMMU may cache an invalid L1 stream-table descriptor before its L2
table is allocated. Updating the descriptor in memory does not remove
that cached entry. Existing leaf-only STE invalidations need not remove
it either.

Issue CMD_CFGI_STE with Leaf=0 after publishing a new L2 table, then wait
for CMD_SYNC. Keep Leaf=1 for ordinary STE updates. This is needed for
both coherent and non-coherent SMMUs; CPU cache maintenance is separate.

Arm IHI 0070 D.a, sections 4.3.1 and 5.1, specify the non-leaf
invalidation and require it when an L1 descriptor becomes active.

Fixes: 452ddbe3592b ("xen/arm: smmuv3: Add support for SMMUv3 driver")
Assisted-by: Codex:GPT-6.1
Signed-off-by: Mykola Kvach <mykola_kvach@xxxxxxxx>
---
 xen/drivers/passthrough/arm/smmu-v3.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu-v3.c 
b/xen/drivers/passthrough/arm/smmu-v3.c
index 232df2421c..996f78f83e 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -649,13 +649,14 @@ arm_smmu_write_strtab_l1_desc(__le64 *dst, struct 
arm_smmu_strtab_l1_desc *desc)
        write_atomic(dst, cpu_to_le64(val));
 }
 
-static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid)
+static void arm_smmu_sync_ste_for_sid(struct arm_smmu_device *smmu, u32 sid,
+                                     bool leaf)
 {
        struct arm_smmu_cmdq_ent cmd = {
                .opcode = CMDQ_OP_CFGI_STE,
                .cfgi   = {
                        .sid    = sid,
-                       .leaf   = true,
+                       .leaf   = leaf,
                },
        };
 
@@ -736,7 +737,7 @@ static void arm_smmu_write_strtab_ent(struct 
arm_smmu_master *master, u32 sid,
                 * the STE regardless of whether the old value was live.
                 */
                if (smmu)
-                       arm_smmu_sync_ste_for_sid(smmu, sid);
+                       arm_smmu_sync_ste_for_sid(smmu, sid, true);
                return;
        }
 
@@ -762,9 +763,9 @@ static void arm_smmu_write_strtab_ent(struct 
arm_smmu_master *master, u32 sid,
                dst[1] |= cpu_to_le64(FIELD_PREP(STRTAB_STE_1_EATS,
                                                 STRTAB_STE_1_EATS_TRANS));
 
-       arm_smmu_sync_ste_for_sid(smmu, sid);
+       arm_smmu_sync_ste_for_sid(smmu, sid, true);
        write_atomic(&dst[0], cpu_to_le64(val));
-       arm_smmu_sync_ste_for_sid(smmu, sid);
+       arm_smmu_sync_ste_for_sid(smmu, sid, true);
 
        /* It's likely that we'll want to use the new STE soon */
        if (!(smmu->options & ARM_SMMU_OPT_SKIP_PREFETCH))
@@ -806,6 +807,8 @@ static int arm_smmu_init_l2_strtab(struct arm_smmu_device 
*smmu, u32 sid)
 
        arm_smmu_init_bypass_stes(desc->l2ptr, 1 << STRTAB_SPLIT);
        arm_smmu_write_strtab_l1_desc(strtab, desc);
+       /* IHI 0070 D.a, section 5.1: L1STD changes need non-leaf CFGI_STE. */
+       arm_smmu_sync_ste_for_sid(smmu, sid, false);
        return 0;
 }
 
-- 
2.53.0

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.