From nobody Sun Apr 12 02:49:52 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 1771668269428543.6892079478982; Sat, 21 Feb 2026 02:04:29 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vtjpk-0005mx-QU; Sat, 21 Feb 2026 05:03: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 1vtjpd-0005kZ-9Q; Sat, 21 Feb 2026 05:03:25 -0500 Received: from zg8tmtyylji0my4xnjqumte4.icoremail.net ([162.243.164.118]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vtjpa-00057r-JU; Sat, 21 Feb 2026 05:03:24 -0500 Received: from prodtpl.icoremail.net (unknown [10.12.1.20]) by hzbj-icmmx-7 (Coremail) with SMTP id AQAAfwC3v2PmgplpjqBVBw--.4384S2; Sat, 21 Feb 2026 18:03:18 +0800 (CST) Received: from phytium.com.cn (unknown [218.76.62.144]) by mail (Coremail) with SMTP id AQAAfwD3TevcgplpBk4cAA--.34138S12; Sat, 21 Feb 2026 18:03:17 +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 09/31] hw/arm/smmuv3: Enforce Secure stage 2 capability check when decoding STE Date: Sat, 21 Feb 2026 18:02:28 +0800 Message-Id: <20260221100250.2976287-10-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: AQAAfwD3TevcgplpBk4cAA--.34138S12 X-CM-SenderInfo: pwdqw3tdrrljuu6sx5pwlxzhxfrphubq/1tbiAQANBWmYzyUAJgABs1 Authentication-Results: hzbj-icmmx-7; spf=neutral smtp.mail=tangtao163 4@phytium.com.cn; X-Coremail-Antispam: 1Uk129KBjvJXoW7Ary5Xry7tw13Gw43AF4kCrg_yoW8JFWkpF Z8GwsY9rWfJ3WfZrnruws2yrZ7WFWrGr9rGr1Ik343Z3WUAr1Dtr1IkF1agFyrXrWrXrW7 uan2qFZ5Xr4vyrJanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj 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=162.243.164.118; envelope-from=tangtao1634@phytium.com.cn; helo=zg8tmtyylji0my4xnjqumte4.icoremail.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=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: 1771668271643158500 Content-Type: text/plain; charset="utf-8" When decoding a Stream Table Entry (STE) from the Secure stream table that enables stage-2 translation, verify that the SMMU implementation advertises Secure stage-2 support via S_IDR1.SEL2. If stage-2 is requested but S_IDR1.SEL2 is 0, mark the STE as ILLEGAL. This implements the requirement from the Arm SMMUv3 architecture specification (IHI 0070G.b, Section 5.2, Page 218) that a Secure STE with stage-2 enabled is only valid when the implementation supports Secure stage-2 translation. Signed-off-by: Tao Tang Reviewed-by: Pierrick Bouvier --- hw/arm/smmuv3.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 2192bec2368..d011357253e 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -623,6 +623,16 @@ static int decode_ste(SMMUv3State *s, SMMUTransCfg *cf= g, if (ret) { goto bad_ste; } + + /* + * Stage 2 is implemented but Secure stage 2 is not supported while + * STE is from Secure stream table. STE is ILLEGAL in this case + * according to (IHI 0070G.b) 5.2 STE, Stream Table Entry, Page 21= 8. + */ + if ((cfg->sec_sid =3D=3D SMMU_SEC_SID_S) && + !(FIELD_EX32(s->bank[SMMU_SEC_SID_S].idr[1], S_IDR1, SEL2))) { + goto bad_ste; + } } =20 /* Multiple context descriptors require SubstreamID support */ --=20 2.34.1