From patchwork Tue Jun 28 04:21:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 585488 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5036:0:0:0:0 with SMTP id e22csp422457mab; Mon, 27 Jun 2022 22:00:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v3tYL4OfETjDYWK3cDr5RwaaufA3ldjBGQwU6M20qnMnu5/lXZGIeUBicTR4V7plmKyGRz X-Received: by 2002:a05:6214:1c8c:b0:46e:15b2:3f35 with SMTP id ib12-20020a0562141c8c00b0046e15b23f35mr2244810qvb.76.1656392426369; Mon, 27 Jun 2022 22:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656392426; cv=none; d=google.com; s=arc-20160816; b=cQiiyWazz/TAMkQOQdnLF6v0rO9ssIrQRGfD4l2LFvcAAogxCwuK8luUqU0xVkw9o9 3KyrW2sdKPezIlai8HjCS8IWN93zSRlKdJtCkLgndd/406vMx4BDfYyy/qnVdOs6vWWZ WtDJpFvY+Lhsmw7T9sJ2osOjNdZnfdg6IpLk7CcrfkuUIG3ksoKcLeMA9TawAPjWF9S4 aBoL4hhxiWP2wTlBWEq2ZR5M8ESZqWQPySgUQ9UlENDoN5wQmITnx/JM+G1VGzZfFhh5 NYWUowl3MCc6IG8hH96afj7HcfjQgK6lVpx6/+xD+weZVbpZ9p4ELkZSNaz7fagVOVtg WuKw== 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=QMHowAe2qqOcR59WIhFIt7ar7qrWdpcyRnVo7s79wDU=; b=AQW7HsWCW+YfjgQ7P7Th3T3QoK8x/jL/FCKGbJS+S9PCx4sEheHTP3GZHsQeHj5Lkr OC8yr4J2hSRtdzLb+M+CY6M0bG1EJ24yIblR79nEFIiWbW9T0Vycl4oVrKXqGovPoaS2 CFZK/q8WJ7q2XAtqW65pT9JBzbUvQtwIkkksErrUxeEOBzoIB+Cx8keRk9Gyu9YJqR4n KGEmyWt+GTBZmU/8KAUjyAlWheoPZnMtMOUAFcNyQqz4jQqLlO20v/mNXuJfM/MR5Z/W cjTTP4mMoVcSZwT3eMBv2WSoPBKJCNrX9onHpXEOUOGC+2DMLO1srE4pdYZX3jOuTGUd 3fdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M2VRsroE; 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 c3-20020ac80083000000b00304e83203d3si6412755qtg.38.2022.06.27.22.00.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jun 2022 22:00:26 -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=M2VRsroE; 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]:46904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o63Kr-0000fU-Ra for patch@linaro.org; Tue, 28 Jun 2022 01:00:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o62kJ-0002iD-Eb for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:22:39 -0400 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]:47080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o62kH-0003us-OI for qemu-devel@nongnu.org; Tue, 28 Jun 2022 00:22:39 -0400 Received: by mail-pf1-x430.google.com with SMTP id a15so10860111pfv.13 for ; Mon, 27 Jun 2022 21:22:37 -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=QMHowAe2qqOcR59WIhFIt7ar7qrWdpcyRnVo7s79wDU=; b=M2VRsroE7qD9F2EoJaW/fOsPoy0uGgP2yzBaCecTaKYiZeb1uKLOyWq+O2N79SzT01 h8Y/lvnnHHKqayXwDmceSGXdMmILMvadNTRZYWZa00Bv/HhkMSunNidW0HHjXk7cyt2d JeolNr/+F9hndx5bMvMP8VcmDAPm6EJOkhpi0JOCz/iDQ3SjXsTdWThDJQX70ajT41CE b+lVy9BBkKv7FY4M6ykXMTOj7tziQbPnTdF/FUmi8j3+qXXD4iIN4sVOAtMOtb/ncDlU CkIgjMJ4TYyyka0eYyV5vGyRPgNDDp6Pni9zPOi3kLYCalDgdZ1XNwlrCoxRA4VmMUkw 4OVA== 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=QMHowAe2qqOcR59WIhFIt7ar7qrWdpcyRnVo7s79wDU=; b=opKi8w+bwQlJgJxyhRNR+3cOnavBAyIQdKTvgCgyBK7IePEDFV11AZ0ZZWBjXc8ChU apAhu58fQdgz2rQYchUR/NXERoFZuVQ9TV6xc/PurP+vL58y49j3+z6wLFmvAasFAO7Y 7OfbdvgC3dPm49RXz1Jvz2w0MWbipeIiEAd7dmKygMtjE1tED6Wcj6NE1CVJWG8RbewP 8nRoC67vXja6Gs5EqUqIv0OQXFvKoE7gCZoU543GwMbth1RfGq3RxVYX1o8fd0Mlrmna NgOh/5jYVWVK+v1nPlUzc03bUvd+yA00AgDxGedNE5zvVjBgkvZGPm9rmcZNfASwvMOq 8fxA== X-Gm-Message-State: AJIora+nFDjGwrTdJsz4cZctJcWBwyfQVoWGcQ7zTQ4tA/nvYzBCzgDl KlYrL3z2MTXK5mFj+g6B/5SSOSLhIbm1LQ== X-Received: by 2002:a63:7a49:0:b0:40c:ca38:aed7 with SMTP id j9-20020a637a49000000b0040cca38aed7mr15981612pgn.11.1656390156422; Mon, 27 Jun 2022 21:22:36 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id jg6-20020a17090326c600b0016a087cfad8sm7994929plb.264.2022.06.27.21.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jun 2022 21:22:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v4 31/45] target/arm: Reset streaming sve state on exception boundaries Date: Tue, 28 Jun 2022 09:51:03 +0530 Message-Id: <20220628042117.368549-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220628042117.368549-1-richard.henderson@linaro.org> References: <20220628042117.368549-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x430.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=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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We can handle both exception entry and exception return by hooking into aarch64_sve_change_el. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- 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 976e414eda..2dc1f95c6d 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);