From nobody Tue Nov 26 22:11:05 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=1703810941; cv=none; d=zohomail.com; s=zohoarc; b=H1h+tSPeXqiJK7QF9zpL2FUACwYJMVJsH875N5wGTlQdXmqAVI4k+9CcTe3HV/2RJ+ApzhW7EQge7e2gJjFwRJEwGXFbB8H6EJUHMXYEaDVa333dzHf7wUV2CQnz7hJH9J3jt3A+bZZtHEsk+Ip6PrgzWnjjTuL1ccmAdwxeGvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1703810941; h=Content-Transfer-Encoding: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:Cc; bh=KT0dgX+fbfi05uQpO/YMpPX7vZZAzvk8bOn5ql7e53k=; b=fJ3YFiF50ceO26Jm0caugCMNqdRFagpJr26nNFwPgC1KLDiRGfcPnShYWer2szVBH4wudYyZ9sLRIkJ+QzH7ZzNKQE0yQGoaLavRJMBXXQunOdslBDCJEhkWWHd2ClYEQDP74/PpWK9A0Mk6sQqLiu0F7CLaNbOlX3pj/Lz8jRg= 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 1703810941580145.77526442744738; Thu, 28 Dec 2023 16:49:01 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rJ12M-0003Ro-Pf; Thu, 28 Dec 2023 19:47:42 -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 1rJ12L-0003Ql-4M for qemu-devel@nongnu.org; Thu, 28 Dec 2023 19:47:41 -0500 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rJ12J-0002yT-Es for qemu-devel@nongnu.org; Thu, 28 Dec 2023 19:47:40 -0500 Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5cdfa676fa3so3095281a12.1 for ; Thu, 28 Dec 2023 16:47:39 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id z3-20020a170902ee0300b001d3561680aasm14393949plb.82.2023.12.28.16.47.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Dec 2023 16:47:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1703810857; x=1704415657; darn=nongnu.org; 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=KT0dgX+fbfi05uQpO/YMpPX7vZZAzvk8bOn5ql7e53k=; b=ulxC2axbHHzsCgtsPXMs1NHCfFI+nsKnwIafxjTspqPFX8L6ToHKoVcyu3AD5h2W+V 791OJyFTLLrZ5Dgngf9vKDzv7VowI5OtYTTaZ1cvMiI246MyRYsqonJNBDk1MyydrMNE at2r31tLumXQjwAPfnwFly+EoX0GkT89lCb76Z5b3L9Z6O3ju2nCY7dCBr08NwQcZRLd Tp8rRa0K2cXW46kVhBXULKnRXrunHLdBmgM0Jd9+XC+e1BJEWi3GiL6Wc3S+ra/XOsSU oW75E68JUcEYnCvOE7hH61eZJmN2PzVz7etf4Iz02xMYBSXZZPAd6PjI/oTEm9cUo99H woTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703810857; x=1704415657; 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=KT0dgX+fbfi05uQpO/YMpPX7vZZAzvk8bOn5ql7e53k=; b=YVuu+52PPMO3zKBkOIgD70tF7FzysxAvROhVXaaQvFDeRrEcnn4S59PiLk3vf8B5he AUfiTIF8oObsC3ma5s/+8KS04mxPnOUt5ospNSIiBJGi4swP/jqsso370fFWM/+y8zIK FRXyNq8LIokILq11ZOYHwvtJgYorfTOlHFnFpI4PMkfkROoaPBJ871Ws5i/qoZwGb4HX PavcbWxE2t1J3ydA+ua3b6W1osHsYR143+Hq/x5PXPNT8RM7R6O+hGlSEUAihC9/EWAU 0sIJR5nFGHBZ/A7ZX86V2QM6AyiCT60x4iXguL9NU40/ouugiEyVWj4L32Il5bBgVKGs q91A== X-Gm-Message-State: AOJu0YwLCP10EapE9xZsqAIGzEFpUAhBmvCWyTvP5Qq78RwRyrNe8d7J qTQD+oSo5qT9IOPcQZuvwX2xUyB8iNzLmead4u1De2JoiPY= X-Google-Smtp-Source: AGHT+IEE+awqnuXnv9wfkqPuuq2HD46EPQ8bY2SmOduADCedh8PArl0J60mleimxX3bgrXczdJq6Dg== X-Received: by 2002:a17:90a:740c:b0:28b:bd8a:1bf8 with SMTP id a12-20020a17090a740c00b0028bbd8a1bf8mr12684743pjg.35.1703810857583; Thu, 28 Dec 2023 16:47:37 -0800 (PST) From: Atish Patra To: qemu-devel@nongnu.org Subject: [v2 3/5] target/riscv: Add cycle & instret privilege mode filtering definitions Date: Thu, 28 Dec 2023 16:47:29 -0800 Message-Id: <20231229004731.3841550-4-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231229004731.3841550-1-atishp@rivosinc.com> References: <20231229004731.3841550-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::52a; envelope-from=atishp@rivosinc.com; helo=mail-pg1-x52a.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: 1703810943304100003 Content-Type: text/plain; charset="utf-8" From: Kaiwen Xue This adds the definitions for ISA extension smcntrpmf. Signed-off-by: Kaiwen Xue Signed-off-by: Atish Patra --- target/riscv/cpu.c | 1 - target/riscv/cpu.h | 6 ++++++ target/riscv/cpu_bits.h | 29 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index da3f05cd5373..54395f95b299 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1297,7 +1297,6 @@ const char *riscv_get_misa_ext_description(uint32_t b= it) const RISCVCPUMultiExtConfig riscv_cpu_extensions[] =3D { /* Defaults for standard extensions */ MULTI_EXT_CFG_BOOL("sscofpmf", ext_sscofpmf, false), - DEFINE_PROP_BOOL("smcntrpmf", RISCVCPU, cfg.ext_smcntrpmf, false), MULTI_EXT_CFG_BOOL("zifencei", ext_zifencei, true), MULTI_EXT_CFG_BOOL("zicsr", ext_zicsr, true), MULTI_EXT_CFG_BOOL("zihintntl", ext_zihintntl, true), diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index d74b361be641..34617c4c4bab 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -319,6 +319,12 @@ struct CPUArchState { =20 target_ulong mcountinhibit; =20 + /* PMU cycle & instret privilege mode filtering */ + target_ulong mcyclecfg; + target_ulong mcyclecfgh; + target_ulong minstretcfg; + target_ulong minstretcfgh; + /* PMU counter state */ PMUCTRState pmu_ctrs[RV_MAX_MHPMCOUNTERS]; =20 diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index ebd7917d490a..0ee91e502e8f 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -401,6 +401,10 @@ /* Machine counter-inhibit register */ #define CSR_MCOUNTINHIBIT 0x320 =20 +/* Machine counter configuration registers */ +#define CSR_MCYCLECFG 0x321 +#define CSR_MINSTRETCFG 0x322 + #define CSR_MHPMEVENT3 0x323 #define CSR_MHPMEVENT4 0x324 #define CSR_MHPMEVENT5 0x325 @@ -431,6 +435,9 @@ #define CSR_MHPMEVENT30 0x33e #define CSR_MHPMEVENT31 0x33f =20 +#define CSR_MCYCLECFGH 0x721 +#define CSR_MINSTRETCFGH 0x722 + #define CSR_MHPMEVENT3H 0x723 #define CSR_MHPMEVENT4H 0x724 #define CSR_MHPMEVENT5H 0x725 @@ -885,6 +892,28 @@ typedef enum RISCVException { /* PMU related bits */ #define MIE_LCOFIE (1 << IRQ_PMU_OVF) =20 +#define MCYCLECFG_BIT_MINH BIT_ULL(62) +#define MCYCLECFGH_BIT_MINH BIT(30) +#define MCYCLECFG_BIT_SINH BIT_ULL(61) +#define MCYCLECFGH_BIT_SINH BIT(29) +#define MCYCLECFG_BIT_UINH BIT_ULL(60) +#define MCYCLECFGH_BIT_UINH BIT(28) +#define MCYCLECFG_BIT_VSINH BIT_ULL(59) +#define MCYCLECFGH_BIT_VSINH BIT(27) +#define MCYCLECFG_BIT_VUINH BIT_ULL(58) +#define MCYCLECFGH_BIT_VUINH BIT(26) + +#define MINSTRETCFG_BIT_MINH BIT_ULL(62) +#define MINSTRETCFGH_BIT_MINH BIT(30) +#define MINSTRETCFG_BIT_SINH BIT_ULL(61) +#define MINSTRETCFGH_BIT_SINH BIT(29) +#define MINSTRETCFG_BIT_UINH BIT_ULL(60) +#define MINSTRETCFGH_BIT_UINH BIT(28) +#define MINSTRETCFG_BIT_VSINH BIT_ULL(59) +#define MINSTRETCFGH_BIT_VSINH BIT(27) +#define MINSTRETCFG_BIT_VUINH BIT_ULL(58) +#define MINSTRETCFGH_BIT_VUINH BIT(26) + #define MHPMEVENT_BIT_OF BIT_ULL(63) #define MHPMEVENTH_BIT_OF BIT(31) #define MHPMEVENT_BIT_MINH BIT_ULL(62) --=20 2.34.1