RISC-V Development

gtrace: RISC-V Hardware Trace Heads for Mainline Linux With 14-Patch v6 Series

📅 2026-10-04 ⏱ 8 min read 🔗 Source: LKML (Oct 1 2026, posted by Mayuresh Chitale)

On 1 October 2026, Mayuresh Chitale posted v6 of [PATCH v6 00/14] Linux RISC-V trace framework and drivers to the Linux kernel mailing list. The series introduces gtrace — an architecture-neutral hardware-trace framework whose first backend is the ratified RISC-V E-trace specification. Patch authorship is split evenly between Anup Patel (7 patches) and Chitale (7 patches). If it merges, RISC-V silicon with E-trace IP gains what Arm systems have had for years through CoreSight: instruction-level hardware tracing visible in perf.

Honesty note. This is a v6 patch series under review, not a merged kernel feature. Nothing upstream has picked it up in the days after posting, no maintainer tree carries it, and no timeline to mainline is stated. Testing today requires a QEMU model (Daniel Henrique Barboza's rv-etrace branch) — the series names no shipping silicon with E-trace. The archive snapshot also shows no review replies yet.

What gtrace Is

gtrace (Generic Trace) lives in drivers/hwtracing/gtrace/ and provides the minimal shared plumbing every hardware-trace implementation needs:

The design is deliberately not RISC-V-only. The cover letter states the framework is architecture-neutral and that the required Arm components could be adapted onto the same framework in the future — a notable claim, because it positions gtrace as a possible long-term successor-or-sibling to drivers/hwtracing/coresight/ rather than a one-ISA bolt-on. In v5 the authors made exactly that pivot: the earlier RISC-V-only rvtrace core was rebuilt as gtrace, and all drivers moved under the new directory.

The Specification Foundation Is Ratified

Unlike many RISC-V kernel features that track draft specs, this series sits on ratified documents:

SpecificationStatusRole in the series
RISC-V E-trace v1.0 (encoder + encapsulation, riscv-non-isa/e-trace-encap)Ratified (v1.0.0-ratified tag)First trace protocol backend
RISC-V Nexus trace (riscv-non-isa/tg-nexus-trace)Ratified (1.0_Ratified tag)Second supported protocol

The drivers are designed to be agnostic to the underlying trace protocol: both E-trace and N-trace should work, and discovery of protocol parameters is deliberately left to the user-space trace decoder. In v6 the trace format (E-Trace vs N-Trace) is selected through the platform driver's compatible string and recorded into both the hardware configuration and the perf data header.

The 14 Patches

AuthorPatchesWhat they do
Anup Patel (7)dt-bindings; gtrace core; RISC-V platform driver; path create/destroy; AUX copy helper; DMA_RESTRICTED_POOL defconfig; MAINTAINERSThe framework itself plus the DT plumbing: a new riscv,trace-component.yaml binding, the 858-line gtrace-core.c, and enabling DMA restricted pools so implementations with RAM-sink address restrictions can be handled
Mayuresh Chitale (7)path start/stop; encoder driver; perf AUX flag; RAM-sink driver; perf driver; perf-tools PMU record; gtrace decoderThe functional stack on top: RISC-V trace encoder and RAM-sink drivers, gtrace-perf.c (390 lines), the gtrace PMU, and initial tools/perf support including a stub decoder

The total diffstat: 24 files, 3,160 insertions. Notable new files beyond the core: rvtrace-ramsink.c (357 lines — the on-chip RAM sink, default buffer 1 MB), rvtrace-encoder.c (236), rvtrace-platform.c (186), gtrace-of.c (126 — DT connection parsing, promoted into the core in v6), and tools/perf/arch/riscv/util/auxtrace.c (221).

What Changed in v6

The version history tells the maturation story — v2 was rebased on Linux 6.18-rc3, v3 on 7.0-rc1, v4 on 7.1-rc1:

How to Test It Today

The series is testable on QEMU's virt machine with trace support from Daniel Henrique Barboza's rv-etrace branch, against Chitale's riscv_trace_support_v6 kernel branch:

$ qemu-system-riscv64 -nographic -M virt -smp 2 -bios fw_dynamic.bin \
  -kernel Image -append "root=/dev/vda rw console=ttyS0 earlycon=sbi" \
  -drive file=rootfs.img,id=disk1,if=none,format=raw \
  -device virtio-blk-device,drive=disk1

# capture gtrace data with perf
$ perf record --all-cpus -e gtrace/event=0x1/ <command>

# inspect: perf.data carries PERF_RECORD_AUXTRACE records
$ perf report -D

The perf.data output contains PERF_RECORD_AUXTRACE sections pointing at the raw gtrace data offsets; full packet decoding is future work — the in-tree decoder today is a 95-line stub, with protocol-parameter discovery explicitly left to user space.

Stated Roadmap

The cover letter lists follow-up series: sysfs support, ACPI support, more trace drivers (funnel, ATB and friends), support for the upcoming self-hosted trace specification, and — the strategically interesting one — Arm component support under the gtrace framework.

Builder Takeaways

2026 年 10 月 1 日,Mayuresh Chitale 向 Linux 内核邮件列表提交了 [PATCH v6 00/14] Linux RISC-V trace framework and drivers。该系列引入 gtrace —— 一个架构中立的硬件跟踪框架,首个后端是已批准(ratified)的 RISC-V E-trace 规范。补丁署名在 Anup Patel(7 个)与 Chitale(7 个)之间对半分。如果合入,带 E-trace IP 的 RISC-V 芯片将获得 Arm 体系通过 CoreSight 享有多年的能力:在 perf 中可见的指令级硬件跟踪。

诚实说明。 这是仍在评审中的 v6 补丁系列,不是已合入的内核功能。发布后数日内上游尚无人接手,未进入任何维护者树,也没有给出进入主线的时间表。当前测试依赖 QEMU 模型(Daniel Henrique Barboza 的 rv-etrace 分支)—— 系列未点名任何带 E-trace 的量产芯片。存档快照中也尚未出现评审回复。

gtrace 是什么

gtrace(Generic Trace,通用跟踪)位于 drivers/hwtracing/gtrace/,提供每套硬件跟踪实现所需的最小公共管道:

该设计刻意不绑定 RISC-V。封面信明确:框架是架构中立的,未来 Arm 所需组件也可以适配到同一框架上 —— 这是一个值得注意的表态,因为它把 gtrace 定位成 drivers/hwtracing/coresight/ 的潜在长期继任者或姊妹框架,而不是单一 ISA 的附属品。v5 正是完成了这一转身:早先 RISC-V 专属的 rvtrace 核心重构为 gtrace,全部驱动迁入新目录。

规范基础已经批准

与许多追随草案规范的 RISC-V 内核特性不同,本系列站在已批准的文档上:

规范状态在系列中的角色
RISC-V E-trace v1.0(编码器 + 封装,riscv-non-isa/e-trace-encap)已批准(v1.0.0-ratified 标签)首个跟踪协议后端
RISC-V Nexus 跟踪(riscv-non-isa/tg-nexus-trace)已批准(1.0_Ratified 标签)第二种受支持协议

驱动设计为对底层跟踪协议不可知:E-trace 与 N-trace 都应可用,协议参数的发现刻意留给用户态解码器。v6 中,跟踪格式(E-Trace 或 N-Trace)通过平台驱动的 compatible 字符串选择,并写入硬件配置与 perf 数据头。

14 个补丁的分工

作者补丁内容
Anup Patel(7)dt-bindings;gtrace 核心;RISC-V 平台驱动;路径创建/销毁;AUX 拷贝助手;DMA_RESTRICTED_POOL defconfig;MAINTAINERS框架本体加设备树管道:新增 riscv,trace-component.yaml 绑定、858 行的 gtrace-core.c,以及启用 DMA 受限池以支持 RAM sink 地址受限的实现
Mayuresh Chitale(7)路径启停;编码器驱动;perf AUX 标志;RAM-sink 驱动;perf 驱动;perf 工具 PMU record;gtrace 解码器其上的功能栈:RISC-V 跟踪编码器与 RAM-sink 驱动、gtrace-perf.c(390 行)、gtrace PMU,以及 tools/perf 初始支持(含桩解码器)

总 diffstat:24 个文件,3,160 行新增。核心之外值得注意的新文件:rvtrace-ramsink.c(357 行 —— 片上 RAM sink,默认缓冲 1 MB)、rvtrace-encoder.c(236)、rvtrace-platform.c(186)、gtrace-of.c(126 —— 设备树连接解析,v6 升格进核心)、tools/perf/arch/riscv/util/auxtrace.c(221)。

v6 变了什么

版本史就是成熟史 —— v2 基于 Linux 6.18-rc3,v3 基于 7.0-rc1,v4 基于 7.1-rc1:

今天如何测试

使用 Daniel Henrique Barboza 的 rv-etrace 分支中带跟踪支持的 QEMU virt 机型,配合 Chitale 的 riscv_trace_support_v6 内核分支即可测试:

$ qemu-system-riscv64 -nographic -M virt -smp 2 -bios fw_dynamic.bin \
  -kernel Image -append "root=/dev/vda rw console=ttyS0 earlycon=sbi" \
  -drive file=rootfs.img,id=disk1,if=none,format=raw \
  -device virtio-blk-device,drive=disk1

# 用 perf 采集 gtrace 数据
$ perf record --all-cpus -e gtrace/event=0x1/ <command>

# 查看:perf.data 中是 PERF_RECORD_AUXTRACE 记录
$ perf report -D

perf.data 输出中,PERF_RECORD_AUXTRACE 段指向原始 gtrace 数据偏移;完整包解码是后续工作 —— 当前树内解码器只是一个 95 行的桩,协议参数发现明确留给用户态。

官方路线图

封面信列出了后续系列:sysfs 支持、ACPI 支持、更多跟踪驱动(funnel、ATB 等)、对即将到来的自托管跟踪(self-hosted trace)规范的支持,以及 —— 战略上最有趣的一条 —— 在 gtrace 框架下支持 Arm 组件。

开发者要点

Краткое содержание (RU)

1 октября 2026 года Mayuresh Chitale опубликовал v6 серии из 14 патчей «Linux RISC-V trace framework and drivers». Она добавляет gtrace — архитектурно-нейтральный фреймворк аппаратного трассирования, первый бэкенд которого — ратифицированный RISC-V E-trace. Авторство патчей пополам: Anup Patel (7) и Chitale (7). 24 файла, +3160 строк: ядро gtrace-core.c, драйверы энкодера и RAM-sink, gtrace-perf.c, PMU gtrace и начальная поддержка в tools/perf. Драйверы независимы от протокола (E-trace и N-trace); проверка — через QEMU-модель и perf record -e gtrace/event=0x1/. Проект не слит: это v6 на реконсидерации. Общество в короткой перспективе: RISC-V получает аналог Arm CoreSight в основной линейке Linux.

Resumen (ES)

El 1 de octubre de 2026, Mayuresh Chitale publicó la v6 de una serie de 14 parches titulada «Linux RISC-V trace framework and drivers». Introduce gtrace, un marco de trazado por hardware neutral respecto a la arquitectura cuyo primer backend es la especificación RISC-V E-trace ya ratificada. La autoría se reparte a partes iguales entre Anup Patel (7 parches) y Chitale (7). Son 24 archivos y 3.160 líneas nuevas: núcleo gtrace-core.c, drivers de codificador y RAM-sink, gtrace-perf.c, el PMU gtrace y soporte inicial en tools/perf. Los drivers son agnósticos al protocolo (E-trace y N-trace); las pruebas usan un modelo QEMU y perf record -e gtrace/event=0x1/. No está fusionado: es una v6 en revisión. En la práctica, RISC-V se acerca al equivalente de CoreSight en el kernel principal de Linux.

Résumé (FR)

Le 1er octobre 2026, Mayuresh Chitale a publié la v6 d'une série de 14 patchs intitulée « Linux RISC-V trace framework and drivers ». Elle ajoute gtrace, un cadriciel de traçage matériel neutre quant à l'architecture, dont le premier backend est la spécification RISC-V E-trace déjà ratifiée. La paternité se partage à parts égales entre Anup Patel (7 patchs) et Chitale (7). Au total : 24 fichiers, 3 160 lignes ajoutées — noyau gtrace-core.c, pilotes encodeur et RAM-sink, gtrace-perf.c, PMU gtrace et premier support dans tools/perf. Les pilotes sont indépendants du protocole (E-trace et N-trace) ; les tests passent par un modèle QEMU et perf record -e gtrace/event=0x1/. La série n'est pas fusionnée : c'est une v6 en revue. Concrètement, RISC-V se rapproche de l'équivalent de CoreSight dans le noyau Linux principal.

Kurzfassung (DE)

Am 1. Oktober 2026 veröffentlichte Mayuresh Chitale v6 der 14-Patch-Serie »Linux RISC-V trace framework and drivers«. Sie führt gtrace ein, ein architekturneutrales Hardware-Tracing-Framework, dessen erstes Backend die bereits ratifizierte RISC-V-E-trace-Spezifikation ist. Die Autorenschaft teilt sich hälftig: Anup Patel (7 Patches) und Chitale (7). Insgesamt 24 Dateien, +3160 Zeilen: Kern gtrace-core.c, Treiber für Encoder und RAM-Sink, gtrace-perf.c, das PMU gtrace sowie erste Unterstützung in tools/perf. Die Treiber sind protokollagnostisch (E-trace und N-trace); getestet wird über ein QEMU-Modell mit perf record -e gtrace/event=0x1/. Die Serie ist nicht gemerged — eine v6 im Review. Praktisch bedeutet es: RISC-V rückt an das CoreSight-Äquivalent im Linux-Mainline-Kernel heran.

خلاصه (FA)

در ۱ اکتبر ۲۰۲۶، Mayuresh Chitale نسخهٔ ششم سری ۱۴ پچی «Linux RISC-V trace framework and drivers» را منتشر کرد. این سری gtrace را معرفی می‌کند: چارچوب ردیابی سخت‌افزاریِ مستقل از معماری که اولین بک‌اند آن مشخصات تأییدشدهٔ RISC-V E-trace است. مالکیت پچ‌ها نیم‌به‌نیم است: Anup Patel (۷ پچ) و Chitale (۷ پچ). روی‌هم‌رفته ۲۴ فایل و ۳۱۶۰ خط افزودنی: هستهٔ gtrace-core.c، درایورهای انکودر و RAM-sink، gtrace-perf.c، PMU با نام gtrace و پشتیبانی اولیه در tools/perf. درایورها از پروتکل مستقل‌اند (هم E-trace و هم N-trace)؛ آزمایش از طریق مدل QEMU و perf record -e gtrace/event=0x1/ انجام می‌شود. این سری ادغام نشده است — یک v6 در حال بازبینی است. در عمل، RISC-V به معادل CoreSight در کرنل اصلی لینوکس نزدیک می‌شود.

Sources / 参考来源

← Back to Tech Blog