From patchwork Mon Jan 23 13:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 645553 Delivered-To: patch@linaro.org Received: by 2002:a17:522:b9de:b0:4b9:b062:db3b with SMTP id fj30csp2186384pvb; Mon, 23 Jan 2023 05:37:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXIUXgS8EJmhg1aHUHNwHdFnhRoLWQNNTyGsUB29iIMSoNXNVddyhg/8TqdOMADK9kFM3W X-Received: by 2002:a05:6214:32f:b0:532:299d:99c9 with SMTP id j15-20020a056214032f00b00532299d99c9mr32730453qvu.1.1674481035066; Mon, 23 Jan 2023 05:37:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674481035; cv=none; d=google.com; s=arc-20160816; b=qgqal2J872ZytK94l/euKhPdDzuTznak2IrdqSV3+eGq1xs11F9seh/8+vF5krjikP Mujf0y4VqmOzYXyk+XcWiVXIGvkZLOQKt6SdO5jkamvy4f89DVnvnqO/YipB95TNUgAc sxMy6xx3vMNjfImU4yeX6cYSnKPFsp7S+ZRbzujvmxsZq5fnK0ZR63Ece3SqhJJpdGvn szOFyD1rpOuTsBhGkegtiR0ZqV2wlPd4z8IIV25tVnleWH4oLoJSxdo9uELfdi4YeRH2 ceI4Gbyo8JNHOsTAtX6twG/4th2X+aiMgOQZz+zOXi/Ge26ObQPTAhYP2DOA36oCcA/H F10A== 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=vZk1C88uw/inCNfkrhOVPoUDXVTmPwNQrJRmUIYnoUY=; b=G/zkSzSi/fC+t8OnWECMh0LV6GVJ5VAqsYzwoIAMmP/BJ5VG2P8w/5QAW1G+bia9FL U0LpBFTwKBNJ/1qFenZX5uLV+grz3aA0yitIxOfcsdFtC4BvVXE0NgfxjZeMLxLZifWQ 8l7ngRgxGdbvx5oSZlYGBIkJ37XazB62ItGrVdhI/TWNDUzeIjEKBpa1F3Lk3MaiNoI5 hcjQgd8pMmwK3xsGDlZe8IUxCOKYf0/VLNHgdmNYR6DgR9CN+7t1jWCUcRdi5XDKAwmH ijtUVW6aGoWKQpKTdA0rmk23Y6o1nLdNf+PBbKhHlCLJ7f3bIV9cXk7ppFn1gS+mDqXg KcRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DptZjk2e; 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 og12-20020a056214428c00b00531c58053cfsi2081355qvb.253.2023.01.23.05.37.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jan 2023 05:37:15 -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; dkim=pass header.i=@linaro.org header.s=google header.b=DptZjk2e; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJx07-0006Ki-Ny; Mon, 23 Jan 2023 08:36:43 -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 1pJwzc-0005xL-1A for qemu-devel@nongnu.org; Mon, 23 Jan 2023 08:36:15 -0500 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pJwzY-0002PQ-VP for qemu-devel@nongnu.org; Mon, 23 Jan 2023 08:36:10 -0500 Received: by mail-wm1-x332.google.com with SMTP id e19-20020a05600c439300b003db1cac0c1fso9123819wmn.5 for ; Mon, 23 Jan 2023 05:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=vZk1C88uw/inCNfkrhOVPoUDXVTmPwNQrJRmUIYnoUY=; b=DptZjk2eRGxN815sOpbFJ2EIw6ZxsFCm/5ZtSXO0npbgZwwu65Nh/duBte92Lnf3JC MD5NWCv5n7LgazigWlq9CwnM9zSRX0/yx7YXzuox7/v9502O0sK2OXVofJkQYrDdhEBj 4LJqa4FNqxql/Sy+ectaRO+sNrwyNsU2AB2XnLvi3l/3+YF5XtUGtzFjAKvyXGHXyXFa b9s8df1WkKJHwUs+ol/UPgITDQMVOEb8bf17W8kowNichdevUHcbOMYHIdDh7nRWl2rR FjeLhPgUkWsXKXJ1n4l++UgQH/ryf5+8HtSAchaFlT5XNhfJLKbh7ZBzKDhxFdRopcJz xiVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vZk1C88uw/inCNfkrhOVPoUDXVTmPwNQrJRmUIYnoUY=; b=L2B+BhVKZ2Y/p1YY/xU3IxJUppO6R3MwKHpy5MBSN8fEzL+yoEvKjFzOYwYGMu8mH6 8ejvXkrqny5Q4/vUV0jJOKrl0MDixILJVbIG3G5seubyMSsBnhDNpe7oEXZVHNdY4wdV Y1XMl8JzlsT3S06XixKOgC284EmmqEgGrrMF3ZcB2E/ikNgIzAz/SxuyyapayZjQlvDF G4yk6DmR4nPSX3em4jLqqEYGE9HUzDLYeZ9gqvfjhgSp/CBRy4BKwhJPlm+if+M6dV8h sQNYJY332rO6zLHZbJhIwM4kcPSGfv2j3S8hTTBhT5c+t/eQPvYcBtKXtY539HTwMUa5 BEqg== X-Gm-Message-State: AFqh2kpnkWUFBxzJ2udXXlqwRK1YqU6Iyl/qgqzdrFfPnOKWTuBXLkVf S0UfJLROu7dEscFXwzZsyHow+KyyyyfdyZIA X-Received: by 2002:a05:600c:358b:b0:3db:2e6e:7826 with SMTP id p11-20020a05600c358b00b003db2e6e7826mr12685821wmq.5.1674480967527; Mon, 23 Jan 2023 05:36:07 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id d19-20020a05600c34d300b003a6125562e1sm10817457wmq.46.2023.01.23.05.36.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Jan 2023 05:36:06 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 13/26] target/arm/sme: Reorg SME access handling in handle_msr_i() Date: Mon, 23 Jan 2023 13:35:40 +0000 Message-Id: <20230123133553.2171158-14-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230123133553.2171158-1-peter.maydell@linaro.org> References: <20230123133553.2171158-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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 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: Richard Henderson Signed-off-by: Richard Henderson Reviewed-by: Fabiano Rosas Signed-off-by: Philippe Mathieu-Daudé Message-id: 20230112102436.1913-2-philmd@linaro.org Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2ee171f249c..35cc851246f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1841,18 +1841,20 @@ static void handle_msr_i(DisasContext *s, uint32_t insn, goto do_unallocated; } if (sme_access_check(s)) { - bool i = crm & 1; - bool changed = false; + int old = s->pstate_sm | (s->pstate_za << 1); + int new = (crm & 1) * 3; + int msk = (crm >> 1) & 3; - if ((crm & 2) && i != s->pstate_sm) { - gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); - changed = true; - } - if ((crm & 4) && i != s->pstate_za) { - gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); - changed = true; - } - if (changed) { + if ((old ^ new) & msk) { + /* At least one bit changes. */ + bool i = crm & 1; + + if ((crm & 2) && i != s->pstate_sm) { + gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i)); + } + if ((crm & 4) && i != s->pstate_za) { + gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i)); + } gen_rebuild_hflags(s); } else { s->base.is_jmp = DISAS_NEXT;