From nobody Sun Apr 12 02:50:53 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1771669069700153.9380515485309; Sat, 21 Feb 2026 02:17:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vtk3J-0007oa-Me; Sat, 21 Feb 2026 05:17:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vtk3I-0007me-0y; Sat, 21 Feb 2026 05:17:32 -0500 Received: from zg8tmja5ljk3lje4ms43mwaa.icoremail.net ([209.97.181.73]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vtk3G-0007ic-Eo; Sat, 21 Feb 2026 05:17:31 -0500 Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-6 (Coremail) with SMTP id AQAAfwBnPEQ3hplpJR9zAA--.17914S2; Sat, 21 Feb 2026 18:17:27 +0800 (CST) Received: from phytium.com.cn (unknown [218.76.62.144]) by mail (Coremail) with SMTP id AQAAfwD3Tes2hplpcE4cAA--.34141S3; Sat, 21 Feb 2026 18:17:27 +0800 (CST) From: Tao Tang To: Eric Auger , Peter Maydell , "Michael S . Tsirkin" , Marcel Apfelbaum Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Chen Baozi , Pierrick Bouvier , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Mostafa Saleh , Chao Liu , Tao Tang Subject: [RFC v4 18/31] hw/arm/smmuv3: Make evtq producer use SEC_SID Date: Sat, 21 Feb 2026 18:17:23 +0800 Message-Id: <20260221101723.2994751-1-tangtao1634@phytium.com.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260221100250.2976287-1-tangtao1634@phytium.com.cn> References: <20260221100250.2976287-1-tangtao1634@phytium.com.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAfwD3Tes2hplpcE4cAA--.34141S3 X-CM-SenderInfo: pwdqw3tdrrljuu6sx5pwlxzhxfrphubq/1tbiAQANBWmYzyUAOQAAsr Authentication-Results: hzbj-icmmx-6; spf=neutral smtp.mail=tangtao163 4@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7ZF4xAFy7XF1rWry5Gr13twb_yoW8Zw13pr Z0yFn5K34YyFsxJF95Zrs8u3W7C3y0qrnrGrWxKFyruw15Cr13XFyUJryFyryvgr97J3yk ZFsYkay5Zr45t3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj DUYxn0WfASr-VFAU7a7-sFnT9fnUUIcSsGvfJ3UbIYCTnIWIevJa73UjIFyTuYvj4RJUUU UUUUU Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=209.97.181.73; envelope-from=tangtao1634@phytium.com.cn; helo=zg8tmja5ljk3lje4ms43mwaa.icoremail.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1771669070993158500 Content-Type: text/plain; charset="utf-8" The event queue producer path wrote entries through address_space_memory with MEMTXATTRS_UNSPECIFIED, so produced entries did not use the sec_sid-selected DMA context. Pass AddressSpace and MemTxAttrs to queue_write() from sec_sid, and assert that the selected AddressSpace exists before producing entries. Signed-off-by: Tao Tang Reviewed-by: Eric Auger Reviewed-by: Pierrick Bouvier --- hw/arm/smmuv3.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index b2559e80f24..fa09099a09a 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -128,7 +128,8 @@ static inline MemTxResult queue_read(SMMUQueue *q, Cmd = *cmd, return ret; } =20 -static MemTxResult queue_write(SMMUQueue *q, Evt *evt_in) +static MemTxResult queue_write(SMMUQueue *q, Evt *evt_in, + AddressSpace *as, MemTxAttrs attrs) { dma_addr_t addr =3D Q_PROD_ENTRY(q); MemTxResult ret; @@ -138,8 +139,7 @@ static MemTxResult queue_write(SMMUQueue *q, Evt *evt_i= n) for (i =3D 0; i < ARRAY_SIZE(evt.word); i++) { cpu_to_le32s(&evt.word[i]); } - ret =3D dma_memory_write(&address_space_memory, addr, &evt, sizeof(Evt= ), - MEMTXATTRS_UNSPECIFIED); + ret =3D dma_memory_write(as, addr, &evt, sizeof(Evt), attrs); if (ret !=3D MEMTX_OK) { return ret; } @@ -154,6 +154,11 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s,= SMMUSecSID sec_sid, SMMUv3RegBank *bank =3D smmuv3_bank(s, sec_sid); SMMUQueue *q =3D &bank->eventq; MemTxResult r; + SMMUState *bs =3D ARM_SMMU(s); + MemTxAttrs txattrs =3D smmu_get_txattrs(sec_sid); + AddressSpace *as =3D smmu_get_address_space(bs, sec_sid); + /* Secure AddressSpace must be available, assert if not. */ + g_assert(as); =20 if (!smmuv3_eventq_enabled(s, sec_sid)) { return MEMTX_ERROR; @@ -163,7 +168,7 @@ static MemTxResult smmuv3_write_eventq(SMMUv3State *s, = SMMUSecSID sec_sid, return MEMTX_ERROR; } =20 - r =3D queue_write(q, evt); + r =3D queue_write(q, evt, as, txattrs); if (r !=3D MEMTX_OK) { return r; } --=20 2.34.1