From nobody Mon Nov 25 02:40:49 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=1719446460; cv=none; d=zohomail.com; s=zohoarc; b=CBR7QR4OxPlr/7SwAjM5COzLHsSb3yMrfLuukjRcBh+LSxU2qbE15sABuxbxeccUghx2alDSSAaHAsSsKrcSUnvyqI6JoHAeUwNw2a58yITBQh0fC5xUd32ulRLOhYAz7a+oMjA+QADyiNmPRj7+3DTxjGhb7laZNImj6SoMSVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719446460; h=Content-Type: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:To:To:Message-Id:Reply-To; bh=fDD9iROrIst0nip8AVI59daMkN6MkmnFrZb7icBkdaA=; b=FoLo4dFLAB8h2v2TCjlg2Fuxq+QuZlYbbLy0nA3G7qhyxKZHgIqjfLelWV9QfwZO+2WfT2thiubTXWrWKzb1eG8s/2GquPmeh88PKoqJ2g41mvdlyBb/nx3v3Q3CfShtSL8gwg303faZU7lFwIkRZsq2cIlJLj6NvcAajvS57mI= 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 1719446460693557.0002285026555; Wed, 26 Jun 2024 17:01:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMcWE-0007kD-6Z; Wed, 26 Jun 2024 19:57:42 -0400 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 1sMcWA-0007iN-RV for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:57:38 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcW8-0005VZ-Pz for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:57:38 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1f9b523a15cso8896225ad.0 for ; Wed, 26 Jun 2024 16:57:36 -0700 (PDT) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac998398sm630965ad.225.2024.06.26.16.57.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:57:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719446255; x=1720051055; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=fDD9iROrIst0nip8AVI59daMkN6MkmnFrZb7icBkdaA=; b=Zbemps1HShLr5mCdHbOrrLJwlo1uFeBrMA5Gt/+Rw2t6KYUGvdCV2WmIbTHv1yn9dN R2dKqnSRnm6Ot/uESh8exCb1TRhbYerxnkYO6ozaUyv4lViaQEnBYkGTvHu/AeYDO+y2 ABzBH3ZqabriHbYDtQKiE3E5tv+gXWn64aFVG1xizKSLtqJSsc88tBLrOzDLf/pMOQe6 xZDeHBDJldW+Fs0G8hxUy9S/nBNTTherxmn+WjxRHqHrAmhN5v7TXzxGr61XY2dwoXtu rbqjj/NtRHb5hAt5+AUZ++SNxdgk2C8b0DpTIGwuAnKQ79rWDGNbyJgtVG8MlsfZV7CY +QJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719446255; x=1720051055; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fDD9iROrIst0nip8AVI59daMkN6MkmnFrZb7icBkdaA=; b=DFjviEdfFRezj3GxsksgyM85fYgZEPaM28nETHL4piARJQY9mWP0Bfi+SsDmDeEG9G xOcQ79Al1NlHrXaQlizCAHp5CaBZkTzOy0g1J0HIPiJ5Ex9AjIBXgoP1wikOtwrba64R Y76riaGO4cUO3iI0zYzPO21/N+xO9ny4HxP/dnprCMj7CrBizmTE/MkjB+3X08DtBVXi JE7Hcf3W1pV5vaAQjuUHVlXYMkZhgZuLc/EpoiFBhp750GJXsmJAqktDSczN20r1JfZ0 UuTd5a/hwnnPTU9WXADlHQMxxEn+AWUB2VOa5BXtbFIuTiPNj/XsRGriDZRqh6BvwETZ NrXg== X-Forwarded-Encrypted: i=1; AJvYcCW0RgSlVifN9H703jGSKCavIFKVfTw2Vb1wDVC5Z4Qmw91uj7CJvAszACMEv7TcBdFG7HxGOE71Es5z5WYSFZy+w/PEvjs= X-Gm-Message-State: AOJu0YybleYUxwMP5Z7+24oVCOa5kGcEwmUnSEGJg1aLUvpmrxTtouxv RTmkVyniFN1sCKZUkL6SQ6oT2n914QFVK2jghXFNGdrDF6SDa4T7rMbdpp5f4rE= X-Google-Smtp-Source: AGHT+IEcmBcy+Wa9Je1rKDGQO1JMd2C3VZs5hzg1F2k0TlA5UG+ac0vLPWdghQjAlxHpWTyAyohatw== X-Received: by 2002:a17:902:d50e:b0:1fa:918e:ec6 with SMTP id d9443c01a7336-1fa918e1123mr37757155ad.61.1719446255377; Wed, 26 Jun 2024 16:57:35 -0700 (PDT) From: Atish Patra Date: Wed, 26 Jun 2024 16:57:22 -0700 Subject: [PATCH v7 02/11] target/riscv: Fix the predicate functions for mhpmeventhX CSRs MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240626-smcntrpmf_v7-v7-2-bb0f10af7fa9@rivosinc.com> References: <20240626-smcntrpmf_v7-v7-0-bb0f10af7fa9@rivosinc.com> In-Reply-To: <20240626-smcntrpmf_v7-v7-0-bb0f10af7fa9@rivosinc.com> To: qemu-riscv@nongnu.org, qemu-devel@nongnu.org Cc: Rajnesh Kanwal , Atish Patra , palmer@dabbelt.com, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, bin.meng@windriver.com, dbarboza@ventanamicro.com, alistair.francis@wdc.com X-Mailer: b4 0.15-dev-13183 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::632; envelope-from=atishp@rivosinc.com; helo=mail-pl1-x632.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 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: 1719446461107100001 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 --- 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 432c59dc66be..3ad851707e5c 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; @@ -5101,91 +5110,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