Charter
Self-hosted trace describes a trace usage scenario where the target system is also the host, such that trace is configured and collected by privileged software running on the target system. Self-hosted trace is commonly used by in-target debuggers (e.g., gdb), performance profiling tools (e.g., Linux perf), and fuzzers (e.g., kAFL).
Self-hosted trace will leverage the existing (non-ISA) RISC-V trace standards, defining extension(s) that add new requirements and restrictions, detailed below, necessary for self-hosted use in production RVA environments.
Each hart has a trace encoder (TE) unique to that hart, and programmable only by privileged software running on that hart, to ensure that trace does not allow other system agents to observe local software execution
The option to filter trace by privilege mode is required, to ensure no leaking of state across trust boundaries
Trace output is routed only to system memory, or another memory-mapped buffer
A supervisor and virtual-supervisor TE interface is available, with appropriate restrictions to prevent tracing of more privileged software execution
Traces collected by a guest should include no indication of virtualization, to avoid trace serving as a virtualization hole
Self-hosted trace will additionally define new ISA extension(s) that include the following enhancements, intended to simplify software enabling and reduce overhead for common case usages, such as tracing of a single application or a single supervisor domain.
A new CSR interface to configure the per-hart trace encoder, with configurable support for S-mode and VS-mode access
A memory buffer sink that utilizes virtual addressing, with an option to enable indication to software that the buffer is full or near full
The ISA extensions will be prototyped with Qemu and Linux perf, to demonstrate the usability of the ISA interface.
Related content
RISC-V International