Skip to content

fix: stop advertising unimplemented Zkr in FDT ISA string#3

Merged
SolAstrius merged 1 commit into
stagingfrom
fix/zkr-advertising
Apr 21, 2026
Merged

fix: stop advertising unimplemented Zkr in FDT ISA string#3
SolAstrius merged 1 commit into
stagingfrom
fix/zkr-advertising

Conversation

@SolAstrius
Copy link
Copy Markdown
Collaborator

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

  • Rebuild librvvm, boot Alpine riscv64 linux-lts (6.18.22 or similar).
  • Pre-fix: kernel oops at `arch_get_random_seed_longs+0x14` → panic at `start_kernel`.
  • Post-fix: kernel boots past `random_init_early` normally; `/proc/cpuinfo` no longer lists zkr.

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.
@SolAstrius SolAstrius merged commit 52c70d1 into staging Apr 21, 2026
@SolAstrius SolAstrius deleted the fix/zkr-advertising branch April 21, 2026 15:26
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant