[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 0/7] target/riscv: Add support for Control Transfer Records Ex
From: |
Rajnesh Kanwal |
Subject: |
[PATCH v4 0/7] target/riscv: Add support for Control Transfer Records Ext. |
Date: |
Wed, 4 Dec 2024 17:56:38 +0500 |
This series enables Control Transfer Records extension support on riscv
platform. This extension is similar to Arch LBR in x86 and BRBE in ARM.
The Extension has been stable and this series is based on v1.0_rc6 [0]
CTR extension depends on both the implementation of S-mode and Sscsrind
extension v1.0.0 [1]. CTR access ctrsource, ctrtartget and ctrdata CSRs using
sscsrind extension.
The series is based on Smcdeleg/Ssccfg counter delegation extension [2]
patches [3]. CTR itself doesn't depend on counter delegation support. This
rebase is basically to include the Smcsrind patches.
Here is the link to a quick start guide [4] to setup and run a basic perf demo
on Linux to use CTR Ext.
Qemu patches can be found here:
https://github.com/rajnesh-kanwal/qemu/tree/b4/ctr_upstream_v4
Opensbi patch can be found here:
https://github.com/rajnesh-kanwal/opensbi/tree/ctr_upstream_v2
Linux kernel patches can be found here:
https://github.com/rajnesh-kanwal/linux/tree/b4/ctr_upstream_v2
[0]:
https://github.com/riscv/riscv-control-transfer-records/releases/tag/v1.0_rc6
[1]:
https://github.com/riscvarchive/riscv-indirect-csr-access/releases/tag/v1.0.0
[2]: https://github.com/riscvarchive/riscv-smcdeleg-ssccfg/releases/tag/v1.0.0
[3]: https://lore.kernel.org/all/20240217000134.3634191-1-atishp@rivosinc.com/
[4]:
https://github.com/rajnesh-kanwal/linux/wiki/Running-CTR-basic-demo-on-QEMU-RISC%E2%80%90V-Virt-machine
Signed-off-by: Rajnesh Kanwal <rkanwal@rivosinc.com>
---
Changelog:
v4: Improvements based on Richard Henderson's feedback.
- Refactored CTR related code generation to move more code into
translation side and avoid unnecessary code execution in generated
code.
- Added missing code in machine.c to migrate the new state.
v3: Improvements based on Jason Chien and Frank Chang's feedback.
- Created single set of MACROs for CTR CSRs in cpu_bit.h
- Some fixes in riscv_ctr_add_entry.
- Return zero for vs/sireg4-6 for CTR 0x200 to 0x2ff range.
- Improved extension dependency check.
- Fixed invalid ctrctl csr selection bug in riscv_ctr_freeze.
- Added implied rules for Smctr and Ssctr.
- Added missing SMSTATEEN0_CTR bit in mstateen0 and hstateen0 write ops.
- Some more cosmetic changes.
-
https://lore.kernel.org/qemu-riscv/20241104-b4-ctr_upstream_v3-v3-0-32fd3c48205f@rivosinc.com/
v2: Lots of improvements based on Jason Chien's feedback including:
- Added CTR recording for cm.jalt, cm.jt, cm.popret, cm.popretz.
- Fixed and added more CTR extension enable checks.
- Fixed CTR CSR predicate functions.
- Fixed external trap xTE bit checks.
- One fix in freeze function for VS-mode.
- Lots of minor code improvements.
- Added checks in sctrclr instruction helper.
-
https://lore.kernel.org/qemu-riscv/20240619152708.135991-1-rkanwal@rivosinc.com/
v1:
-
https://lore.kernel.org/qemu-riscv/20240529160950.132754-1-rkanwal@rivosinc.com/
---
Rajnesh Kanwal (7):
target/riscv: Remove obsolete sfence.vm instruction
target/riscv: Add Control Transfer Records CSR definitions.
target/riscv: Add support for Control Transfer Records extension CSRs.
target/riscv: Add support to record CTR entries.
target/riscv: Add CTR sctrclr instruction.
target/riscv: Add support to access ctrsource, ctrtarget, ctrdata regs.
target/riscv: machine: Add Control Transfer Record state description
target/riscv/cpu.c | 26 ++-
target/riscv/cpu.h | 13 ++
target/riscv/cpu_bits.h | 94 ++++++++
target/riscv/cpu_cfg.h | 2 +
target/riscv/cpu_helper.c | 266 ++++++++++++++++++++++
target/riscv/csr.c | 294 ++++++++++++++++++++++++-
target/riscv/helper.h | 6 +-
target/riscv/insn32.decode | 2 +-
target/riscv/insn_trans/trans_privileged.c.inc | 22 +-
target/riscv/insn_trans/trans_rvi.c.inc | 70 ++++++
target/riscv/insn_trans/trans_rvzce.c.inc | 22 ++
target/riscv/machine.c | 25 +++
target/riscv/op_helper.c | 52 ++++-
target/riscv/tcg/tcg-cpu.c | 11 +
target/riscv/translate.c | 44 ++++
15 files changed, 935 insertions(+), 14 deletions(-)
---
base-commit: 2564f23eaefca2fc77d574c8eaf5c34138ce627f
change-id: 20241029-b4-ctr_upstream_v3-7ab764c68bf1
--
Best regards,
Rajnesh Kanwal
- [PATCH v4 0/7] target/riscv: Add support for Control Transfer Records Ext.,
Rajnesh Kanwal <=
- [PATCH v4 1/7] target/riscv: Remove obsolete sfence.vm instruction, Rajnesh Kanwal, 2024/12/04
- [PATCH v4 2/7] target/riscv: Add Control Transfer Records CSR definitions., Rajnesh Kanwal, 2024/12/04
- [PATCH v4 3/7] target/riscv: Add support for Control Transfer Records extension CSRs., Rajnesh Kanwal, 2024/12/04
- [PATCH v4 4/7] target/riscv: Add support to record CTR entries., Rajnesh Kanwal, 2024/12/04
- [PATCH v4 6/7] target/riscv: Add support to access ctrsource, ctrtarget, ctrdata regs., Rajnesh Kanwal, 2024/12/04
- [PATCH v4 5/7] target/riscv: Add CTR sctrclr instruction., Rajnesh Kanwal, 2024/12/04
- [PATCH v4 7/7] target/riscv: machine: Add Control Transfer Record state description, Rajnesh Kanwal, 2024/12/04