freenode
Kernel & Low-Level

Linux gains RISC-V events that fire with interrupts off

SBI Supervisor Software Events give perf a path into interrupt-disabled code, with kexec treated as unsafe until firmware state can be cleared.

A Linux patch series adds support for RISC-V Supervisor Software Events, a firmware interface that can enter the kernel even when ordinary supervisor interrupts are masked. RISC-V has no standard supervisor-mode non-maskable interrupt. When Linux clears the supervisor interrupt enable bit, a pending interrupt simply waits. That is fine for normal device handling, but it leaves profiling and other urgent notifications blind inside interrupt-disabled regions.

The SBI SSE extension, comparable to Arm's software delegated exception interface, lets the kernel register an entry point with firmware. Firmware saves enough state to transfer control, runs the handler, and resumes the interrupted context. Performance-counter overflow is the first client: RISC-V perf prefers SSE when the firmware event can be registered and enabled, and falls back to the ordinary PMU interrupt only if the extension or that event is explicitly unsupported. Other failures do not silently switch delivery modes. High-priority reliability reports are an intended later client, not part of this work.

The series also closes holes that an NMI-like entry exposes. Page faults taken with fault handling disabled no longer open an interrupt window or run tracepoints before the exception-table fixup, which matters when perf copies a user stack from SSE context. The perf unwinder samples the interrupted task rather than the synthetic handler frame, and lockdep is taught that interrupts really are off inside the handler.

Shutdown is more conservative. SSE is masked before panic, CPU stop, restart, poweroff, and crash paths so firmware cannot enter a handler after that CPU's kernel state is gone. A crash kernel cannot tell whether it inherited registrations from the crashed kernel, so a later normal kexec is rejected whenever firmware advertises SSE, even if the crash kernel itself never registered anything. That restriction stays until there is a safe way to identify or clear inherited firmware state.

Zhanpeng Zhang, Himanshu Chauhan, and Clément Léger are listed as co-maintainers, with Yunhui Cui as reviewer. Kernel selftests cover registration, injection, and perf user-stack sampling under SSE.