From patchwork Wed Dec 13 13:00:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 753519 Delivered-To: patch@linaro.org Received: by 2002:adf:ff85:0:b0:336:3f68:820c with SMTP id j5csp181819wrr; Wed, 13 Dec 2023 05:04:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwiTnjYkMefDya473nqDcmfBuFxQOFB1re/SBU/R9cDWKsR4r/RcQ1freYyx4DNFlxJj2a X-Received: by 2002:a05:6214:1145:b0:67a:a721:8303 with SMTP id b5-20020a056214114500b0067aa7218303mr9374304qvt.93.1702472695289; Wed, 13 Dec 2023 05:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702472695; cv=none; d=google.com; s=arc-20160816; b=CstxvKzfzWUJwzSypdK/8QSRYlJeSFRSmDIYyNir8gLuWHOFrBGRDbGWjd9KJekqu0 Tks6TNlgpWWybBp3yovEw7vwgUgFUYTs41Noc2TmN6EsTqUs6eBc+OSyh4IbUmYKJETS PdzI3qQLeBHKucPEbTGhvySJ9F1JW7hY7CVbKXYNtB/AE47ON9H16prXITggTXsZksq/ 4BXMtA4F4+jntav7vkWXj5KtwO8jlCnZDKQuDzGQmVHnIBHZpbfNfwME+OOaS5nFC1Fj OUhzkhJ/NB2Kq1s7/oi6h9GH1rxrKMmL73xEJZd4W4DXov3sO7E2C+Y5jxq4v6jrJk+D brwg== 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; bh=oQS5kruPWNrWN/rjnuBYGOiICTmX0kCqICs8/CP/ztY=; fh=xJ1URYKcMN3TM0/XAv5v+aCN+5tIbzAdcfBx5UNgoLw=; b=RgtofI4yE5k0NUtZJUBybW1yASjkN0bs39GCD7Zbvsp+6qzRu6cm5XJhKB0hqFLRTj vmoJoadoMz7agTL6oGcalg66R4xX/iy38J2vvX0AoX7EsCZUqxmabZTdilYWEG8Ma7wZ hJnXQtsGJHpgxgwA0eO5C3DNfEsd0ZiqLBUphVSW3iEDAKdqRrWcwRLEhC4NjYXb0+/r Z24UnofnKUrUs3QOTAaSq5i1y+h0Y1TZV6w4GuRxdnQwTFvz3G4Sn1LdYH6sJuTdzn1j FKgT/6iFDT+4Szf4qRGV2f+qKVYnN9CDIpmKb5IDk2rWqoB4B+MVm0U1GVb0mJPMdBG1 tU6A== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id eb7-20020ad44e47000000b0067effdafcb6si491996qvb.119.2023.12.13.05.04.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Dec 2023 05:04:55 -0800 (PST) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rDOuS-0004Ab-46; Wed, 13 Dec 2023 08:04:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDOsm-0000cB-L8; Wed, 13 Dec 2023 08:02:37 -0500 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rDOsj-0007Cg-IQ; Wed, 13 Dec 2023 08:02:35 -0500 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 15DF73B44A; Wed, 13 Dec 2023 16:01:06 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id AEE5A3C8DB; Wed, 13 Dec 2023 16:00:46 +0300 (MSK) Received: (nullmailer pid 1024784 invoked by uid 1000); Wed, 13 Dec 2023 13:00:46 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Peter Maydell , Richard Henderson , Michael Tokarev Subject: [Stable-7.2.8 23/24] target/arm: Disable SME if SVE is disabled Date: Wed, 13 Dec 2023 16:00:32 +0300 Message-Id: <20231213130041.1024630-23-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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-bounces+patch=linaro.org@nongnu.org From: Peter Maydell There is no architectural requirement that SME implies SVE, but our implementation currently assumes it. (FEAT_SME_FA64 does imply SVE.) So if you try to run a CPU with eg "-cpu max,sve=off" you quickly run into an assert when the guest tries to write to SMCR_EL1: #6 0x00007ffff4b38e96 in __GI___assert_fail (assertion=0x5555566e69cb "sm", file=0x5555566e5b24 "../../target/arm/helper.c", line=6865, function=0x5555566e82f0 <__PRETTY_FUNCTION__.31> "sve_vqm1_for_el_sm") at ./assert/assert.c:101 #7 0x0000555555ee33aa in sve_vqm1_for_el_sm (env=0x555557d291f0, el=2, sm=false) at ../../target/arm/helper.c:6865 #8 0x0000555555ee3407 in sve_vqm1_for_el (env=0x555557d291f0, el=2) at ../../target/arm/helper.c:6871 #9 0x0000555555ee3724 in smcr_write (env=0x555557d291f0, ri=0x555557da23b0, value=2147483663) at ../../target/arm/helper.c:6995 #10 0x0000555555fd1dba in helper_set_cp_reg64 (env=0x555557d291f0, rip=0x555557da23b0, value=2147483663) at ../../target/arm/tcg/op_helper.c:839 #11 0x00007fff60056781 in code_gen_buffer () Avoid this unsupported and slightly odd combination by disabling SME when SVE is not present. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2005 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20231127173318.674758-1-peter.maydell@linaro.org (cherry picked from commit f7767ca301796334f74b9b642b395a4bd3e3dbac) Signed-off-by: Michael Tokarev diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 38d066c294..6cf7a33591 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1498,6 +1498,16 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp) return; } + /* + * FEAT_SME is not architecturally dependent on FEAT_SVE (unless + * FEAT_SME_FA64 is present). However our implementation currently + * assumes it, so if the user asked for sve=off then turn off SME also. + * (KVM doesn't currently support SME at all.) + */ + if (cpu_isar_feature(aa64_sme, cpu) && !cpu_isar_feature(aa64_sve, cpu)) { + object_property_set_bool(OBJECT(cpu), "sme", false, &error_abort); + } + arm_cpu_sme_finalize(cpu, &local_err); if (local_err != NULL) { error_propagate(errp, local_err);