From patchwork Wed Jul 13 04:58:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 590064 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp194061max; Tue, 12 Jul 2022 22:03:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vLzzE4+EQlNnroGaJFO0SEbcIkRa8zdO6pgWdFgPyWZMRTjneMOXB0l7oQ10YKaVhXwQVt X-Received: by 2002:a05:6214:27c1:b0:473:85c9:3eeb with SMTP id ge1-20020a05621427c100b0047385c93eebmr1328652qvb.53.1657688595281; Tue, 12 Jul 2022 22:03:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657688595; cv=none; d=google.com; s=arc-20160816; b=PaP0Ebw8e/wIEa0mCd6Vcxa5rGCf9zS81pOxt3rBorDzbJlpDyjcG7fELaxfG4zSCk ToOO5ZDH8Q13+OJE9RjmjlXSi7P94ynsFw3/s+4LVBt97Up5JFmjReW2ko183+l9/yPi BgsKzyAih6TRx84KlT2iYlqc+uz9XGA/ZPzolsXfI89upz0qSJFlTEV4I6y/rDduHTQt jhasuCCEBk88pIkW2k/jo5T4sIgN1R/utdym6uGU5MdrdBmE+aDLO9WS8MHLu74f7pFl iU70EJFpzhmOSldjE82X+9YCtjBmHIYSfWbdUARu5OUtF8UKcxQAfCX058mxtULXJJN8 z/Xg== 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=adgTAr9VDfDVcGX7dOUKK/5iltOe5AGqwdazS0Dpj50=; b=KXBI8nrExXbRe920GUICs1Iuu/baGXHkm/wqYl3/HuqKCZkF6Bnpsq/WUFRMADw3eq 1MBdGVnahqB9U1+zFrGkQyKmMIdV66IGSKw+Ar9aymmMpytaXSZllzwJW/hP3FKbxQGe i9SFa67hMVr9b1Krrnwn15ReTD8izKqiWP7x59/DRmMwVpMvYxxAVOg4tc8rkH2mUvM1 lqkTEtLQF3+9Uu84FblNCiebYjOsWHeshMi1AsNyM+abswVIy4iUFvsWZgPGhl6Y6vwh GFZWGfjlp4VRwdppoDssbvTexAv07UOfzBdRgXHwVVAi/4Sp933KNY5AD09I2vwH8iLo 4DQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PqX9403U; 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 o3-20020a0562140e4300b004730a0db001si1340749qvc.203.2022.07.12.22.03.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jul 2022 22:03:15 -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=PqX9403U; 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]:49220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBUWo-0003iP-TV for patch@linaro.org; Wed, 13 Jul 2022 01:03:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBUSj-0000xd-1i for qemu-devel@nongnu.org; Wed, 13 Jul 2022 00:59:01 -0400 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]:41588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oBUSh-0006rE-HT for qemu-devel@nongnu.org; Wed, 13 Jul 2022 00:59:00 -0400 Received: by mail-pg1-x52a.google.com with SMTP id 23so9451881pgc.8 for ; Tue, 12 Jul 2022 21:58:59 -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=adgTAr9VDfDVcGX7dOUKK/5iltOe5AGqwdazS0Dpj50=; b=PqX9403U7TMHZ1GrCG2x6F1rPzzkR7rnFAuEeXOCRi2vgmBPFprTI5Wgh2QHvyCO8q F5tRyR+DDq4PZxbsoIJTVW1rhNAMM0JSRvlX1JpKdQy1vn7Iwfh4Sb81IZpXeuPwe0k5 2KxZNAEZiPkUJPggBgfi3ys9X9/miDHo/wGR7qQ502KcGpIAmc+m2beRIEmM69Zplouz +259hy+5EIv9GD2urFg0qjYwDXWZV5zgxNRmFDy48eygsxyO5fQFQvgZ773DrlzxSqa9 FJAHilhUOzSIbe2bQXAfVWycTdyQd1vmAdDw5mFqeBJGCPCGaOPKDa7UI1QUNM9NaBOk hwqg== 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=adgTAr9VDfDVcGX7dOUKK/5iltOe5AGqwdazS0Dpj50=; b=mM/qYYGxtgiDzyKJlhCR79rZm/DP9B+tc6Rs6RBK5/DjYkXz1n5BFWVox/nRu2nCHD gFTChnEZpO3xm+MXlKBmOOhh2XEu1XQqX0+k6ktquhU0iLuhuY2hFlzt2kxyMBDZm3zL vShIjoJYCZDN2ey7e1zLp/18MsaLTndhoA7BcBCTmN8aN6Rf9ZvQ4IpgDGKqNVucQel5 kxTn93CqJ9mOnWmIl3bkOKFjM51g9vFDRXIebiOd3FSj8UyVUrgQGdp65uNQSu9HIynM iPrFllnwKIe5scwy/XyDiU/xIW9wDXOUYLM74sGo/++bRiY6JLFXgCaQf6k1bY+6R+1p lC1Q== X-Gm-Message-State: AJIora+wbgBQwzvP3lpo2+FN4XGExun21PlDzltagMpOoXXF7zpTc6gZ GSqiJqrTQwUHm/18rNhJZ2X3s2jNT6TqtNAB X-Received: by 2002:a63:20a:0:b0:411:909f:8ae2 with SMTP id 10-20020a63020a000000b00411909f8ae2mr1523086pgc.132.1657688338182; Tue, 12 Jul 2022 21:58:58 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id d194-20020a621dcb000000b00525302fe9c4sm7677047pfd.190.2022.07.12.21.58.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 21:58:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: broonie@kernel.org, qemu-arm@nongnu.org Subject: [PATCH 1/2] target/arm: Fill in VL for tbflags when SME enabled and SVE disabled Date: Wed, 13 Jul 2022 10:28:47 +0530 Message-Id: <20220713045848.217364-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713045848.217364-1-richard.henderson@linaro.org> References: <20220713045848.217364-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52a; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52a.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" When PSTATE.SM, VL = SVL even if SVE is disabled. This is visible in kselftest ssve-test. Reported-by: Mark Brown Signed-off-by: Richard Henderson --- target/arm/helper.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index cfcad97ce0..6fff7fc64f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -10882,13 +10882,19 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, } if (cpu_isar_feature(aa64_sme, env_archcpu(env))) { int sme_el = sme_exception_el(env, el); + bool sm = FIELD_EX64(env->svcr, SVCR, SM); DP_TBFLAG_A64(flags, SMEEXC_EL, sme_el); if (sme_el == 0) { /* Similarly, do not compute SVL if SME is disabled. */ - DP_TBFLAG_A64(flags, SVL, sve_vqm1_for_el_sm(env, el, true)); + int svl = sve_vqm1_for_el_sm(env, el, true); + DP_TBFLAG_A64(flags, SVL, svl); + if (sm) { + /* If SVE is disabled, we will not have set VL above. */ + DP_TBFLAG_A64(flags, VL, svl); + } } - if (FIELD_EX64(env->svcr, SVCR, SM)) { + if (sm) { DP_TBFLAG_A64(flags, PSTATE_SM, 1); DP_TBFLAG_A64(flags, SME_TRAP_NONSTREAMING, !sme_fa64(env, el)); } From patchwork Wed Jul 13 04:58:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 590065 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5817:0:0:0:0 with SMTP id j23csp195411max; Tue, 12 Jul 2022 22:05:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sDO0ElKMbH0j9nlMno/zDn/ywRmiJSd+6x6SBDB3mI25o4V/EAdYWZyivs8/3o3cdLgvsT X-Received: by 2002:a05:622a:1802:b0:31e:af62:5701 with SMTP id t2-20020a05622a180200b0031eaf625701mr1285251qtc.327.1657688700177; Tue, 12 Jul 2022 22:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657688700; cv=none; d=google.com; s=arc-20160816; b=khgRd3J+ERV5da4beEWJOtqcssVgsOdmUjDxhv2ythzWiUuwHUCanV/nffZu8xSoJS RQmP2dsaLqJp8dwHqDS4S3pDr8agvWsNVyvystGGWSTVZTKzoDFsuFLb4a1qiPRLdtYZ f+dFLMH1qMnwE9HBAXioq2pcsrffuk8vZadnmVUvjww0cEyVy7scBSSSpJN0vaKEWpL/ mA6IJyi7ApgxZi+0ui4iyz3S39BMfsolpT+OJZY8gqZZq6OUij4VLm6YrpPkh58EPgLD CRis04FwHm7Que5e9PNXUiOb1tcLsunh9RA0IM19S1lMSLgepcUIs07kfieLDYUs0D4M OgpQ== 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=H0h1mijfb/JBmMIsG1ho4eH5ZlC4TyS0gLWzNfX6jB0=; b=bc1WtMOW7BJWSl6vC37+QL5kv3vNdMjVj3yYg06PJbuNCpVzRGACWmIhVFyvJGwv2m OvngYXgvkIprhfK1D7CTkT9nQ3oso/gAN4mTk+GIjpFDm6wBPF2DQUPXABUItqGEMCIU 0R886GiYnvjqViGChu5VYl3CCVJpYgrvdcANsdCRJycxrMswfO+U4tDwT3WYw2KVZ7dk mqBadYuYPSHFXc1dmztS9mlx8CXCtHuuhhCczGrPHVNcqg3W3vyRSnmlmg+6h28xyRWK WXS+ODZ+/d0svGRzrZrSlCfX9itSpb2j/8pkXBrmha6YBrCXFUBrWPWAhnM35VVU+nnK wAJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Um2W1PLj; 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 i6-20020a05620a248600b006b56ce4ad13si8484576qkn.358.2022.07.12.22.05.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Jul 2022 22:05:00 -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=Um2W1PLj; 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]:51628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oBUYV-0005Lw-Pm for patch@linaro.org; Wed, 13 Jul 2022 01:04:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oBUSq-0001B5-5v for qemu-devel@nongnu.org; Wed, 13 Jul 2022 00:59:08 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]:36580) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oBUSk-0006rw-2d for qemu-devel@nongnu.org; Wed, 13 Jul 2022 00:59:07 -0400 Received: by mail-pj1-x1034.google.com with SMTP id z12-20020a17090a7b8c00b001ef84000b8bso1791419pjc.1 for ; Tue, 12 Jul 2022 21:59:01 -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=H0h1mijfb/JBmMIsG1ho4eH5ZlC4TyS0gLWzNfX6jB0=; b=Um2W1PLjch0aH+/d4eDtNA/Xw2OpL6Z6fnYnDEPLyYkGENxcYExIubl6SknSvYwo+Q jZpDWmDw2iZe5/gIbCO2J3eQBXG5hPWqeWC8UZjWIAJ/U5rX7i6xPxrJJA+uWogdwzkH S2fo8Zu1trTE5UVzSGM46Ax8EWi5BsyLtJ9Vkwk/pYslkP6VuMEo8kxniNvYreOIBrsg JINfuxoMahU+jTeKMFUOnSOMfk4A9EmwAoADRS4rm0cCfzpGTr1QRyoGnSDbT0v9hqYq nReQ6TEaE9CnogdI9/fuir68MtEylw7/tMdhvZ5vaygrtkpQv/1tgyjlvV9l7B73R66w F4Ng== 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=H0h1mijfb/JBmMIsG1ho4eH5ZlC4TyS0gLWzNfX6jB0=; b=n4fCpDXitdryae4ncawfyKvEpIvX7hl+pn3sCg0YNPoYOhxq8sxyJ81Fm85UmUyNbB 99a1uV+N7EKisOgm/RQ7BnMdD5ZJjsos3VTIYiKReeI8KFOxcDHmCTpZQYx2hVk3Yuo2 xZV4BRcK6Z9akwyTtH425TaQa7s3LkuSWbnXCuEUnC1/VKYM7DuA0Jc1Lt5siuqt5Mc7 BGgluzl+TlRRvQPGV6Gb5PVdgAGesF6rpjItKZE10JtLncYsjx8FFWydMkj51CGGJ+Mk SOqZgvLiy3gop7UmZ5E01wmuW8wIM4wlJ0gn+SlkwsBR78C31XzofXyi7/nZuUEcWev7 57jg== X-Gm-Message-State: AJIora8XYduMDxbXYAdKGE55MceMrhgj/0UDu0xsrixZ8F/stttXyehm LUEugFbIh0qbvAMtZci21i2L++NaPdlO5vt+ X-Received: by 2002:a17:903:26c1:b0:16b:df40:e566 with SMTP id jg1-20020a17090326c100b0016bdf40e566mr1435578plb.121.1657688340781; Tue, 12 Jul 2022 21:59:00 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id d194-20020a621dcb000000b00525302fe9c4sm7677047pfd.190.2022.07.12.21.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jul 2022 21:59:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: broonie@kernel.org, qemu-arm@nongnu.org Subject: [PATCH 2/2] target/arm: Fix aarch64_sve_change_el for SME Date: Wed, 13 Jul 2022 10:28:48 +0530 Message-Id: <20220713045848.217364-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220713045848.217364-1-richard.henderson@linaro.org> References: <20220713045848.217364-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 were only checking for SVE disabled and not taking into account PSTATE.SM to check SME disabled, which resulted in vectors being incorrectly truncated. Signed-off-by: Richard Henderson --- target/arm/helper.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 6fff7fc64f..24c45a9bf3 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11228,6 +11228,21 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq) } } +static uint32_t sve_vqm1_for_el_sm_ena(CPUARMState *env, int el, bool sm) +{ + int exc_el; + + if (sm) { + exc_el = sme_exception_el(env, el); + } else { + exc_el = sve_exception_el(env, el); + } + if (exc_el) { + return 0; /* disabled */ + } + return sve_vqm1_for_el_sm(env, el, sm); +} + /* * Notice a change in SVE vector size when changing EL. */ @@ -11236,7 +11251,7 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, { ARMCPU *cpu = env_archcpu(env); int old_len, new_len; - bool old_a64, new_a64; + bool old_a64, new_a64, sm; /* Nothing to do if no SVE. */ if (!cpu_isar_feature(aa64_sve, cpu)) { @@ -11256,7 +11271,8 @@ void aarch64_sve_change_el(CPUARMState *env, int old_el, * 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)) { + sm = FIELD_EX64(env->svcr, SVCR, SM); + if (old_a64 != new_a64 && sm) { arm_reset_sve_state(env); return; } @@ -11273,10 +11289,13 @@ 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_len = (old_a64 && !sve_exception_el(env, old_el) - ? sve_vqm1_for_el(env, old_el) : 0); - new_len = (new_a64 && !sve_exception_el(env, new_el) - ? sve_vqm1_for_el(env, new_el) : 0); + old_len = new_len = 0; + if (old_a64) { + old_len = sve_vqm1_for_el_sm_ena(env, old_el, sm); + } + if (new_a64) { + new_len = sve_vqm1_for_el_sm_ena(env, new_el, sm); + } /* When changing vector length, clear inaccessible state. */ if (new_len < old_len) {