From patchwork Mon Jun 20 17:52:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 583193 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp933472mab; Mon, 20 Jun 2022 11:19:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t+5nDql1Q7J5SPjTkYGgnAqeuZQ5fPBMcELbGNbEKQnTL6/WDzuJRM5gEWaBS8WOmKnwCV X-Received: by 2002:a05:622a:1646:b0:305:955:9cf6 with SMTP id y6-20020a05622a164600b0030509559cf6mr20164080qtj.407.1655749156849; Mon, 20 Jun 2022 11:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655749156; cv=none; d=google.com; s=arc-20160816; b=TE6aGpL0F12xLzf5rSwvBPsLM4lSIuRPssUhe974f6oqRNGUQAnNWKRklu3MmHbCES kguCOFkYsQzJGXIATX5qVtdqkcsKGNMGCUaYqhJemz9r+otGpbngmCE5EXWH3mPnx7JG kNYiBKE7OyeY2iTrd+OLVpDpAYL8BDvM44QGbBIx9QQ7G5Ta1wW8i5HKDaJzEJTN+dDc Mq7N/VOMZVzVN+kqIUx8lr+VCzICfDB1JjTPkgnzB4uu0cod7MjRtfq3gxFCt1mxX6Gr e1QgftueZfj/1yxspQpoPBhmv0LoMoaJt9oF89qc+Eq0fcHR7juVe2KKFRS4j00FMMue R3tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zl3UQa9L83DTzd5dN0hhGMfsA9e6o+OsnHnXrS/Os6s=; b=KWAHntP8P5RE+3xU3Nd0LYmSLOQIfjui4ro8tUDo9bB/4xcEOznyLxBFzwYF1FCmwj YUen3eUvtM2S5DTIITxTv2IMdFSDLFk1KeGs6fpA+SUdjCrJSI7q82e03eFjnR/BVn7n r71g9l+FyHRpICfkYYmXS4Bx3ahQxjWcCzKd0X24wtO1Sxq2V0yNSjflJdfrYrZNkgwW H6XqVeJaJSBe/MNB+kdq6ndAXwWsDr4sZaySMXifbB3qE7uHJ/LKQ97HYX12AXq1JRZs igaYLwNdAWkqaDxWPO5Iv3ECaDuGOsjh3a655gXHoT9v+B8A4ODiEJ3T0giDaCORQH5/ tRXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xh2uG1T/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fq13-20020a056214258d00b0045b00bc6ba9si9298742qvb.349.2022.06.20.11.19.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 20 Jun 2022 11:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="xh2uG1T/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:53912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3LzY-0001XD-DE for patch@linaro.org; Mon, 20 Jun 2022 14:19:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3LaO-0006OV-Bb for qemu-devel@nongnu.org; Mon, 20 Jun 2022 13:53:18 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:43149) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3LaH-0001ZF-OS for qemu-devel@nongnu.org; Mon, 20 Jun 2022 13:53:12 -0400 Received: by mail-pj1-x1031.google.com with SMTP id y13-20020a17090a154d00b001eaaa3b9b8dso10987572pja.2 for ; Mon, 20 Jun 2022 10:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zl3UQa9L83DTzd5dN0hhGMfsA9e6o+OsnHnXrS/Os6s=; b=xh2uG1T/oYbbuFNqTvwHHhyXVAxgJZQei6IkfqezkwKW39CsLPX0qmRt5a0VDfn6Vm NlUplWm5ipFiQv8z8o4afiKAE6yYOwKZ4qZzz8tSCXkj2J0C8qBsaYgRthq+uUoUx9ek Kfy5+FFZL0dtS7qfm5SiPNgY29M+SUb1yYx+T2ln5eML2xISaRKJPgk79w0S2L/knmbS GDPx8xwd7haF9vKvTHetZveq4DeEWijg0s8lIxa58Ov63gbUAZ6/fUlw/p6I0ecPqjll q9pl3E6yYtGHZjoXejqTRbTMWoDAkzB/PmtJKd2txVgpYG6N0Kl36Uf8r6hpveU5HjCe UXgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zl3UQa9L83DTzd5dN0hhGMfsA9e6o+OsnHnXrS/Os6s=; b=Aegy+E+rbIwmKFO3ukr9phjFqmA5+8AOcV+h8Xd657QTmwySJJRtVCS9ZrmKnPxVyB tOjkD7K8FGV7nLrMXoxV9tlE33XIf6oFNkHEXCDFvck/J7LlsfHKcBZIdpipn1pAAU7M NUSrfDFrJakzS/EMsSBFXauroHeyp/Zvjb0aoCNKeQ+dinBVqmdiT3KqDZ5JFe3dOv7a K5+FqSH7Ndu+pCl8xPZCfJKi0rZT1ZEtHo7MWoGOI2JFCt08v1jEZ6sNVK8/jOkkngR7 ZH3QoVmZPrdLbmyVWmTZ0hGAgt/AmQP8St1I8TazKWc6WbWidMNMVGXmbWpYR7BHjU1Z t4tQ== X-Gm-Message-State: AJIora8RMsuoLJauR3FAIWXxQa2x4Wtv0Z0IDmD9M4cFQVSUB8yzd6d4 /pKqGd2mHGUdY78ks1tJps3MicQsKJ8vEA== X-Received: by 2002:a17:90a:2f87:b0:1ec:87b2:ff15 with SMTP id t7-20020a17090a2f8700b001ec87b2ff15mr16295045pjd.135.1655747588348; Mon, 20 Jun 2022 10:53:08 -0700 (PDT) Received: from stoup.. ([2602:47:d49e:3c01:a3e0:8a80:7b85:aea6]) by smtp.gmail.com with ESMTPSA id j14-20020aa7928e000000b00525133f98adsm5138138pfa.146.2022.06.20.10.53.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jun 2022 10:53:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Subject: [PATCH v3 37/51] target/arm: Reset streaming sve state on exception boundaries Date: Mon, 20 Jun 2022 10:52:21 -0700 Message-Id: <20220620175235.60881-38-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220620175235.60881-1-richard.henderson@linaro.org> References: <20220620175235.60881-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can handle both exception entry and exception return by hooking into aarch64_sve_change_el. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 26f4a4bc26..9c5b1a10eb 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11754,6 +11754,19 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, return; } + old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64; + new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64; + + /* + * Both AArch64.TakeException and AArch64.ExceptionReturn + * invoke ResetSVEState when taking an exception from, or + * returning to, AArch32 state when PSTATE.SM is enabled. + */ + if (old_a64 != new_a64 && FIELD_EX64(env->svcr, SVCR, SM)) { + arm_reset_sve_state(env); + return; + } + /* * DDI0584A.d sec 3.2: "If SVE instructions are disabled or trapped * at ELx, or not available because the EL is in AArch32 state, then @@ -11766,10 +11779,8 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, * we already have the correct register contents when encountering the * vq0->vq0 transition between EL0->EL1. */ - old_a64 = old_el ? arm_el_is_aa64(env, old_el) : el0_a64; old_len = (old_a64 && !sve_exception_el(env, old_el) ? sve_vqm1_for_el(env, old_el) : 0); - new_a64 = new_el ? arm_el_is_aa64(env, new_el) : el0_a64; new_len = (new_a64 && !sve_exception_el(env, new_el) ? sve_vqm1_for_el(env, new_el) : 0);