fix: stop advertising unimplemented Zkr in FDT ISA string#3
Merged
Conversation
The emulator CPU doesn't implement the `seed` CSR that the Zkr (cryptographic seed) extension requires, but the hardcoded ISA extension string in riscv_exts advertised it. Linux 6.18+ `arch_get_random_seed_longs` trusts the FDT, issues `csrrwi x13, seed, 0` at `start_kernel+0x68a` (before any console is initialized), and the undefined instruction trap kills the kernel before it can even complain (Oops — illegal instruction, then immediate panic). Empirical repro: boot any recent-mainline Linux kernel with Zkr detection enabled; it will oops at `random_init_early`. Confirmed in Scalar Evolution / Alpine riscv64 linux-lts 6.18.22 under this emulator. Drop zkr from the advertised extension list until the CSR is wired up. Other zk* extensions (zbkb, zbkx) stay because they're just bit-manip instructions already covered by the JIT.
3 tasks
SolAstrius
added a commit
that referenced
this pull request
May 1, 2026
The emulator CPU doesn't implement the `seed` CSR that the Zkr (cryptographic seed) extension requires, but the hardcoded ISA extension string in riscv_exts advertised it. Linux 6.18+ `arch_get_random_seed_longs` trusts the FDT, issues `csrrwi x13, seed, 0` at `start_kernel+0x68a` (before any console is initialized), and the undefined instruction trap kills the kernel before it can even complain (Oops — illegal instruction, then immediate panic). Empirical repro: boot any recent-mainline Linux kernel with Zkr detection enabled; it will oops at `random_init_early`. Confirmed in Scalar Evolution / Alpine riscv64 linux-lts 6.18.22 under this emulator. Drop zkr from the advertised extension list until the CSR is wired up. Other zk* extensions (zbkb, zbkx) stay because they're just bit-manip instructions already covered by the JIT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The emulator CPU doesn't implement the `seed` CSR that the Zkr (cryptographic seed) extension requires, but the hardcoded ISA extension list in `rvvm.c` advertises it. Modern Linux kernels (6.18+) trust the FDT and call `csrrwi x13, seed, 0` from `arch_get_random_seed_longs` during `random_init_early` — before any console is initialised — and the undefined-instruction trap panics the guest immediately.
Drop `zkr` from `riscv_exts` until the CSR is wired up.
Test plan