From: Atish Patra <atishp@rivosinc.com>
To: qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Cc: palmer@dabbelt.com, liwei1518@gmail.com,
zhiwei_liu@linux.alibaba.com, bin.meng@windriver.com,
dbarboza@ventanamicro.com, alistair.francis@wdc.com
Subject: [PATCH v2 00/13] Add RISC-V Counter delegation ISA extension support
Date: Tue, 23 Jul 2024 16:29:57 -0700 [thread overview]
Message-ID: <20240723-counter_delegation-v2-0-c4170a5348ca@rivosinc.com> (raw)
This series adds the counter delegation extension support. The counter
delegation ISA extension(Smcdeleg/Ssccfg) actually depends on multiple ISA
extensions.
1. S[m|s]csrind : The indirect CSR extension[1] which defines additional
5 ([M|S|VS]IREG2-[M|S|VS]IREG6) register to address size limitation of
RISC-V CSR address space.
2. Smstateen: The stateen bit[60] controls the access to the registers
indirectly via the above indirect registers.
3. Smcdeleg/Ssccfg: The counter delegation extensions[2]
The counter delegation extension allows Supervisor mode to program the
hpmevent and hpmcounters directly without needing the assistance from the
M-mode via SBI calls. This results in a faster perf profiling and very
few traps. This extension also introduces a scountinhibit CSR which allows
to stop/start any counter directly from the S-mode. As the counter
delegation extension potentially can have more than 100 CSRs, the specificaiton
leverages the indirect CSR extension to save the precious CSR address range.
Due to the dependancy of these extensions, the following extensions must be
enabled to use the counter delegation feature in S-mode.
"smstateen=true,sscofpmf=true,ssccfg=true,smcdeleg=true,smcsrind=true,sscsrind=true"
This makes the qemu command line quite tedious. In stead of that, I tried to
enable all PMU related extensions of ssccfg is set via newly introduced
preferred rule in last 3 patches. This approach was agreed upon in previous
revision[1] as well.
The first 2 patches decouple the indirect CSR usage from AIA implementation
while patch3 adds stateen bits validation for AIA.
The PATCH4 implements indirect CSR extensions while remaining patches
implement the counter delegation extensions.
The Qemu patches can be found here:
https://github.com/atishp04/qemu/tree/b4/counter_delegation
The Linux kernel patches can be found here (WIP version due to onging upstream
dependant patches):
https://github.com/atishp04/linux/tree/b4/counter_delegation
Changes from previous RFC version:
1. Renamed sxcsrind to csrind to align with other function names.
2. Enable sscofpmf by default for virt machine.
3. Introduced a preferred extension enabling rule strategy for generic
mult-extension dependencies.
4. Enables all PMU related extensions if ssccfg extension is set.
RFC Link:
https://lore.kernel.org/all/35a4d40c-9d0d-4a0a-a2c9-5d5f7def9b9c@ventanamicro.com/T/
[1] https://github.com/riscv/riscv-indirect-csr-access
[2] https://github.com/riscv/riscv-smcdeleg-ssccfg
Cc: kaiwenxue1@gmail.com
Signed-off-by: Atish Patra <atishp@rivosinc.com>
---
Atish Patra (7):
target/riscv: Enable S*stateen bits for AIA
target/riscv: Add configuration for S[m|s]csrind, Smcdeleg/Ssccfg
target/riscv: Invoke pmu init after feature enable
target/riscv: Enable sscofpmf for bare cpu by default
target/riscv: Repurpose the implied rule startergy
target/riscv: Add a preferred ISA extension rule
target/riscv: Enable PMU related extensions to preferred rule
Kaiwen Xue (6):
target/riscv: Add properties for Indirect CSR Access extension
target/riscv: Decouple AIA processing from xiselect and xireg
target/riscv: Support generic CSR indirect access
target/riscv: Add counter delegation definitions
target/riscv: Add select value range check for counter delegation
target/riscv: Add counter delegation/configuration support
target/riscv/cpu.c | 25 ++
target/riscv/cpu.h | 18 ++
target/riscv/cpu_bits.h | 34 ++-
target/riscv/cpu_cfg.h | 4 +
target/riscv/csr.c | 726 ++++++++++++++++++++++++++++++++++++++++++---
target/riscv/machine.c | 1 +
target/riscv/tcg/tcg-cpu.c | 109 ++++---
7 files changed, 845 insertions(+), 72 deletions(-)
---
base-commit: 225d5c7b671d5eaf86bf36d40e7da2d1de2cca84
change-id: 20240715-counter_delegation-10ab44c7d2c0
--
Regards,
Atish patra
next reply other threads:[~2024-07-23 23:31 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-23 23:29 Atish Patra [this message]
2024-07-23 23:29 ` [PATCH v2 01/13] target/riscv: Add properties for Indirect CSR Access extension Atish Patra
2024-07-26 7:42 ` Alistair Francis
2024-07-27 1:33 ` Atish Kumar Patra
2024-07-31 9:24 ` Alistair Francis
2024-08-07 7:53 ` Atish Kumar Patra
2024-07-23 23:29 ` [PATCH v2 02/13] target/riscv: Decouple AIA processing from xiselect and xireg Atish Patra
2024-08-06 0:05 ` Alistair Francis
2024-07-23 23:30 ` [PATCH v2 03/13] target/riscv: Enable S*stateen bits for AIA Atish Patra
2024-08-06 0:12 ` Alistair Francis
2024-08-07 7:53 ` Atish Kumar Patra
2024-07-23 23:30 ` [PATCH v2 04/13] target/riscv: Support generic CSR indirect access Atish Patra
2024-08-06 0:15 ` Alistair Francis
2024-08-07 7:50 ` Atish Kumar Patra
2024-07-23 23:30 ` [PATCH v2 05/13] target/riscv: Add counter delegation definitions Atish Patra
2024-08-06 0:36 ` Alistair Francis
2024-07-23 23:30 ` [PATCH v2 06/13] target/riscv: Add select value range check for counter delegation Atish Patra
2024-08-06 0:41 ` Alistair Francis
2024-07-23 23:30 ` [PATCH v2 07/13] target/riscv: Add counter delegation/configuration support Atish Patra
2024-08-06 1:21 ` Alistair Francis
2024-08-07 7:48 ` Atish Kumar Patra
2024-07-23 23:30 ` [PATCH v2 08/13] target/riscv: Add configuration for S[m|s]csrind, Smcdeleg/Ssccfg Atish Patra
2024-08-06 1:22 ` Alistair Francis
2024-07-23 23:30 ` [PATCH v2 09/13] target/riscv: Invoke pmu init after feature enable Atish Patra
2024-08-06 1:43 ` Alistair Francis
2024-07-23 23:30 ` [PATCH v2 10/13] target/riscv: Enable sscofpmf for bare cpu by default Atish Patra
2024-08-06 1:51 ` Alistair Francis
2024-08-06 8:27 ` Andrew Jones
2024-07-23 23:30 ` [PATCH v2 11/13] target/riscv: Repurpose the implied rule startergy Atish Patra
2024-07-23 23:30 ` [PATCH v2 12/13] target/riscv: Add a preferred ISA extension rule Atish Patra
2024-08-06 1:48 ` Alistair Francis
2024-08-07 7:46 ` Atish Kumar Patra
2024-07-23 23:30 ` [PATCH v2 13/13] target/riscv: Enable PMU related extensions to preferred rule Atish Patra
2024-08-06 8:46 ` Andrew Jones
2024-08-06 16:05 ` Daniel Henrique Barboza
2024-08-07 2:01 ` Alistair Francis
2024-08-07 7:43 ` Atish Kumar Patra
2024-08-08 0:27 ` Alistair Francis
2024-08-08 8:12 ` Atish Kumar Patra
2024-08-08 8:24 ` Alistair Francis
2024-08-09 21:40 ` Atish Kumar Patra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240723-counter_delegation-v2-0-c4170a5348ca@rivosinc.com \
--to=atishp@rivosinc.com \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).