From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673519981; cv=none; d=zohomail.com; s=zohoarc; b=iJpzMQLeV/3mehGLB9eUc0IpT0HmLoeb3svOhDqlX0sEBbqpDD/lTKm7yKN2hDuQ/igp6TZgsk8RqKDB1Tw02Tj1PvWhgxVUUWkIsWF0fHmetqskINbYFApBLGEEni+WqWcW433kJNZBx++QkU9JwzkKGXB9SjCMj/uklkL5LXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673519981; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ePUpY57zvg4A0Qc0xpq/0lKutMQk/AlQwlgNULaa5VI=; b=n5J05WAiQEJreyvpWUxzjR6+//TVRw0EUkO6JRY+Jf0RqvjIYLNx+hO0HPXafy6VmrfQsN0sdraPtKPtJfSuC9z6CZEj0zZWo0i8vMlbiHub9G6Y+SDnRYvZ78zPkWp4DYvMAdHt4cy7p7ajZraP5UEjwLpD3PuKUfU3BcFOr3U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167351998117262.21978105872279; Thu, 12 Jan 2023 02:39:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFulM-0002i1-VY; Thu, 12 Jan 2023 05:24:48 -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 1pFulL-0002hV-KK for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:24:47 -0500 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFulK-0000Gh-2U for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:24:47 -0500 Received: by mail-wr1-x434.google.com with SMTP id bk16so17567432wrb.11 for ; Thu, 12 Jan 2023 02:24:45 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id d20-20020adfa354000000b002bc50ba3d06sm11959200wrb.9.2023.01.12.02.24.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ePUpY57zvg4A0Qc0xpq/0lKutMQk/AlQwlgNULaa5VI=; b=pODn1w1BBgXqFZuZdQXrXgL0CISMMe7H69BLjKztTbUWphMg+Q66mfBBdwSY5iunhR FmFnqaCqwg2RaR2m7JNqqO7jTsj9oat2HLfWYZa8JWanOKqNVOjuUEanuSZS519V+bkM Q9n/rNM/9Vc0iyi1IGZIDdyFE0EpJgx1JHih2jr8U7+kGgMvnfkl53HQCJ5K2Px2JfTg SRIdfBp5P24ooZecEZzMtMz7L73jvPNBtHH2Nk/xVvAe9NqzNw3hmNcpQi8hZSMBvPFd cTyI3Vwtx8aYA+iRXCS8781FnAhIFwUbSUTCvhBymQUvwynYVFvhY3zw5DKrVnmdO2+h JXDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ePUpY57zvg4A0Qc0xpq/0lKutMQk/AlQwlgNULaa5VI=; b=t5fKwkvkzsDj+erpXrkNLpBTvfPxN+xUllkV6huIs2BwWQHxilrBqz9/ivFS5jC/g6 GZYql0RZtzcci9ZVzp98bI0f+3fbYNUHgrqSDDmmS0RCLJjfaWaYUr4WVh1zNkNPBhkQ nQnkLjdScNld82HNCG+hsqPxYDPR3C8+28Z2uDMASjoYTxjpnL1/CDqsvfSnFYQENo9O in601O889ZvlxoK7HfrlO/ow/mGRHrMvJO5zk/EYAg++xamScf3CBVnPQviq0jMk7mwo VRK90QoPYpq4b+vHxghyr1Epdk2DytCAcmRoDGqYn+Nx//4jcESjldciwaJbBZ7SjO/V 5IQA== X-Gm-Message-State: AFqh2krAkKia6Q17BFG/Et81mCztau356WJm9scLWDqO32sk1UMy39ib b6FFxgg8TETrXcE8CwYFC5zy8HZe8qGFe0vC X-Google-Smtp-Source: AMrXdXsc//ysHLz1kQO6V1TFAqGsLFRrfVWBnR8h7GOivP5y3Z2mUieYF/naWGik/EJ+ND8fdtzWnQ== X-Received: by 2002:a5d:61ca:0:b0:28a:4135:d303 with SMTP id q10-20020a5d61ca000000b0028a4135d303mr36073650wrv.37.1673519084321; Thu, 12 Jan 2023 02:24:44 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/7] target/arm/sme: Reorg SME access handling in handle_msr_i() Date: Thu, 12 Jan 2023 11:24:30 +0100 Message-Id: <20230112102436.1913-2-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673519981638100001 From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- target/arm/translate-a64.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2ee171f249..35cc851246 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1841,18 +1841,20 @@ static void handle_msr_i(DisasContext *s, uint32_t = insn, goto do_unallocated; } if (sme_access_check(s)) { - bool i =3D crm & 1; - bool changed =3D false; + int old =3D s->pstate_sm | (s->pstate_za << 1); + int new =3D (crm & 1) * 3; + int msk =3D (crm >> 1) & 3; =20 - if ((crm & 2) && i !=3D s->pstate_sm) { - gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); - changed =3D true; - } - if ((crm & 4) && i !=3D s->pstate_za) { - gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); - changed =3D true; - } - if (changed) { + if ((old ^ new) & msk) { + /* At least one bit changes. */ + bool i =3D crm & 1; + + if ((crm & 2) && i !=3D s->pstate_sm) { + gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); + } + if ((crm & 4) && i !=3D s->pstate_za) { + gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); + } gen_rebuild_hflags(s); } else { s->base.is_jmp =3D DISAS_NEXT; --=20 2.38.1 From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673519154; cv=none; d=zohomail.com; s=zohoarc; b=mWlWeQbsF7R1ETb7xnBjgBbFre5N/qBpu/p5A6s4fym1vZXGHDW+vHGpoK42/uOO7M13ft7/tHHAmDtjAZc72YRz6rgyJzRvNcD63lNdIoL87PaFKinFUmPXbLUT1nZ86oE35ZQHYMB5BgXXVusQK217OQTyQDKeYfL0DriFQCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673519154; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VQhBH/U1Fypgm54dLIg4D6CrvEvSuf6an15qZZ2LS2o=; b=QHzJwRXdwB8bpb8zjcHwCCWK2Lrijjyt4OmGB5gacno7ajbW/UiGXZfpld+QzG51gxVEcpfqEp9IaPEAEjfSLGiy1hVz4cKiY9bsdISybY9g02bb6HlZ3y3p/ogdewdMT4hFoSxXRIEGfhYOjmX0r4U7U2ixAS/eKV+nVypusM8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673519154728728.8865859674426; Thu, 12 Jan 2023 02:25:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFulS-0002jw-9h; Thu, 12 Jan 2023 05:24:54 -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 1pFulQ-0002jF-FL for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:24:52 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFulO-0000HK-UK for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:24:52 -0500 Received: by mail-wm1-x32b.google.com with SMTP id m26-20020a05600c3b1a00b003d9811fcaafso14616456wms.5 for ; Thu, 12 Jan 2023 02:24:50 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id z6-20020a05600c0a0600b003d96efd09b7sm30373648wmp.19.2023.01.12.02.24.48 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:24:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VQhBH/U1Fypgm54dLIg4D6CrvEvSuf6an15qZZ2LS2o=; b=Kh/Pmc/t8Mt3X0WW8iYSqNAwqT3eTgLPLAtevcyUCZmDyKRh8sfjYmR7tSpQK/KMB8 FiTm6M8bhNii4pXYP1MnnbeVCKZt3JTm5oT4iGjt7lBuBfD1I7Ns4KVzlEle/OG2d5kQ BKKQeqtJ9B8rl3APvyxYjZ4oo/JPPGppcK73DA/94FNSxxi2iDVURpSsQU3HhBc981rp LNeKarluVZUCeFKHAtvOZDvQXGygSRFK1PaTwXVg4s7n7KdzJRHi1PtzRCwKsQx6TejA +0bcrduWm6SaNMCIx3tcKVIRx36FP0eyKGXjKpO6voPMOm2eEaaxR+bPBpnEqM6KHRVb xGgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VQhBH/U1Fypgm54dLIg4D6CrvEvSuf6an15qZZ2LS2o=; b=RYxGxwZJUeF5PYDKtdSwjMPuvPOYtzNpU98Mwjz5duwGVcYz4dEGDvFcKN6oJ6T06v rnqvXeFXLSWvxWSBTB9X865WABOPp8/hp6sic9wvLUp5orLhBSoqhkuJ6v9iwkZUoCb5 I/XExyWjxRQkwyHFyh6lCEIo7j1FUiU4v8rhLAR/T1EoJ6Z9ieTVgqxVphTeLHBpR+Ts 7xDfUTi0CyYmB6pscCrru7/D+7eKJ0SsAd4zvnpvRmn9BUjevj2zpdkDCd+bdOFP8R0j zpcSFRN8TW6sdf/Ouj+dcomj4kcxRLRFNx2uY9RVSLNxEUIqmX6hqqd55MEaDbWBsChl 3Zvw== X-Gm-Message-State: AFqh2ko9XC9/nka46DuqF7CqbOGqZzdcFNlwqXQwm2xGRNQWL4sNrnAd X1Un4ahX7qQXPcrJBP/5kb5EZmdzDePtIWyn X-Google-Smtp-Source: AMrXdXs9MTl9Z5cYBqZqfbUR6PZFgyw1fMQLn1E/ZvqFw8Ta1YF+ZQpDyTr88RsgXX2PJOLwXXWNFg== X-Received: by 2002:a05:600c:35c8:b0:3cf:85f7:bbc4 with SMTP id r8-20020a05600c35c800b003cf85f7bbc4mr55110871wmq.2.1673519089135; Thu, 12 Jan 2023 02:24:49 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/7] target/arm/sme: Rebuild hflags in set_pstate() helpers Date: Thu, 12 Jan 2023 11:24:31 +0100 Message-Id: <20230112102436.1913-3-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673519156822100001 From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- target/arm/sme_helper.c | 2 ++ target/arm/translate-a64.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index f891306bb9..b5aefa3eda 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -45,6 +45,7 @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i) } env->svcr ^=3D R_SVCR_SM_MASK; arm_reset_sve_state(env); + arm_rebuild_hflags(env); } =20 void helper_set_pstate_za(CPUARMState *env, uint32_t i) @@ -65,6 +66,7 @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) if (i) { memset(env->zarray, 0, sizeof(env->zarray)); } + arm_rebuild_hflags(env); } =20 void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 35cc851246..035e63bdc5 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1855,7 +1855,6 @@ static void handle_msr_i(DisasContext *s, uint32_t in= sn, if ((crm & 4) && i !=3D s->pstate_za) { gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); } - gen_rebuild_hflags(s); } else { s->base.is_jmp =3D DISAS_NEXT; } --=20 2.38.1 From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673520075; cv=none; d=zohomail.com; s=zohoarc; b=BgGNpaxVIt96g+cwhWqkUTfTjCPkM6lI2aOodo4PGdZ+M3nt2QtsPtLV+A28t6RMdRmPxwDY8/aynKFGuHMUKpcAt1aKqmBr6Z4UuCFruklGCACFgDR9XDEGiiClAqqAUvrYy56iKsbOqT1oLbYeR+ZLScdfLRJKCLgDHP1VRCI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673520075; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zgYSpkPWt3XJSKPRvFourSSz9p544s04F5BpIyvX9KA=; b=iGMP1h+sN/ngY5ie7Z2evVRXo0Lf92km6TUneVnLeWACXLpsNx6vVCtNJExxH+BbX6DLc2CHHHHuT4BB0iRkVJoG/G1IdmUgKzXs7/kh9RIXrdRnPJzEfWUglSglp9zgFOTRYqB1GRiemi9KySEp/Osn+ZpDMI3Q+8d2OroYZK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673520075915990.787455753011; Thu, 12 Jan 2023 02:41:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFulY-0002mL-0q; Thu, 12 Jan 2023 05:25:00 -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 1pFulV-0002lN-A7 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:24:57 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFulT-0000I1-LP for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:24:57 -0500 Received: by mail-wr1-x42b.google.com with SMTP id d17so17598655wrs.2 for ; Thu, 12 Jan 2023 02:24:55 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o15-20020a5d62cf000000b002bbedd60a9asm10371382wrv.77.2023.01.12.02.24.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:24:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zgYSpkPWt3XJSKPRvFourSSz9p544s04F5BpIyvX9KA=; b=vPynf7WsrZGoepkqM84RvsX3vqjyfFUib2jQL+Y9NknK83R14sh7RA3hAbntDyXcFQ ZPn5ICY277BdgPxcTcma07klwB84ngeOzVjTlurWROOz9sTdiBHEvKnAMFLIZzD7UkBV eGsFdLuVxCGgy7FnzTwf2RcumSu/vE/BSIVoQAhBGuZzDCpzzeA750gPrUZpV+usBooo 4Zc3WyT7S789BcVlBkagATSxrc/Uh4Sz5uMuYJmwSke6ArtME+/WfpU6588kJOB6SQ5R D/itwWP3/yedJOiA6NGkSkrrM9jlZd0+O+pHUNRbR9KpgBIBgP08c1NDlKB81c2FwbtH rubw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zgYSpkPWt3XJSKPRvFourSSz9p544s04F5BpIyvX9KA=; b=ZEYIl370Re6veKBPNiXTtiz4tuszNuPCec1aAqGWFQoTo/PYuwrx0ZYNy5XYFNoOhy KJt6x3TSmFuXZVZqLDGNJQLcwv5c4dEdXuPM2NXgZGe3wqG13vzMBG2NtZliS01+XiFc Tk23MfE+Z5+djba+xY5xed6HMSamO4Mae9OvG75E4u2srDZhw63a1sdcBb7P2rApbyYg KjAE73DUhlYTaTd5jqqwZw4Rw0T6AgXlAwmsFnDcjrATXtGDzei0lGzqBlNKyPh/aYEn D+Lq9K/E7jysT1BICTbY2IALWjezI2mXyBtLCR3TGZ3y4SjsaIikPZy++DKU7AvPZqjn 102A== X-Gm-Message-State: AFqh2kp37mhdAx9uC56PriLerGHfvyvxGvtbYg5r3CfLtjMGVQ5tJ8xl A5OlWyMhGheMzCY3Rtj2nVNpmmFPqFp+DvTi X-Google-Smtp-Source: AMrXdXvS1ZKG5ictRWzdSjcsqRpq2YqN87pXb0DBRjNcqckBhzh5T8tIQxF8G++lotW0fwpLkqg+/w== X-Received: by 2002:a5d:4692:0:b0:2bb:e94c:fcbf with SMTP id u18-20020a5d4692000000b002bbe94cfcbfmr10155989wrq.52.1673519093982; Thu, 12 Jan 2023 02:24:53 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 3/7] target/arm/sme: Introduce aarch64_set_svcr() Date: Thu, 12 Jan 2023 11:24:32 +0100 Message-Id: <20230112102436.1913-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673520078168100001 From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- linux-user/aarch64/cpu_loop.c | 2 +- linux-user/aarch64/signal.c | 2 +- target/arm/cpu.h | 1 + target/arm/helper.c | 8 ++++++++ target/arm/sme_helper.c | 4 ++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 9875d609a9..d53742e10b 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -93,8 +93,8 @@ void cpu_loop(CPUARMState *env) * On syscall, PSTATE.ZA is preserved, along with the ZA matri= x. * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState. */ + aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); if (FIELD_EX64(env->svcr, SVCR, SM)) { - env->svcr =3D FIELD_DP64(env->svcr, SVCR, SM, 0); arm_rebuild_hflags(env); arm_reset_sve_state(env); } diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index 6a2c6e06d2..b6e4dcb494 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -669,11 +669,11 @@ static void target_setup_frame(int usig, struct targe= t_sigaction *ka, * Invoke the signal handler with both SM and ZA disabled. * When clearing SM, ResetSVEState, per SMSTOP. */ + aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); if (FIELD_EX64(env->svcr, SVCR, SM)) { arm_reset_sve_state(env); } if (env->svcr) { - env->svcr =3D 0; arm_rebuild_hflags(env); } =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index bf2bce046d..0484da3322 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1123,6 +1123,7 @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uin= t8_t *buf, int reg); void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, int new_el, bool el0_a64); +void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask); void arm_reset_sve_state(CPUARMState *env); =20 /* diff --git a/target/arm/helper.c b/target/arm/helper.c index cee3804354..b5626627a1 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6722,11 +6722,19 @@ static CPAccessResult access_esm(CPUARMState *env, = const ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) +{ + uint64_t change =3D (env->svcr ^ new) & mask; + + env->svcr ^=3D change; +} + static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); + aarch64_set_svcr(env, value, -1); arm_rebuild_hflags(env); } =20 diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index b5aefa3eda..94dc084135 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -43,7 +43,7 @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i) if (i =3D=3D FIELD_EX64(env->svcr, SVCR, SM)) { return; } - env->svcr ^=3D R_SVCR_SM_MASK; + aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); arm_reset_sve_state(env); arm_rebuild_hflags(env); } @@ -53,7 +53,7 @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) if (i =3D=3D FIELD_EX64(env->svcr, SVCR, ZA)) { return; } - env->svcr ^=3D R_SVCR_ZA_MASK; + aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); =20 /* * ResetSMEState. --=20 2.38.1 From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673520628; cv=none; d=zohomail.com; s=zohoarc; b=bTE5Tj0s3tjNLGoqtII5eE+LAwMMmbyN8HH3o4nqwj0BdQBhKbccdiRHCsG1vB+YvnpJ4+Cy4Xz0dHOSh/h+5OxMf7UFkm2IKeHXpTw+Dl2QDW4Js1dXqGi0yWhSBW93Rw45E4DttsG5A9N7qo3XIOEawnDiGZe054QqWS/Mcbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673520628; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Em3cdaU0A4mDO/4c/HA3b5yoakmz2M4KDrzcG5G3fHE=; b=newC4xswk7iM+L32zXrf7BXKdWt/qW1wti1kU/gPmCVN4KzwZLqJB5cGdo2d6Ilj23vsWDxfMupCgga1vpoRqJ05Nhj+nfixujCOnQ9tnUxLo+EHfjZsNS0GAn8dWS6x/MyCwALL2T0WL5rAR5yuXYpSblF/5ic054hixdyUvPc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673520628568264.8095677133781; Thu, 12 Jan 2023 02:50:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFulb-0002ng-Of; Thu, 12 Jan 2023 05:25:03 -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 1pFula-0002nG-5P for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:02 -0500 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFulY-0000IV-EQ for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:01 -0500 Received: by mail-wr1-x436.google.com with SMTP id t5so13186631wrq.1 for ; Thu, 12 Jan 2023 02:25:00 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id t10-20020a5d534a000000b00272c0767b4asm16149711wrv.109.2023.01.12.02.24.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:24:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Em3cdaU0A4mDO/4c/HA3b5yoakmz2M4KDrzcG5G3fHE=; b=yKyEQ4SVE2qG6ILL25rghQEbX940+Dd59c6uKBanddX/AK8NI9qbHtXS0BUqglQyyI +DVVYhGVUhE/s/9cxqZ1VgGEKvWvNx7gwm0GeSfnBFydYpfPmt2RMqvf/1A9JJEd3n1G kbhOR24LAaqR2Y8YyHYbV79u1LcXmgsytJM6mCb5Katj88nm6AHu9BPMiFaWQNa2K8vc k31E7rutyz3kqFHFz3Qpr5qtwT6cIF275FWZG2K4f01in0+xcuRC47M7WC6hf589o956 AZkLEtoFfwWfrS+e/0x+X92Y/F31yErzt51E/VBOLpez/Z9F8i04Dmd/yG6rI0GZjc6c ddcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Em3cdaU0A4mDO/4c/HA3b5yoakmz2M4KDrzcG5G3fHE=; b=RP+x6Pn4v3CBwNMnoBVgy/y8qPSvVX9LE/foyIATQUHsOHyJ0sCCI0iRd8NXOiC0aW UxSjJy+jYJpWtgeCE5FieEZ/7HP1SboJk0tWJ0jyM4P91YL+wff8s2WjIdexFrxTc7HR 3fLEi7s2ZtFOBoZsCpaPe3nv8sPiSneIfUDIas0KY26oT8RJ1gbZLP7Ua8kM7fc4xSSK W1TXgo583IiEf0IBepWxIfMyTgE4qdJPcA+E2l54XlU7P5w1q7Kl87zi7PIGxg5uV+IZ 3Ok+HkgCo32pPn+Q5drvn/RtcXyRgaBxVhjQl77BdxSCy5BXifhMXHdXlwcPlDh1nCuS xBTg== X-Gm-Message-State: AFqh2kqMmhWSLfg1+ea1P1epKA4y3rgMhkcdpDy4GPxnFv5ZFIEkRtzY HIq9KP7l7i85UWemT/i/oUJNNdLyAKblcZEs X-Google-Smtp-Source: AMrXdXsqe9SffNChchUXLDZY29HmQDGaVF8IVpZ2RQBahhxLVwxNb6RidOSf7AVYcNcD52oXndemLA== X-Received: by 2002:a5d:5a19:0:b0:242:2088:1546 with SMTP id bq25-20020a5d5a19000000b0024220881546mr63860138wrb.61.1673519098883; Thu, 12 Jan 2023 02:24:58 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 4/7] target/arm/sme: Reset SVE state in aarch64_set_svcr() Date: Thu, 12 Jan 2023 11:24:33 +0100 Message-Id: <20230112102436.1913-5-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::436; envelope-from=philmd@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673520630897100001 From: Richard Henderson Move arm_reset_sve_state() calls to aarch64_set_svcr(). Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- linux-user/aarch64/cpu_loop.c | 1 - linux-user/aarch64/signal.c | 8 +------- target/arm/cpu.h | 1 - target/arm/helper.c | 13 +++++++++++++ target/arm/sme_helper.c | 10 ---------- 5 files changed, 14 insertions(+), 19 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index d53742e10b..5e93d27d8f 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -96,7 +96,6 @@ void cpu_loop(CPUARMState *env) aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); if (FIELD_EX64(env->svcr, SVCR, SM)) { arm_rebuild_hflags(env); - arm_reset_sve_state(env); } ret =3D do_syscall(env, env->xregs[8], diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index b6e4dcb494..a326a6def5 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -665,14 +665,8 @@ static void target_setup_frame(int usig, struct target= _sigaction *ka, env->btype =3D 2; } =20 - /* - * Invoke the signal handler with both SM and ZA disabled. - * When clearing SM, ResetSVEState, per SMSTOP. - */ + /* Invoke the signal handler with both SM and ZA disabled. */ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); - if (FIELD_EX64(env->svcr, SVCR, SM)) { - arm_reset_sve_state(env); - } if (env->svcr) { arm_rebuild_hflags(env); } diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0484da3322..a471add499 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1124,7 +1124,6 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned= vq); void aarch64_sve_change_el(CPUARMState *env, int old_el, int new_el, bool el0_a64); void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask); -void arm_reset_sve_state(CPUARMState *env); =20 /* * SVE registers are encoded in KVM's memory in an endianness-invariant fo= rmat. diff --git a/target/arm/helper.c b/target/arm/helper.c index b5626627a1..b655dde27d 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6722,11 +6722,24 @@ static CPAccessResult access_esm(CPUARMState *env, = const ARMCPRegInfo *ri, return CP_ACCESS_OK; } =20 +/* ResetSVEState */ +static void arm_reset_sve_state(CPUARMState *env) +{ + memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); + /* Recall that FFR is stored as pregs[16]. */ + memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); + vfp_set_fpcr(env, 0x0800009f); +} + void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask) { uint64_t change =3D (env->svcr ^ new) & mask; =20 env->svcr ^=3D change; + + if (change & R_SVCR_SM_MASK) { + arm_reset_sve_state(env); + } } =20 static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index 94dc084135..f73bf4d285 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -29,22 +29,12 @@ #include "vec_internal.h" #include "sve_ldst_internal.h" =20 -/* ResetSVEState */ -void arm_reset_sve_state(CPUARMState *env) -{ - memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs)); - /* Recall that FFR is stored as pregs[16]. */ - memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs)); - vfp_set_fpcr(env, 0x0800009f); -} - void helper_set_pstate_sm(CPUARMState *env, uint32_t i) { if (i =3D=3D FIELD_EX64(env->svcr, SVCR, SM)) { return; } aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); - arm_reset_sve_state(env); arm_rebuild_hflags(env); } =20 --=20 2.38.1 From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673520365; cv=none; d=zohomail.com; s=zohoarc; b=f3GfOfTnkwHASc5MjLN1cjoSdXtGazkiPOCm6rSyI4tZ1yg22Wjusk/Q/E3sAUY3iMSBoLePkxwYaQanUFL0tN0WPI2ZcOwLYqvxTKmPaHQV6iCNyktYfKFDWNXM9xH2Wfu2i8yos599z+fzmCAkNCqN9UQy6PaC5vimt/dVG3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673520365; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QdbzZcLHTRdT4BdGiWixXL1Aa81U11XaY7492Ze75as=; b=cdKSysB75MyaT0IhiZ2QPRzZi17Hc41VALcjA+0oYbGbhN6NNn1BSXwOF0t6ynlKWIAWoCZAOEK2SCzN5P8hhXY5rDcpGHnEcL7QLmNyr/ConSz4RjVXWbFFqsJF3BhD4+h+2+IEijDaRadexmt0X0kvS+A9sTe8k6ZCa6xlufU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1673520365091923.383248513125; Thu, 12 Jan 2023 02:46:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFulh-0002r3-Cn; Thu, 12 Jan 2023 05:25:09 -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 1pFulf-0002pp-SU for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:07 -0500 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFuld-0000JT-Hm for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:07 -0500 Received: by mail-wr1-x433.google.com with SMTP id r2so17594171wrv.7 for ; Thu, 12 Jan 2023 02:25:05 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id bp28-20020a5d5a9c000000b00273cd321a1bsm16093843wrb.107.2023.01.12.02.25.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QdbzZcLHTRdT4BdGiWixXL1Aa81U11XaY7492Ze75as=; b=nAWbmTJjZr2z4XR4KZiNPTDBbXLEH7I+zKOmGMhXO3LcAU+nArtF+TPvbsZs/I38iK zwEV8Qy8eXsf9JKUKkYkbE/c5w35qD/JlVuOIFR9jKGA90HmLAcj+4gs+BAkvXafI401 5k5+QhWohkWjRIzlLMq0R7oIQjL6MQDYsJCMAj/0tfZniY04m4eyQXwKFZThXbHsu6ZS OI66zpcIIMY6zYyfywVmG6p4J6vRX6fIO5BQ5a8FU7y7t/+CJ7Bgtr1BOkwd5CfQwflg fXxHNLxnWFbI94nBtPGdhVgWM5rWasCFPWn3bXOkJPIp9rX9Z1yyDdmXd9GUpFDltTnQ Pg9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QdbzZcLHTRdT4BdGiWixXL1Aa81U11XaY7492Ze75as=; b=tdCJ+nq3A+ffxCxXzGDRxSYH4roEpCVWmUIKupzz04vCI5O8EBqRCH+s/AELi4zfnZ iOuuWwEAq/VvmZ7k41ePDpvvyE8cLjr5oHdZeX7swsSdrTfLDDqTmI4YdA2d//TuK02m 8RwCENXXYzFdypQf/2NVn6avOsHT9DxH9Q1ljgpZdt5qt1HBtm0tSj3fFOx3T0VN/PIS 2jISvZUMnj2PEUfb4uQLjdW6IMv92KyH0d1dtClcdilLAkZ+FkMHlirIWTcFI7cZa5K5 lwTjng1QwygzuMW0qIRbFo51/ZpV3XnqQeFtZQ78PXXDTS/p9sqPtug55zpyk9QeX+F7 KfjQ== X-Gm-Message-State: AFqh2krd7Hzc7usLr0dKapySOmq9IqD94aiAq+yd1zr3Uutq1WqEY1dY GXZ1HetxeG5O1nQYHBhn2vPUo9pPBXYCvp3K X-Google-Smtp-Source: AMrXdXsm+2jtQaYstWVNP3fYMiEuWwZqQTvaJEd3q7nze2LYGZexTOiRs6OVgHWKH9/DUoN2qKcI5Q== X-Received: by 2002:a5d:6b87:0:b0:2bc:371a:8a1 with SMTP id n7-20020a5d6b87000000b002bc371a08a1mr9088673wrx.22.1673519103792; Thu, 12 Jan 2023 02:25:03 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 5/7] target/arm/sme: Reset ZA state in aarch64_set_svcr() Date: Thu, 12 Jan 2023 11:24:34 +0100 Message-Id: <20230112102436.1913-6-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::433; envelope-from=philmd@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673520368931100001 From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- target/arm/helper.c | 12 ++++++++++++ target/arm/sme_helper.c | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index b655dde27d..26c3bb4cdf 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6740,6 +6740,18 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new= , uint64_t mask) if (change & R_SVCR_SM_MASK) { arm_reset_sve_state(env); } + + /* + * ResetSMEState. + * + * SetPSTATE_ZA zeros on enable and disable. We can zero this only + * on enable: while disabled, the storage is inaccessible and the + * value does not matter. We're not saving the storage in vmstate + * when disabled either. + */ + if (change & new & R_SVCR_ZA_MASK) { + memset(env->zarray, 0, sizeof(env->zarray)); + } } =20 static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index f73bf4d285..e146c17ba1 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -44,18 +44,6 @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i) return; } aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); - - /* - * ResetSMEState. - * - * SetPSTATE_ZA zeros on enable and disable. We can zero this only - * on enable: while disabled, the storage is inaccessible and the - * value does not matter. We're not saving the storage in vmstate - * when disabled either. - */ - if (i) { - memset(env->zarray, 0, sizeof(env->zarray)); - } arm_rebuild_hflags(env); } =20 --=20 2.38.1 From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673519801; cv=none; d=zohomail.com; s=zohoarc; b=DiCxtGlNrE40oEhWRiwXmi3wOciFaygqXQiqnOdAF/3xoW4pdA6zK11u/VkLdQtgMBimpl5qfla1MuTqUanK+I6/QSeOlRN+Lmx4jsd70lwCBZNBCaegs7GiNpD4FjLveXWYxfef0IofXXJm5aFKvDIK9UGWiJFWJn1kuBgA2p4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673519801; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8CuYXoXmL7ijt24wyfbq14oA67+HiirVzpTtqD3Youw=; b=HXlb2EnHTSrm/A1zugDeo0E+fr9kqwMgbSVyMpUDGesJHynvm03FOvHk7Qi/+vX/R6kyiWtTYkix1ZXiBWCfRVsl5YdxUPaLovQUMeHFXKoGXThq2LIG7MswDWN0IBmnEXtm8bqUqGLNSikSBJosTn7ximoIJLbuqn3SUhlvt1M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673519801298516.9486632737281; Thu, 12 Jan 2023 02:36:41 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFuls-0002vp-IB; Thu, 12 Jan 2023 05:25:26 -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 1pFulk-0002tY-FY for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:12 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFuli-0000QN-P8 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:12 -0500 Received: by mail-wm1-x333.google.com with SMTP id c4-20020a1c3504000000b003d9e2f72093so11391173wma.1 for ; Thu, 12 Jan 2023 02:25:10 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id o2-20020a5d58c2000000b002bdbead763csm5246655wrf.95.2023.01.12.02.25.07 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:25:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8CuYXoXmL7ijt24wyfbq14oA67+HiirVzpTtqD3Youw=; b=qXH6pT4WCtj0i/rwINa5zec6fTTDvu8HOhmfPdwZZmq1LxcOE1NWLaZfaGCFFNfr7g //d2syim3zV3loqCd2wOolXc0fPzQ1ascdIw/4/b/BcAnS1n7N5G5HB7apFhrtroY5WJ JZpIl+ZuVYkrp8O0GG/f3diOieAkrVMOcPusASUeVpQ7gvQ3G4NI9j5FHPJnK/b/Vdz8 PKT+pAux546BeGtuAoR13tRrr/unaYNY0w9fvvCi+nuH4s+6rPN6Wamhze2p6S9Vm0nX KXWiC1d6qXK+V6Qw4gTjoZzNVvJR463CrX95RiQxhZ+aRAy/9JOr3eWhLjo/nfSQryJ0 HJEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8CuYXoXmL7ijt24wyfbq14oA67+HiirVzpTtqD3Youw=; b=wkhbNnChIP0qRxMIQhEHOapSppc8jUEWkT+JcQgszTGpUywD0blOnBMPPlsLiJf+Td 5vsByzKX1g4DMroaAofIrFMBLAU6RN8YtLgLAwlQG/dYB9lxS+kyTv0vOptWwcaV3xA3 e/3zIh41OzzR//h9SPLeI3M/BX7QNKnC+kf+FopdD3ENb5tnlAyn/QGUFP5E7uZgi/1R /RwPyyLWlfZoBxZwM6XO5Ee07aHhWFu4RO9ZCAbp7HN4rlI4leosXwLd1/7IZ7WVT5Ym mqCvYUrvrmuPTkk0B5x3zkjpyKxQ+tz8uhN/njIJLUMXSnfEwEKxvGCBQJKWcZ/K8r96 CDCA== X-Gm-Message-State: AFqh2komMyPZwjVDu9hU8bqXM5QxNcDgUbm8Nrj21R9+3w7uGz0BJxYV Fm7ZaVd83oX0zf8FsFTu3Wl9tVROKyNDSZDm X-Google-Smtp-Source: AMrXdXv0E740Gj4zdeLUgO1PDeboLfRNoq3S1aRClHrMOo1bSJCzY2cw23+UgfwQcHpdOk5fFrVFkA== X-Received: by 2002:a05:600c:5399:b0:3d9:c6f5:c63d with SMTP id hg25-20020a05600c539900b003d9c6f5c63dmr23428536wmb.28.1673519108795; Thu, 12 Jan 2023 02:25:08 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 6/7] target/arm/sme: Rebuild hflags in aarch64_set_svcr() Date: Thu, 12 Jan 2023 11:24:35 +0100 Message-Id: <20230112102436.1913-7-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673519801813100001 From: Richard Henderson Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- linux-user/aarch64/cpu_loop.c | 8 +------- linux-user/aarch64/signal.c | 3 --- target/arm/helper.c | 6 +++++- target/arm/sme_helper.c | 8 -------- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c index 5e93d27d8f..2e2f7cf218 100644 --- a/linux-user/aarch64/cpu_loop.c +++ b/linux-user/aarch64/cpu_loop.c @@ -89,14 +89,8 @@ void cpu_loop(CPUARMState *env) =20 switch (trapnr) { case EXCP_SWI: - /* - * On syscall, PSTATE.ZA is preserved, along with the ZA matri= x. - * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState. - */ + /* On syscall, PSTATE.ZA is preserved, PSTATE.SM is cleared. */ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); - if (FIELD_EX64(env->svcr, SVCR, SM)) { - arm_rebuild_hflags(env); - } ret =3D do_syscall(env, env->xregs[8], env->xregs[0], diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c index a326a6def5..b265cfd470 100644 --- a/linux-user/aarch64/signal.c +++ b/linux-user/aarch64/signal.c @@ -667,9 +667,6 @@ static void target_setup_frame(int usig, struct target_= sigaction *ka, =20 /* Invoke the signal handler with both SM and ZA disabled. */ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); - if (env->svcr) { - arm_rebuild_hflags(env); - } =20 if (info) { tswap_siginfo(&frame->info, info); diff --git a/target/arm/helper.c b/target/arm/helper.c index 26c3bb4cdf..cf77bdd378 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6735,6 +6735,9 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new,= uint64_t mask) { uint64_t change =3D (env->svcr ^ new) & mask; =20 + if (change =3D=3D 0) { + return; + } env->svcr ^=3D change; =20 if (change & R_SVCR_SM_MASK) { @@ -6752,6 +6755,8 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new,= uint64_t mask) if (change & new & R_SVCR_ZA_MASK) { memset(env->zarray, 0, sizeof(env->zarray)); } + + arm_rebuild_hflags(env); } =20 static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, @@ -6760,7 +6765,6 @@ static void svcr_write(CPUARMState *env, const ARMCPR= egInfo *ri, helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); aarch64_set_svcr(env, value, -1); - arm_rebuild_hflags(env); } =20 static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri, diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index e146c17ba1..3abe03e4cb 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -31,20 +31,12 @@ =20 void helper_set_pstate_sm(CPUARMState *env, uint32_t i) { - if (i =3D=3D FIELD_EX64(env->svcr, SVCR, SM)) { - return; - } aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); - arm_rebuild_hflags(env); } =20 void helper_set_pstate_za(CPUARMState *env, uint32_t i) { - if (i =3D=3D FIELD_EX64(env->svcr, SVCR, ZA)) { - return; - } aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); - arm_rebuild_hflags(env); } =20 void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) --=20 2.38.1 From nobody Sun May 19 09:23:51 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1673520305; cv=none; d=zohomail.com; s=zohoarc; b=UeXhsx07NPu6vnz9qynr9zvukDfRodt1l40DztkpdUDm513RYxnEybiDm3WSis2b0f3cRbZo7in81FVyz3LvUh9EBTJsSolHx/1QGYSIXn7N8pNDDIGdGnrrJ5lkbb1Zqmyh6n7rBvqJWJIkexhxHhWL0RCUYcdpXu4qTcp6rPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673520305; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mUA0s/OLF3irpYz8q/+5iIV+g6F7cgz94WGYfbGpTw8=; b=IJOx3uTpqmIOerckmrBU+F8ZB6s++cd+eFncJwSsmTtZDu3OmnCX68K1SB+wyS+bK1kSyRxrNGyPbQWh4sfWR3z7Z1Inbn91N2QC3dtLC6IDumbzSZTVJ6zvDMlYHdvZ4cScjLZAo2WrEsT8BhRnKiq9f55HCHNaQG8XFqUmnd4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTP id 1673520305885480.0060940568077; Thu, 12 Jan 2023 02:45:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFum3-00037K-Kz; Thu, 12 Jan 2023 05:25:31 -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 1pFulq-0002wQ-L8 for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:24 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pFuln-0000Wh-Es for qemu-devel@nongnu.org; Thu, 12 Jan 2023 05:25:18 -0500 Received: by mail-wm1-x336.google.com with SMTP id ay12-20020a05600c1e0c00b003d9ea12bafcso10817615wmb.3 for ; Thu, 12 Jan 2023 02:25:15 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id ay13-20020a05600c1e0d00b003d34faca949sm21317183wmb.39.2023.01.12.02.25.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Jan 2023 02:25:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mUA0s/OLF3irpYz8q/+5iIV+g6F7cgz94WGYfbGpTw8=; b=Sewkk4bCLwBH/pHnaleAQkGb1+NuBVt+ZNiur7WAfGsG1gemNpSTO7lxNQlBC5tOBG 4gLNx9CTD7F/sGHD7yeKdGNOJzKJEyZNxri4fVNbbAfgu7ShGM07pW/096/nVMMg+Kmb BRPRpghh+ABTSWdNyaREaB5P7UQxr4hQeeYCarGz0FeiHzKlQPCSaua7zmlRsgCvu6u8 zLdRLIbwYx6gfedLxMXIScVH8Ma4P/P+ZlkGqva8AnZ44zdvKk1Ua48b8UQ+3Qmabf9a ymWbGsEn21c6QGfgnj6b8VeCyk9UIKznn+8O3bLmHbJkhte9zAk/qi9mdfcmJukXzrsM PlGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mUA0s/OLF3irpYz8q/+5iIV+g6F7cgz94WGYfbGpTw8=; b=t98DOYIRpiEme6mQOb7B8LTAdiBl4bJ5T2ujIMdlk1klH299R2G3a46w/Lus6fN1xE Hk69sQxjLAClVRezlaibbBJnby/IlvvNpJOlI+EzeqB9KCZvIrXZCSqVT5w9lSyenNBO yAvDQvEIo0LSa3syTOKN26mQ0tSCKMmq0HZT0khUGHP321mSUtoeEykNckn/6XVcuSs1 snv4HKR81z0jVoYQupB0N8xUCqfilVu5fLMZPFLPfX+T5q8hSdxyhL0kBk9+N+kI5db9 2P/+xmkdob9lIn316LdRiQscTjtA5588hjbl8EF4jgxvaSI76izEGu3fJaVkNV1gXLQ4 qg1Q== X-Gm-Message-State: AFqh2kriMhQ7yFstp2VLZxYvLpr1U4EH2kXP2U1h4hvPZaRtscrFXCRc OlyOmaujxyNWiXZcO1pvCUYimCFptgShsSCU X-Google-Smtp-Source: AMrXdXtgiDGZ0K65M92CLuWZ1DFtL2LH2tGMcj0VmVv0DWUfdKRoXOGMym9eNC+lUvjlC/LXJtJUsw== X-Received: by 2002:a05:600c:19c7:b0:3d9:7096:262a with SMTP id u7-20020a05600c19c700b003d97096262amr48776350wmq.27.1673519113813; Thu, 12 Jan 2023 02:25:13 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Richard Henderson Cc: Laurent Vivier , Peter Maydell , Fabiano Rosas , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 7/7] target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr() Date: Thu, 12 Jan 2023 11:24:36 +0100 Message-Id: <20230112102436.1913-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230112102436.1913-1-philmd@linaro.org> References: <20230112102436.1913-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1673520307114100005 From: Richard Henderson Unify the two helper_set_pstate_{sm,za} in this function. Do not call helper_* functions from svcr_write. Signed-off-by: Richard Henderson Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Fabiano Rosas --- target/arm/helper-sme.h | 3 +-- target/arm/helper.c | 2 -- target/arm/sme_helper.c | 9 ++------- target/arm/translate-a64.c | 10 ++-------- 4 files changed, 5 insertions(+), 19 deletions(-) diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h index d2d544a696..27eef49a11 100644 --- a/target/arm/helper-sme.h +++ b/target/arm/helper-sme.h @@ -17,8 +17,7 @@ * License along with this library; if not, see . */ =20 -DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32) -DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32) +DEF_HELPER_FLAGS_3(set_svcr, TCG_CALL_NO_RWG, void, env, i32, i32) =20 DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32) =20 diff --git a/target/arm/helper.c b/target/arm/helper.c index cf77bdd378..1d74b95971 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6762,8 +6762,6 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new,= uint64_t mask) static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) { - helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM)); - helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA)); aarch64_set_svcr(env, value, -1); } =20 diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c index 3abe03e4cb..1e67fcac30 100644 --- a/target/arm/sme_helper.c +++ b/target/arm/sme_helper.c @@ -29,14 +29,9 @@ #include "vec_internal.h" #include "sve_ldst_internal.h" =20 -void helper_set_pstate_sm(CPUARMState *env, uint32_t i) +void helper_set_svcr(CPUARMState *env, uint32_t val, uint32_t mask) { - aarch64_set_svcr(env, 0, R_SVCR_SM_MASK); -} - -void helper_set_pstate_za(CPUARMState *env, uint32_t i) -{ - aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK); + aarch64_set_svcr(env, val, mask); } =20 void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 035e63bdc5..19cf371c4c 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1847,14 +1847,8 @@ static void handle_msr_i(DisasContext *s, uint32_t i= nsn, =20 if ((old ^ new) & msk) { /* At least one bit changes. */ - bool i =3D crm & 1; - - if ((crm & 2) && i !=3D s->pstate_sm) { - gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); - } - if ((crm & 4) && i !=3D s->pstate_za) { - gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); - } + gen_helper_set_svcr(cpu_env, tcg_constant_i32(new), + tcg_constant_i32(msk)); } else { s->base.is_jmp =3D DISAS_NEXT; } --=20 2.38.1