From patchwork Mon Jul 11 13:57:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 589374 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp3303562mab; Mon, 11 Jul 2022 07:34:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uo9lqSjuT40zbwzwZygUCQ6Qb3TiWTbjjxKWbZ5V7dEDToRRZRsAt/OYX1Tmf9elEF8Ayl X-Received: by 2002:ac8:5801:0:b0:31d:4c67:6f3 with SMTP id g1-20020ac85801000000b0031d4c6706f3mr14028206qtg.46.1657550068384; Mon, 11 Jul 2022 07:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657550068; cv=none; d=google.com; s=arc-20160816; b=jPEpnj9Gp0WCJyu+3qTP5c8kGzVQbV8mzt3zSZ2q29bQNqIG/JN9kmnkA/OyU2+6T3 0V5VRY/6JasgUH244ML7IyJ4Z85krKpooetq0ZyTH8vPxd3BtaiPBqAF2VYDV+oif1sz 67KgyuT1lAkgrhKm8KTP5C1wiBssu9Ci6cOpMgBOszDbv5cyaweefRSlVM+02EvQ4lNo zc3MgXbMegHpXN0Z6n8WuxNQ9ClQ7qWpEwyIee+VZf+ZybAz8Md3/xrJmS5q0dPvvhht X2r1PShOs85kXY6xt47sKEB9YlLGXo1DTwTMFPh/0NeiT6hCltXygKhLfm80eacLjm80 rD0Q== 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:to:from :dkim-signature; bh=HEJdzVygGY0s6uguuLvn1wUd1JpqYr/BZXBoM1CiCf4=; b=efYc3JLMoGBdjYvtw589d/4Fo+BNuoxBpLPe9x+YDfCRqVtleJmv26oKaiWqcReOVr OF1B+H28CkpNTzSVNTKkkQJFl08lE0KWrnaws7/CzgBHYI4+/8OquFd9OiT8IXWmNyZN B1cqiW5mtILxr3NMTqEY8yWSSilTN33lLjF8sTOmm83xqUOQyDwj3H3rHNvjtNh/fOMO VADxRMadaAXL3j/cgFJnGvXHc6L+WQPUsuv9uD/UrazlDP/IdbqKKSTy71u93bh3ZESz 1NS2zbSpfUTySEsMduRzZSgd/OGb5rbh1zdyCjUeS5OOy5k3VsikM8WHCvcLDv33mQ/E 0B7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d1KW+XGJ; 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 l26-20020a37f51a000000b006a711bb7498si3560353qkk.277.2022.07.11.07.34.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jul 2022 07:34:28 -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=d1KW+XGJ; 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]:42502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oAuUU-0007HJ-Pp for patch@linaro.org; Mon, 11 Jul 2022 10:34:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oAtvi-0006h6-Hp for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:31 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:38514) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oAtvd-0002kD-56 for qemu-devel@nongnu.org; Mon, 11 Jul 2022 09:58:30 -0400 Received: by mail-wr1-x42a.google.com with SMTP id v14so7135985wra.5 for ; Mon, 11 Jul 2022 06:58:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HEJdzVygGY0s6uguuLvn1wUd1JpqYr/BZXBoM1CiCf4=; b=d1KW+XGJCSbxzHD6ARnb2fXE0hJnIsFh4TZBWaPuGef+vJTtFbqpPO0KgWMlNdGDS/ ffRQEu5JQjj8O+Xaddel2jf/p5bZRQCUfIyWUXlsSWnC3Q/ZzMApMeoPW11yWk+33inO dmAoU3Ys714bmLiRZLuxBbwT4c9n4nL8JvfVy9BxPEeB/oAzpxNGsbc7QRb8yHfFBtas qVFkATwTHr+HfPm+b2Gm/Ao+gtZblpbMecMThgCNpn/XIkDSCC/TfciWzGY3kyUKCJb1 WBXz8NGm6iuWTTObvH5Q2tFZkCo3Ploo3fQNAYeouegWSDK5uB0/MEzEiixIepS0z6/b SG+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HEJdzVygGY0s6uguuLvn1wUd1JpqYr/BZXBoM1CiCf4=; b=peiWbs8w9V2aL1UwOHiaIaUlXTsVVcnXhNsS/LdFLXCssQcruPq0iXDX5jI9BiPqC9 Onmul3cBPFv4RxTPbH9/cAB6oI0PV7tkpAE/vFSWdVDVRTDT9VmRTe+yMnOcJR7v/sGE +r0MTOHt9yObh2fl/VEB271odPoXD7Lb/eDMhvv6BjWf/vnXTxOM05RAhl5gCty36J5b HCDAx9bgUngdR34jnmGODM/HBCk+zs3cJUZ4iyoVJUGsgxOU0css+gh/dHYXToIxfg3y HqOCdusS3UsHnOpr8cJ50tYa+SroIWi4fVyRFQjR7YqjjciZKiN0NuMYDW1CIDz9I1GI wD7g== X-Gm-Message-State: AJIora/eWsKwCN4JkGql9F2hNouVK5mgU37fiuAdU3UGf2HRlWoK9Xhl 0pmGCh8zR71V7Li5ZXOrpZKRj663G5vqyg== X-Received: by 2002:a05:6000:1ac8:b0:21b:9236:6207 with SMTP id i8-20020a0560001ac800b0021b92366207mr16684793wry.123.1657547898694; Mon, 11 Jul 2022 06:58:18 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id q123-20020a1c4381000000b00397402ae674sm7595596wma.11.2022.07.11.06.58.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 06:58:18 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 31/45] target/arm: Reset streaming sve state on exception boundaries Date: Mon, 11 Jul 2022 14:57:36 +0100 Message-Id: <20220711135750.765803-32-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220711135750.765803-1-peter.maydell@linaro.org> References: <20220711135750.765803-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42a.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" From: Richard Henderson 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 Message-id: 20220708151540.18136-32-richard.henderson@linaro.org Signed-off-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 73a5b2b86d9..cfcad97ce07 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11242,6 +11242,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 @@ -11254,10 +11267,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);