From nobody Tue Nov 26 08:56:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1709146366; cv=none; d=zohomail.com; s=zohoarc; b=O+EHnbwjnmkY5epq73ekM9X5q4i4W6ccXnmqW3rSQvGddXrgZLquLpnHiSGJ2EKgBh4uJlexnTbvjFjmk5W439ZqtmkMZaXwKs1VDDv6wUa7fSOn0wM8j7QmGLHimofuCTEcdi3HHnEt3nXZsAcwV+ZA64rSWCqtXFNN1P2tLNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709146366; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:Message-Id:Reply-To:To; bh=7vH3VUY1zOLA7qqRfQ/TyWVihmXP/uPzN9vWw0YjNAA=; b=ksLzd9Odl5DgpAQDoPtnb+F3+xdTac0PbEx+U1c1JTNxDDUMlUunBBr/80D3NJTZ3W48679AfiHAhf+fuBcSskGKtzbpVYaRH+muGpLgWpUCN1EapXBXfMlMZmwOSEHofVIzBwNG72LWVLnQt2uyS5svoY4nQwaWHGRArWAqGY4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709146366820410.6351801561508; Wed, 28 Feb 2024 10:52:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rfP22-0000lM-Ia; Wed, 28 Feb 2024 13:51:54 -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 1rfP20-0000kd-Nr for qemu-devel@nongnu.org; Wed, 28 Feb 2024 13:51:52 -0500 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rfP1y-0006tw-PG for qemu-devel@nongnu.org; Wed, 28 Feb 2024 13:51:52 -0500 Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3c19b7d9de7so2071694b6e.2 for ; Wed, 28 Feb 2024 10:51:50 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id o20-20020a635d54000000b005dbed0ffb10sm49562pgm.83.2024.02.28.10.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 10:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1709146309; x=1709751109; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7vH3VUY1zOLA7qqRfQ/TyWVihmXP/uPzN9vWw0YjNAA=; b=vGg+0OCF17KGYS96CsHvecnY/nL2CtFPgKqz8Od4aAykEzGDIqA5ciDKl6dqk+axss MbvUPgtWMewuHlHL4AVVN81ej850kuLZOUh6NQWwhPZXK9X3oS/szy015aolqBd/M5xI CHw8v1yV6b32p9RUF3Eysq1hpCwfZSKtuJycZNUbUucBtn1JryhkWlolTtt8Jejivkn8 lKKTPQQxdg0seSntMlu4ZEEbPzuU+MQPoA8M4kBunVGVUKAygKG7sxiLqS/5X1KKj7q/ qzkFc7d1ECc9AKKDsgOAe2LL0px8EkUtTkFpbUJXeYnlsTGioeYkgrkmb3Q6fRvZfZ2D HEjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709146309; x=1709751109; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7vH3VUY1zOLA7qqRfQ/TyWVihmXP/uPzN9vWw0YjNAA=; b=Zs4C9HXVIBTzMAXtK4a1efXpXOBEfTlGgad2mihOwIh6DX8PZ8muGFQ3h7ghleb0Sd VuMHHMCa8G3pkJW2/mRvSCQEdCBPUbDM8H03QxhXHjxdaY1bkk7ahnVR4ZO05Qw+d0uz WOItq/ZgEZU0cO9i54+nKSIZz81hGkl34vXVjzoXn8gyJym1g2NGpZUEcG0k1Kaq4/zZ UmWnal9kJ5CKryRtSRD3xlfu8m9trp5weWizWp7AS+CoNzZ48CWfASACfOYhnIxYvfqx O+DuBE9/46LjIsPbteyHwxwPqKhDFvfCLfgFLc2ZQlKVmSgfWZ3T/q2tMcPTW5YJeL0r Y2RA== X-Forwarded-Encrypted: i=1; AJvYcCWqfSvEzqeykDHrRayiwPpLnjHXwXcsXSJhY1bvmZRRXTCH1RsYuaySmaU4rHZm7/Wqc4MhVcQZszI+1eLTGiO5+hQbij4= X-Gm-Message-State: AOJu0YwmErm8TxBc2OWUD+qozDwYD5jxXUi8194lm3hsSvmxPDcLcuwv xIuuMIs1aCCf7lSdCybb9w5OymcoiyzCnmrLOZtg2txYFGA+PJPTmNnW2R0iZyQ= X-Google-Smtp-Source: AGHT+IErEihPN3QBX/PuDNQLqefWqGx5Z/5EtJycJkUmzxkMFog8w4J2gI8JlP1nWcOMeU2q3SyNIA== X-Received: by 2002:a05:6808:1511:b0:3c1:b146:d9e5 with SMTP id u17-20020a056808151100b003c1b146d9e5mr5451705oiw.36.1709146309251; Wed, 28 Feb 2024 10:51:49 -0800 (PST) From: Atish Patra To: Cc: Daniel Henrique Barboza , Alistair Francis , Atish Patra , Bin Meng , Liu Zhiwei , Palmer Dabbelt , qemu-devel@nongnu.org, qemu-riscv@nongnu.org, Weiwei Li , kaiwenxue1@gmail.com Subject: [PATCH v5 1/5] target/riscv: Fix the predicate functions for mhpmeventhX CSRs Date: Wed, 28 Feb 2024 10:51:12 -0800 Message-Id: <20240228185116.1321730-2-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228185116.1321730-1-atishp@rivosinc.com> References: <20240228185116.1321730-1-atishp@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=atishp@rivosinc.com; helo=mail-oi1-x235.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @rivosinc-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1709146367533100004 Content-Type: text/plain; charset="utf-8" mhpmeventhX CSRs are available for RV32. The predicate function should check that first before checking sscofpmf extension. Fixes: 14664483457b ("target/riscv: Add sscofpmf extension support") Reviewed-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis Signed-off-by: Atish Patra Reviewed-by: LIU Zhiwei --- target/riscv/csr.c | 67 ++++++++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d4e8ac13b90c..a3d979c4c72c 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -227,6 +227,15 @@ static RISCVException sscofpmf(CPURISCVState *env, int= csrno) return RISCV_EXCP_NONE; } =20 +static RISCVException sscofpmf_32(CPURISCVState *env, int csrno) +{ + if (riscv_cpu_mxl(env) !=3D MXL_RV32) { + return RISCV_EXCP_ILLEGAL_INST; + } + + return sscofpmf(env, csrno); +} + static RISCVException any(CPURISCVState *env, int csrno) { return RISCV_EXCP_NONE; @@ -5035,91 +5044,91 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { [CSR_MHPMEVENT31] =3D { "mhpmevent31", any, read_mhpmevent, write_mhpmevent }, =20 - [CSR_MHPMEVENT3H] =3D { "mhpmevent3h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT3H] =3D { "mhpmevent3h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT4H] =3D { "mhpmevent4h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT4H] =3D { "mhpmevent4h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT5H] =3D { "mhpmevent5h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT5H] =3D { "mhpmevent5h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT6H] =3D { "mhpmevent6h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT6H] =3D { "mhpmevent6h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT7H] =3D { "mhpmevent7h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT7H] =3D { "mhpmevent7h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT8H] =3D { "mhpmevent8h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT8H] =3D { "mhpmevent8h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT9H] =3D { "mhpmevent9h", sscofpmf, read_mhpmevent= h, + [CSR_MHPMEVENT9H] =3D { "mhpmevent9h", sscofpmf_32, read_mhpmev= enth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT10H] =3D { "mhpmevent10h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT10H] =3D { "mhpmevent10h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT11H] =3D { "mhpmevent11h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT11H] =3D { "mhpmevent11h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT12H] =3D { "mhpmevent12h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT12H] =3D { "mhpmevent12h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT13H] =3D { "mhpmevent13h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT13H] =3D { "mhpmevent13h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT14H] =3D { "mhpmevent14h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT14H] =3D { "mhpmevent14h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT15H] =3D { "mhpmevent15h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT15H] =3D { "mhpmevent15h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT16H] =3D { "mhpmevent16h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT16H] =3D { "mhpmevent16h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT17H] =3D { "mhpmevent17h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT17H] =3D { "mhpmevent17h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT18H] =3D { "mhpmevent18h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT18H] =3D { "mhpmevent18h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT19H] =3D { "mhpmevent19h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT19H] =3D { "mhpmevent19h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT20H] =3D { "mhpmevent20h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT20H] =3D { "mhpmevent20h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT21H] =3D { "mhpmevent21h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT21H] =3D { "mhpmevent21h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT22H] =3D { "mhpmevent22h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT22H] =3D { "mhpmevent22h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT23H] =3D { "mhpmevent23h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT23H] =3D { "mhpmevent23h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT24H] =3D { "mhpmevent24h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT24H] =3D { "mhpmevent24h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT25H] =3D { "mhpmevent25h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT25H] =3D { "mhpmevent25h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT26H] =3D { "mhpmevent26h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT26H] =3D { "mhpmevent26h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT27H] =3D { "mhpmevent27h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT27H] =3D { "mhpmevent27h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT28H] =3D { "mhpmevent28h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT28H] =3D { "mhpmevent28h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT29H] =3D { "mhpmevent29h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT29H] =3D { "mhpmevent29h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT30H] =3D { "mhpmevent30h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT30H] =3D { "mhpmevent30h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, - [CSR_MHPMEVENT31H] =3D { "mhpmevent31h", sscofpmf, read_mhpmeven= th, + [CSR_MHPMEVENT31H] =3D { "mhpmevent31h", sscofpmf_32, read_mhpme= venth, write_mhpmeventh, .min_priv_ver =3D PRIV_VERSION_1_12_0 = }, =20 --=20 2.34.1