Skip to content
KaruCore
Go back

Zkr (Hardware Random) and RISC-V Debug 1.0

By Markku-Juhani O. Saarinen

Note

TL;DR: Karu64 gains three opt-in features: the standard Zkr entropy source (seed CSR) backed by sampled ring oscillators, a RISC-V Debug 1.0 debug module reachable through the FPGA’s own JTAG port, and debug authentication. On 2026-11-18 the combined image passed its first board session on the VCU118, booting KaruDeb’s Linux 7.4-rc3 kernel, which picks up Zkr on its own.

Table of contents

Open Table of contents

Zkr: the Entropy Source Extension

Zkr is the entropy source part of the ratified RISC-V Scalar Cryptography extensions. It defines one CSR, seed (0x015). Each read returns a status, OPST, in bits 31:30, and in state ES16 also 16 bits of entropy. The other states are BIST (start-up test running), WAIT (no entropy available yet) and DEAD (failed). Accessing seed requires a CSR instruction that performs a write, normally csrrw. A successful poll consumes the returned word. M-mode always has access. S-mode and U-mode get access only if M-mode sets mseccfg.SSEED or USEED.

Zkr is deliberately an entropy source, not a random-number generator: its output is meant to seed a software DRBG, such as the Linux random pool.

A ring-oscillator noise source

On the FPGA, Karu64’s noise source is four free-running inverter rings of 3, 5, 7 and 9 stages, each sampled by a flip-flop on the 75 MHz system clock. Every inverter is placed by hand, and each ring has its own slices. One sample of the four rings is a raw 4-bit symbol, taken every 256 clocks.

One lane: an enable NAND gate and an odd chain of inverters in a loop, sampled by two flip-flops. Four lanes form a 4-bit raw symbol every 256 clocks, which passes decimation by k, per-lane health tests, packing into 16-bit words and a FIFO to the seed CSR. The mnoise GetNoise interface taps the raw symbols after decimation; mentropycfg sets k, the test cutoffs and a lock.
The Karu64 entropy source on the FPGA. Each raw bit is one sampled ring; bits are never combined. Every k-th symbol is kept, checked by repetition-count and adaptive-proportion tests per lane, and four symbols form one 16-bit seed word.

Bits are never combined or whitened in hardware. That is a deliberate choice: each lane remains one physical process of the kind modelled in On Entropy and Bit Patterns of Ring Oscillator Jitter, with a frequency, a duty cycle and a jitter variance per sample. So each lane can be measured and checked against that model, instead of being hidden behind a conditioner. Two custom M-mode CSRs support this:

How OpenSBI and Linux pick it up

Zkr is advertised like any other ISA extension: as zkr in the device tree’s riscv,isa-extensions. OpenSBI v1.9 reads it and sets mseccfg.SSEED, so that the kernel may use seed. Linux lists the extension, and its archrandom code then reads seed at early boot and at every reseed of the random pool. From the board’s console and /proc/cpuinfo on 2026-11-18 (long lines shortened):

OpenSBI v1.9
Platform Reboot Device      : syscon-reboot
Boot HART ISA Extensions    : smstateen,…,zihpm,zkr,smcntrpmf,…,v,f,d
…
Linux version 7.4.0-rc3-zvk-dirty …
Kernel command line: … random.trust_cpu=off
…
random: crng init done

root@karudeb:~# grep -m1 isa /proc/cpuinfo
isa		: rv64imafdcbvh_zicbom_…_zba_zbb_zbs_zkr_zkt_zvbb_…_svpbmt

The kernel command line has random.trust_cpu=off. Linux still mixes what seed delivers into its pool, but does not count it as entropy until the source has been characterised.

The first raw captures on the board, 10^6 symbols at each of six decimations, show what is expected and nothing more:

At one sample per 256 clocks, successive samples are largely decorrelated. Two lanes still show small lag-1 autocorrelation at k = 1, but the captures do not provide enough information to fit the jitter model. The next step is a burst-capture mode that samples every clock cycle, for a proper characterisation.

RISC-V Debug 1.0

karudbg is a Debug Module that targets the ratified RISC-V Debug Specification 1.0, for a single hart:

On the VCU118 the debug transport goes through the FPGA’s own JTAG port, a nested TAP behind the USER4 instruction. So an unmodified OpenOCD and GDB work over the board’s standard USB-JTAG cable, with no extra pins. Debug is opt-in: a build without it is unchanged, and the full debug configuration adds 0.81 % to the core’s NanGate45 area.

On the board, the debugger phases cover:

After the debugger detaches, Linux boots and passes the usual acceptance tests.

Debug authentication

Unrestricted JTAG access is full machine-mode control of the hart. Debug 1.0 provides the hooks for authentication (dmstatus.authenticated, authbusy and the authdata register) but leaves the protocol to the implementation. Karu’s mechanism:

Sequence diagram with the debugger, the Debug Module and the hart. The hart is held at power-on; the debugger sends REQUEST through authdata, which releases the hold; the island ROM draws a nonce from seed and sends a CHALLENGE; the debugger signs it and sends a RESPONSE; the ROM verifies it, sets the grant, closes the window and boots on; the Debug Module then reports authenticated.
Debug authentication in lifecycle AUTH. The window opens once per power-on and lasts 230 cycles; the nonce comes from the Zkr entropy source.

The FPGA version is not secure, by design. It is a functional rehearsal of the mechanism intended for an ASIC:

The production signature algorithm is still to be chosen; probably SLH-DSA and/or ML-DSA. On the FPGA, four DIP switches (SW12) select what an ASIC would fix in its lifecycle fuses and straps. They are read at the CPU reset button or at reconfiguration:

SW12OffOn
1lifecycle OPEN: debug without authenticationlifecycle AUTH
2—lifecycle DISABLED: no debug at all
3boot normallyin AUTH: hold the hart until a debugger sends a request
4entropy source onentropy source off: seed stays in BIST

All off is the default: the board then behaves like an image without these features. On the board, every case passed:

KaruDeb: Linux 7.4-rc3 and OpenSBI v1.9

KaruDeb moves to Linux 7.4-rc3, built with Clang 24. With it, the Debian userspace passes the board acceptance:

The boot ROM now carries OpenSBI v1.9 with a syscon-reboot device, so reboot works without a debugger. The board went through eight software reboots in this session, each back through the boot ROM. KaruDeb also builds a zkr variant of the device tree, which is the one that turns Zkr on for Linux.

More information


Share this post:

Next Post
Karu64: An Open RVA23S64 Processor with Vector Keccak Support