From patchwork Fri Jul 8 15:15:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588552 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp783191mab; Fri, 8 Jul 2022 08:54:14 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vGqSlb/A6MWUhJictlsEtwFzqziGPjMp8n6byAtG/MK1cHpGyUx/5hqoJ5x8n3S2ofpUVu X-Received: by 2002:a05:620a:6c5:b0:6af:3f4f:5b47 with SMTP id 5-20020a05620a06c500b006af3f4f5b47mr2813993qky.267.1657295654489; Fri, 08 Jul 2022 08:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657295654; cv=none; d=google.com; s=arc-20160816; b=F5RDFkD8DuaNEn839HKl/nZHseC0FMurlYKlbu6b2UElmo20xN2wpz5JXotwQslh4w TBtnGoUrI9+WxIjXN+VEUw9xx4rp0yjFrTGOlclbJuf0Ik8jX6zBNvtxZW+2nhsSU/q4 Jf7Y3cRamv13lYd3i4SmtciWgMDNddEkHysDKuSMtNvuFSZiNCWxiG9AdeMKlRfpsjia hxOT5J8GfjoAMhJEQj48H1Xt2ytGBNI3KEf7VZEiTE5CBOSubqoK9dQ1Ix8qY5edM4H7 2xq0U7MRb610Hqh+O+wZJBClLFc8e+kc75toapTowffQ1UxMrhchI++MUZR9oZ98Ee/1 I+mQ== 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=84H03quhV23tsQtptgYsSVgdXeP+LjLwInxbgDJtprk=; b=OpQVWxmCtmSk9t5CYAvqqtFNC5PlaeGYfj3ljLv+5bolYMhUi4RvpG5vJUN4ZOv4+x 0QntP3KmjPtVjVU10zza1NoLXugOkY+gp86COwOL9g4gCAPVElAF+Bc71cKgc6jTW4/d SZkwGKErJK0VP1kwDDHPLrT47XUq/AmIW1jAsPmWBlLKfnMSA2v77nUs+51q3wkvfzdA Eh6xG3C5PZ+YfVbU5Mk2qLTGaVYlRznxYTQ19ynxsDsIeff6PhqIwFABpnJgtTTr7kF+ EWMCn9jclkRSeKAJYJCIaxD7FzOGodSufRTkDJAvRKX9mj2pes0EkZcKJGEQMT9Qknlg pnpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Oz/TiA8M"; 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 cq12-20020a05622a424c00b002f92c911cbfsi9735824qtb.643.2022.07.08.08.54.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 08:54:14 -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="Oz/TiA8M"; 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]:35666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9qJ4-000825-3w for patch@linaro.org; Fri, 08 Jul 2022 11:54:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9pjQ-0004NX-0Q for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:17:24 -0400 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]:44605) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9pjO-0002TY-7b for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:17:23 -0400 Received: by mail-pg1-x52f.google.com with SMTP id bf13so9556735pgb.11 for ; Fri, 08 Jul 2022 08:17:21 -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=84H03quhV23tsQtptgYsSVgdXeP+LjLwInxbgDJtprk=; b=Oz/TiA8MmV3xIdM+MaurNIuOibDIJq9clPQeaz9a71rTsJbLiHTTesr937A8KG/OKV Nc7AD2D/1xFcWsqS3xG/4Xff7gGPFSxtzOsvxXQWaU4GwQjxYnAxnzW48UYddBAQM/+W A+Oxp9TXoxgZS2aNrT7Oq/LDEScveVl22bU2174Du6deXIad4QQI55IAGUxL62IQHMRc 4AIsoY6wWK9LRVjBicR4q+s1z/lhFLqdnybdJPIQ6lhBF+m/7hNF7s/RlSutIKAK9R8n jZoN6ZsWsY4xCelmiehmovy/zEbCubZLVT1Trw7PiDkzjlnlNNzrO9BNR/+luj7PDdBv dapg== 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=84H03quhV23tsQtptgYsSVgdXeP+LjLwInxbgDJtprk=; b=gty8Bb0jeCkJqDqrRoYWRUtn1bAOm4w+U7hdtt74K9n2dO2K0n2gTbw0vww4QF8133 m1YrzMcieD7FyKM2PSaBH8SSr9eRYGbYMEqSNwWLK5TVIHlcDc8A8oPIXSNCWGeJyptL zwdn0fLMCVQRGQXh+Poyy2w1hQosAvaxHCu3cxMKOjpLMO1wsJUsgT9KYY8fSjfhZOdU OL3wD4/8jKf9XEcAIGq7PlWHlvtyesF3lqOfBQS/Z+I4KbAIopQHoC9lKVD41gcpd3xS vLAubBiRzAOA63IaGt7jdGWxumUBGc3KbONMkBIonnrZ/zKMLfJZ7ErrOK66O9IaQFT2 roCw== X-Gm-Message-State: AJIora9yMoj/Zmvvg8EhTaRTPG77oZcztiZ6a8kqQV1PrliEqyqPgvq2 tPdqcgYK8GJ39l+bBsnE11lkMbPRi/exRvc/ X-Received: by 2002:a62:a113:0:b0:51c:1b4c:38d1 with SMTP id b19-20020a62a113000000b0051c1b4c38d1mr4453742pff.13.1657293439963; Fri, 08 Jul 2022 08:17:19 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id n17-20020a056a0007d100b0051bada81bc7sm29085774pfu.161.2022.07.08.08.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:17:19 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 31/45] target/arm: Reset streaming sve state on exception boundaries Date: Fri, 8 Jul 2022 20:45:26 +0530 Message-Id: <20220708151540.18136-32-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220708151540.18136-1-richard.henderson@linaro.org> References: <20220708151540.18136-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52f; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52f.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 73a5b2b86d..cfcad97ce0 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);