From patchwork Fri Jul 8 15:15:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 588531 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:bb16:0:0:0:0 with SMTP id jd22csp765281mab; Fri, 8 Jul 2022 08:32:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ujeg/PksXvkMXCUsNa/eakT8rfah5nesGzoG6tZsvsatC1n7X5s1XmXH9K8VUcU++EMoFE X-Received: by 2002:a05:620a:4843:b0:6ae:e906:ea49 with SMTP id ec3-20020a05620a484300b006aee906ea49mr2708086qkb.744.1657294336496; Fri, 08 Jul 2022 08:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657294336; cv=none; d=google.com; s=arc-20160816; b=r9saU3ZtkiwVfjdDfvxXgsVR5A3dMVi0QMKxztaYNNr/Pt/9gECskPrzNG4rF9euiA TJ5Ba1vVUnizJkKH0sB6VrEv/Vbl2Wj9hEx7oufvg/9avBgTcsdm7sunQgF956h9KG4D s80PYYdl3vMLoAibm5ako8H4iH4nY5swsk4kAIsZ+QDg0ZgFZ9ddjNFjno2xHPajgWal kYtteILvvKXAXMnbrPXjKbmFUYGVb9Ll66o+2Q1aqG8nRG0BdfiteKAc3hwzUeQwW8xT bZ3QPe4Oe57+M8ENnmUztyxlZkxVPexHSNr6qfFIf+h4WuB1zrcBKBE6FINjPIKuLkM1 CwcA== 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=PhJtFSrquOFUVO5QY9Q5zh4pNEWnYjCw2RgtobhuW2s=; b=Z5vEbE6eknTfgeXKwsORf3KkAO7cldOq5Tf6I9Dba/PRWDISD2F3Hh+g+P5ZWlJAkw drSEh/Y7VY6jDRnpN3zfUHMZK1YaTx9qJyD6K44grYqWkPjGwltnS5meoqo/2XyyM2JQ D0fVwYvsL4ZvhhdTJHIGu4AEkTJxrnZcphzVH1qNKmzNgB9EMHf9oVVo1Yq0VeBMSxYC aeU1a0VH4iLCbOSMd9knSDk2Iv8zI0Ps7MOjWwjNt8Buk7oJ5bixv3Qrir8uqSOcnoW/ cUEri1a9hCcMSR2ftZKJ5ykKvdqGadHAa5R1egK2W8OfIFSsmM52eN0Jd4YYlMQDACot A3Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lWMF37XJ; 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 r13-20020a0562140c4d00b0047339576991si2503617qvj.271.2022.07.08.08.32.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Jul 2022 08:32:16 -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=lWMF37XJ; 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]:34084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9pxo-000094-0f for patch@linaro.org; Fri, 08 Jul 2022 11:32:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37146) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9pid-0002b8-1o for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:16:36 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]:38884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o9pia-0002J7-Qd for qemu-devel@nongnu.org; Fri, 08 Jul 2022 11:16:34 -0400 Received: by mail-pf1-x435.google.com with SMTP id o12so10217842pfp.5 for ; Fri, 08 Jul 2022 08:16:32 -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=PhJtFSrquOFUVO5QY9Q5zh4pNEWnYjCw2RgtobhuW2s=; b=lWMF37XJ1jJ0MLY6VWKtYw/pp9ZqCPFDYoUDGnTqI6tvWpYlox6HKjlbtbjvpK0d+C rWWjUSmZrEEICbn/tVKAxOBnfU+ws2kR1YK2qf+hPqFCaB0+I6Fg+Pu5enn4HDoY2Vfn 9YFcS2FTz5lTyTYZDb+QsB1YqGfIDiHpDSN74bJoeKqk1pb1bnCgJxlNBtRvrz/WQ50e Rjco1rdq8GO8YZ9pZWBLny5j77IV0OjXG9ua/lQloW1YOtZzqM45PCQrGOSWnsv4e53R IRMNASxmT6a5TR1hNBLZZSu3lAea+0K5UkOTisqiUpABrKAfCHITMprcJMy4ZA1399HQ r77A== 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=PhJtFSrquOFUVO5QY9Q5zh4pNEWnYjCw2RgtobhuW2s=; b=lQWbh8NJ7VxwUCHkDejljFizWrHCZ4vVfxRVH7KILiRnnzHIQXfCWLhyI+Lk3iQSFf Q4NYoQpVBqDKkTrJDNGtqaMpcNW7NPzgSzx2rX1zB0/xS8OyFlCSkGOh/upuCq9XYYH4 ss9FYbCRpzaSK74KrBqYKXqDYdGJshrZNdd74o54eIP1WdShQQaeNNlBisImi5/z7zek +SJQgzeb0SHCuDwMBXJuf1qHtF6+7XCLT5LNcTpPZluYhgpmqNqda/Y8Eqbl5qOIwU6n Ird2p1VeYNnroDSDNtgVGJQvXAIuR+tT2UlSdB/I08GVtvWJWUatg7Zwjkejm9IeHJoX tjow== X-Gm-Message-State: AJIora/6oQgzxkz/d3neDr7IpgvAwhNaYy4u4bNpdzQyaCh98FVSrS9s f9N+NYdVY84QUZFJit0zAXDixVoOl54kFrHp X-Received: by 2002:a63:6703:0:b0:413:1f40:6cb5 with SMTP id b3-20020a636703000000b004131f406cb5mr3771235pgc.614.1657293391467; Fri, 08 Jul 2022 08:16:31 -0700 (PDT) Received: from stoup.. ([122.255.60.245]) by smtp.gmail.com with ESMTPSA id n17-20020a056a0007d100b0051bada81bc7sm29085774pfu.161.2022.07.08.08.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jul 2022 08:16:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v6 15/45] target/arm: Add SME enablement checks Date: Fri, 8 Jul 2022 20:45:10 +0530 Message-Id: <20220708151540.18136-16-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::435; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x435.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" These functions will be used to verify that the cpu is in the correct state for a given instruction. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.h | 21 +++++++++++++++++++++ target/arm/translate-a64.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/target/arm/translate-a64.h b/target/arm/translate-a64.h index 789b6e8e78..02fb95e019 100644 --- a/target/arm/translate-a64.h +++ b/target/arm/translate-a64.h @@ -29,6 +29,27 @@ void write_fp_dreg(DisasContext *s, int reg, TCGv_i64 v); bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn, unsigned int imms, unsigned int immr); bool sve_access_check(DisasContext *s); +bool sme_enabled_check(DisasContext *s); +bool sme_enabled_check_with_svcr(DisasContext *s, unsigned); + +/* This function corresponds to CheckStreamingSVEEnabled. */ +static inline bool sme_sm_enabled_check(DisasContext *s) +{ + return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK); +} + +/* This function corresponds to CheckSMEAndZAEnabled. */ +static inline bool sme_za_enabled_check(DisasContext *s) +{ + return sme_enabled_check_with_svcr(s, R_SVCR_ZA_MASK); +} + +/* Note that this function corresponds to CheckStreamingSVEAndZAEnabled. */ +static inline bool sme_smza_enabled_check(DisasContext *s) +{ + return sme_enabled_check_with_svcr(s, R_SVCR_SM_MASK | R_SVCR_ZA_MASK); +} + TCGv_i64 clean_data_tbi(DisasContext *s, TCGv_i64 addr); TCGv_i64 gen_mte_check1(DisasContext *s, TCGv_i64 addr, bool is_write, bool tag_checked, int log2_size); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 7fab7f64f8..b16d81bf19 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1216,6 +1216,40 @@ static bool sme_access_check(DisasContext *s) return true; } +/* This function corresponds to CheckSMEEnabled. */ +bool sme_enabled_check(DisasContext *s) +{ + /* + * Note that unlike sve_excp_el, we have not constrained sme_excp_el + * to be zero when fp_excp_el has priority. This is because we need + * sme_excp_el by itself for cpregs access checks. + */ + if (!s->fp_excp_el || s->sme_excp_el < s->fp_excp_el) { + s->fp_access_checked = true; + return sme_access_check(s); + } + return fp_access_check_only(s); +} + +/* Common subroutine for CheckSMEAnd*Enabled. */ +bool sme_enabled_check_with_svcr(DisasContext *s, unsigned req) +{ + if (!sme_enabled_check(s)) { + return false; + } + if (FIELD_EX64(req, SVCR, SM) && !s->pstate_sm) { + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, + syn_smetrap(SME_ET_NotStreaming, false)); + return false; + } + if (FIELD_EX64(req, SVCR, ZA) && !s->pstate_za) { + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, + syn_smetrap(SME_ET_InactiveZA, false)); + return false; + } + return true; +} + /* * This utility function is for doing register extension with an * optional shift. You will likely want to pass a temporary for the