Simmerv is a high-performance full RVA23 and RVA22 RISC-V SoC emulator written in Rust and compilable to WebAssembly.
You can run Linux on the emulator in your browser: online demo is here
wget https://cdimage.ubuntu.com/releases/26.04/release/ubuntu-26.04-preinstalled-server-riscv64.img.xz
unxz ubuntu-26.04-preinstalled-server-riscv64.img.xz
cargo r -rq -- -m 8192 --rva23 linux/fw_payload.elf -f ubuntu-26.04-preinstalled-server-riscv64.img- Emulates RISC-V
RV64GC_Zba_Zbb_Zbc_Zbs_Zicond_Zfhmin_Svinval_Svade_Svpbmt_Sstc_Zicbom_Zicbop_Zicboz_Zihpm(RVA22) processor and peripheral devices (CLINT, PLIC, NS16550A UART, virtio block device, and VirtIO ethernet) - Optional RVA23 mode, enabled with
--rva23: theVvector extension (RVV 1.0,ELEN=64,VLEN=128 or 256 via--vlen) plus Zcb, Zimop, Zcmop, Zfa, Zawrs, Zacas, Zabha, Zvbb, Zvkt and Zihintntl. Boots the RVA23 port of Ubuntu 26.04. - Optional graphics console, enabled with
--graphics WxH: asimple-framebuffershown in an SDL window (or inline in iTerm2), plus a virtio keyboard - Targets native and WASM
- Snapshots
- Speedometer
- RV64IMAC
- RV64FD
- RV64Zifencei
- RV64Zicsr
- Zba, Zbb, Zbc, Zbs ("B" extension)
- Zicond
- Zfhmin (half-precision float conversions)
- Zihpm (hardware performance counters)
- Zicbom, Zicbop, Zicboz (cache block operations)
- Svinval (fine-grained TLB invalidation)
- Svade (hardware A/D fault-on-access)
- Sstc (stimecmp/menvcfg timer compare)
- Sv39, Sv48, Sv57 (the wider two are opt-in: see
--satp-mode) - Svpbmt (page-based memory types; PTEs accepted, no caches to model)
- Privileged Spec 1.12 (mcounteren/scounteren, senvcfg, PMP stub with 0 entries)
- Svnapot
- [-] PMP enforcement (0 entries implemented; all accesses permitted)
The emulator supports all instructions listed above.
- Passes all riscof (RISC-V Architectural Tests) for RV64IMC
- Boots Buildroot, Debian Trixie, Ubuntu
- Linux OpenSBI and legacy BBL boot support
- V — the vector extension, RVV 1.0. All of
Zve64dplus the fullVinstruction set: configuration, unit-stride / strided / indexed / segment / whole-register / fault-only-first loads and stores, the integer, fixed-point, mask, permutation and floating-point operations, and thevstart/vl/vtype/vxrm/vxsat/vcsr/vlenbCSRs withmstatus.VS.VLENdefaults to 128 (Zvl128b, the profile minimum);--vlen 256selectsZvl256binstead. - Zvfh, Zvfhmin — vector half-precision (the full arithmetic set, which is
a superset of the
Zvfhminthe profile requires) - Zvkt, Zkt — constant-time execution; trivially satisfied by a functional model with no data-dependent timing
- Zicond, Zfhmin, Zicbom/z/p, Svinval, Svnapot, Svpbmt, Sstc, Svade (inherited from RVA22)
- Zcb — the newer compressed encodings. Each one abbreviates an instruction the emulator already had, so all twelve decode straight to that uop rather than to a parallel execution path.
- Zimop, Zcmop — may-be-operations.
mop.r.n/mop.rr.nwrite zero tord;c.mop.nchanges no architectural state at all. - Zfa —
fli(both constant tables),fminm/fmaxm, the quiet comparesfleq/fltq,fround/froundnxandfcvtmod.w.d. The half-precision members are omitted: they need fullZfh, which RVA23 does not mandate and this emulator does not implement. - Zvbb — vector basic bit manipulation (
vandn,vbrev,vbrev8,vrev8,vclz,vctz,vcpop,vrol,vror,vwsll), and with itZvkb, which is a strict subset - Zawrs — wait-on-reservation-set. Both forms may terminate the wait immediately and for any reason, so both retire as no-ops.
- Zacas —
amocas.b/h/w/d/q, including the quadword form over even/odd register pairs - Zabha — byte and halfword forms of every AMO
- Zihintntl — non-temporal locality hints. The four hints are
ADD x0, x0, x2..x5(and theC.ADD x0, x2..x5compressed forms), so any conforming hart already retires them as no-ops; a functional model has no cache hierarchy to hint at, which is the same reasonZktandZvktare satisfied for free. Verified to leavex0and the source registers untouched. - Sv48, Sv57 in
satp. Opt-in with--satp-mode sv48/sv57, because Linux keeps the widest modesatpaccepts: defaulting to Sv57 would move every existing guest onto a deeper page table. Exercised by the Tenstorrent suite'spaging_sv48andpaging_sv57groups. - Supm / Ssnpm / Smnpm — pointer masking. Deferred. Nothing depends
on it: masking is opt-in per process (
prctl(PR_SET_TAGGED_ADDR_CTRL)), so software that does not find it simply does not tag pointers, and the one real beneficiary -- HWASAN, which is why Android leans on Arm's equivalent TBI -- does not exist for RISC-V yet. Nor would an emulator gain what the feature is for: the point is that hardware ignores the tag bits for free, and here that is just "do not fault on these addresses". Revisit if LLVM gains RISC-V HWASAN, or a distro ships HWASAN-instrumented RISC-V packages. - Sscofpmf — count-overflow interrupts. A counter wrapping past all-ones
sets
OFon the 0->1 edge and raisesLCOFIP; the interrupt is delivered asCounterOverflowInterruptandscountovfreflects it. Advertised in both device trees. - Ssstateen / Smstateen — the state-enable CSRs.
mstateen0'sSE0andENVCFGbits gatesstateen0andsenvcfgbelow M-mode; every other bit, andmstateen1..3/sstateen0..3entire, reads zero, because the state those bits guard (AIA, IMSIC,Zcmt'sjvt,Zfinx'sfcsr, custom) does not exist here.mstateen0resets permissive rather than to the architectural zero: the only state it gates issenvcfg, so denying by default protects nothing while breaking any firmware that predates Smstateen and never opens the gate. - H — the hypervisor extension, required by RVA23S64. Deferred. Not
needed to run Linux, only to host it: a guest that finds no H simply
offers no KVM. It is also the largest item by a distance -- two-stage
translation, the VS-mode CSR bank, the hypervisor load/stores -- and it
lands on the MMU fast path. Tenstorrent's suite ships an
h_exttest tree that is skipped for now, so the tests are waiting whenever it is picked up.
So RVA23 is complete but for Supm and H, both deferred above for the
same reason: nothing depends on either, and neither blocks anything simmerv is
for.
Coverage is not self-reported: the user-mode set is exercised by Tenstorrent's
architectural tests (see tests/tenstorrent/run.sh) and the vector
implementation is diffed against QEMU instruction by instruction at both
VLEN widths (tests/vector/run.sh).
The device trees advertise what is implemented, so a guest can discover it.
That includes the default (non---rva23) machine, which used to name only
imafdc plus a handful of CSR extensions despite always having had the
bitmanip set, Zicond, Zfhmin and the cache-block operations.
V, Zcb, Zimop, Zcmop, Zfa, Zvbb, Zawrs, Zacas and Zabha are off by default and
enabled together by --rva23, so that a run without the flag still models a hart
that traps every one of those encodings. (The entries inherited from RVA22 are
always on.) RVA23 mandates V, so one switch covers the lot: it gates
instruction decoding, the misa V bit and the vector CSRs, and swaps in a
device tree whose cpu node advertises the profile.
$ cargo r -r -- --rva23 -n my-vector-program.elfTo boot the RVA23 port of Ubuntu, the guest kernel must also have been built
with CONFIG_RISCV_ISA_V=y — without it the kernel drops v from the ISA it
parses out of the device tree, and an RVA23 userland dies on the first vector
instruction in ld.so, because the profile lets glibc emit vector code with no
scalar fallback. riscv: base ISA extensions in the boot log is the thing to
check: it should read acdfimv.
$ cargo r -r -- --rva23 -f ubuntu-26.04-preinstalled-server-riscv64.img \
fw_payload.bin,0x80000000tests/vector/run.sh builds a bare-metal exerciser — 1994 instruction cases
across every SEW, LMUL, rounding mode and addressing form, covering the RVA23
additions as well as base RVV — and diffs simmerv's transcript against QEMU's
virt machine, which shares simmerv's memory map. All 1994 transcript lines
currently match exactly, with three traps on both sides: vwsll at SEW=64,
where the widened element exceeds ELEN and the encoding must be illegal.
One deliberate difference: simmerv enforces vill, register-group alignment,
EMUL range and the "masked instruction may not write v0" rule, but not the
finer source/destination overlap constraints (a narrowing vs1 inside the
double-width vs2 group, a segment-load destination overlapping the index
group). QEMU raises an illegal instruction for those; simmerv executes them.
No conforming assembler emits them.
VERY IMPORTANT: images are stored with git LFS. Install LFS (don't
forget git lfs install also) and recheckout if needed. Otherwise
the images will be small files with LFS pointers.
$ cargo r -r -- linux/fw_payload.bin,0x80000000 -f linux/rootfs.imgor
$ cargo r -r -- -c linux/opensbi/fw_jump.elf,0x80000000 linux/vmlinux,0x80200000 -f linux/rootfs.img-i/--initfs takes a cpio archive, loads it into RAM below the device
tree, and inserts the linux,initrd-start / linux,initrd-end properties into
the tree's /chosen node so the kernel finds it. Nothing else has to be
arranged: no address to work out, and no hand-maintained device tree.
$ cargo r -r -- -m 2048 -i linux/gb6.cpio linux/fw_payload.bin,0x80000000The tree is placed at the top of RAM and the ramdisk goes flush underneath it, page-aligned:
initrd linux/gb6.cpio: [0xe608b000, 0xffffe600) = 435631616 byte(s), device tree at 0xfffff000
The end sits a little below the tree (2560 bytes here) because the start is
rounded down to a page boundary; end - start is always exactly the file's
length.
The properties are inserted, never overwritten. If the tree you pass to -d
already defines them, it is stating where its ramdisk lives, and -i refuses
rather than silently contradicting it:
$ cargo r -r -- -m 2048 -i linux/gb6.cpio -d linux/with-initrd.dtb linux/fw_payload.bin,0x80000000
Error: /chosen already defines linux,initrd-start (8 byte(s) at 0xb8); this
device tree pins its own ramdisk address, so placing one would contradict it.
Remove the property to let the emulator choose an address, or keep this tree
and supply no ramdisk of your ownAppend ,0xADDR to pin the ramdisk's address instead of deriving it
(-i linux/gb6.cpio,0xa0000000). The address must still leave room for the
tree, and the properties are still written.
--dumpdtb writes the effective device tree — after the memory-size patch
and after any -i properties have been inserted — to stdout and exits without
running. That is byte-for-byte what the kernel would have been handed, which
makes it the quickest way to check a layout:
$ cargo r -r -- --dumpdtb -m 2048 -i linux/gb6.cpio | dtc -I dtb -O dts | sed -n '/chosen/,/};/p'
chosen {
bootargs = "console=ttyS0 earlycon=sbi root=/dev/vda1 rw ignore_loglevel random.trust_bootloader=on";
stdout-path = "/uart@10000000";
rng-seed = <...>;
linux,initrd-start = <0x00 0xe608b000>;
linux,initrd-end = <0x00 0xffffe600>;
};Note the stdout: redirect the blob to a file, and keep in mind that the emulator's own diagnostics go to stderr for exactly this reason.
linux/with-initrd.dtb, the wasm demo's linux/demo/demo.dtb and the
linux/tiny128.dtb placeholder were each hand-maintained trees that freeze a
ramdisk address in them — demo/build.sh had to compute
INITRD_ADDR=0x9e000000, sed the two properties into a copy of dts.dts, and
index.html had to repeat the same address so the host side loaded the file to
the right place. Three files, two languages and one number that had to agree
everywhere.
-i removes that on the sim path, and the wasm demo drops it too: it now
calls the same machinery through setup_initrd on the emulator's default tree,
so demo.dtb is deleted, build.sh builds nothing but the initramfs, and no
address appears anywhere. The remaining trees still work — tiny128.dtb is a
placeholder that pins its own ramdisk, and with-initrd.dtb is what -i
refuses by name — but neither is how you should boot a ramdisk.
linux/demo/build.sh also used to strip root=/dev/vda1 rw from the tree's
bootargs, since the demo's init chooses its own root. That is unnecessary: the
kernel runs the initramfs's /init when there is one, and root= is never
consulted. Booting the demo geometry with the stock tree and -i reaches a
login prompt, which is the check that this holds.
cargo r -r -- --graphics 1280x1024 --rva23 \
--append "fbcon=font:SUN12x22 console=ttyS0 console=tty0 earlycon=sbi root=/dev/vda1 rw ignore_loglevel random.trust_bootloader=on" \
linux/fw_payload.elf -f ubuntu-26.04-preinstalled-server-riscv64.img--graphics WxH adds two devices, both declared in the device tree the guest
is handed, so no hand-written .dtb is needed:
- A framebuffer.
W*H*2bytes of RGB565, rounded up to a power of two and carved from the top of RAM at an address aligned to that size (1280x1024 takes 4 MiB at0xffc00000with the default 2 GiB). It stays ordinary RAM in the guest's linear map, kept from the page allocator by a/memreserve/entry, and the emulator reads it back 30 times a second. Linux'ssimplefbbinds it; it warnscannot reserve video memory, which is expected for a framebuffer inside System RAM and harmless. - A keyboard. A virtio-input device at
0x10004000(IRQ 4).
The kernel needs CONFIG_FB_SIMPLE, CONFIG_FRAMEBUFFER_CONSOLE and
CONFIG_VIRTIO_INPUT; the linux/fw_payload.elf shipped here (7.3.0-rc5) has
them all, plus the console fonts fbcon=font: can pick (SUN12x22,
TER16x32, VGA8x16, ...). The default 8x16 font is small at 1280x1024.
A Mandelbrot demo. linux/mandelbrot/build.sh builds mandelbrot, a
6 KB static binary with no libc that zooms into the Mandelbrot set on
/dev/fb0. Copy it into a guest booted with --graphics and run it there;
Ctrl-C stops it and gives the console back.
Where the console goes. Kernel messages go to every console= given; the
last one becomes /dev/console, where init and its shell run. So:
console=ttyS0 console=tty0(above): everything on the graphics console, which you type into; the serial terminal still shows the kernel log.console=tty0 console=ttyS0: kernel log on both, shell on serial.
--append replaces the whole command line, so repeat the default tree's
arguments (root=, earlycon, ...) as above.
Where it is shown. In an SDL window when one can be opened: SDL2 is loaded
at run time (libSDL2-2.0.so.0, or Homebrew's libSDL2-2.0.0.dylib), so
building needs no SDL at all. Keys typed into the window go to the guest's
keyboard; closing it exits. Without a window system (SSH, a headless box), the
frames are drawn inline in the terminal at 1 Hz with iTerm2's image protocol,
redrawn from the top-left and only when the screen changed. There the terminal
is the keyboard: keystrokes go to the graphics console, translated back into
key presses (US layout, arrows, function keys, Ctrl and Alt), and Ctrl-C k
switches them between the graphics console and serial. Set SDL_VIDEODRIVER
to force a particular SDL driver.
Simmerv emulates a VirtIO-net device (MAC 52:54:00:12:34:56) on the second
virtio-mmio window. The built-in device tree already declares it, so a guest
kernel with CONFIG_VIRTIO_NET probes it automatically — but the device stays
inert (packets are dropped) until you attach a host backend. There is no
built-in emulator NAT/DHCP other than what the backend provides.
On Linux, Simmerv connects the guest's NIC to a TAP device — a raw
layer-2 link with no DHCP or NAT of its own, so you configure the host side
and give the guest a static address (or bridge tap0 into a real network if
you prefer).
- Create a persistent TAP owned by your user (so Simmerv needs no root):
$ sudo ip tuntap add dev tap0 mode tap user $USER
$ sudo ip link set tap0 up
$ sudo ip addr add 172.16.0.1/24 dev tap0- For guest internet access, enable forwarding + NAT on the host. The
MASQUERADE rule must name your internet-facing interface — auto-detect
it from the default route rather than assuming
eth0:
$ UPLINK=$(ip route show default | awk '{print $5; exit}') # e.g. enp9s0, wlan0
$ echo "NAT via uplink: $UPLINK" # sanity-check it
$ sudo sysctl -w net.ipv4.ip_forward=1
$ sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -o "$UPLINK" -j MASQUERADE
$ sudo iptables -A FORWARD -i tap0 -j ACCEPT
$ sudo iptables -A FORWARD -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPTIf the guest reaches the host (172.16.0.1) but nothing beyond it, this
rule is almost always the culprit — check it with
sudo iptables -t nat -L POSTROUTING -n -v (wrong out interface, or a
pkts count stuck at 0 while the guest generates traffic).
- Run Simmerv attached to the TAP (
-T <ifname>):
$ cargo r -r -- -T tap0 linux/fw_payload.bin,0x80000000 -f linux/rootfs.img- Configure the interface inside the guest (the name may be
eth0,enp0s…, etc. — checkip link):
# in the guest
$ ip addr add 172.16.0.2/24 dev eth0
$ ip link set eth0 up
$ ip route add default via 172.16.0.1 # only needed for step 2
$ echo 'nameserver 1.1.1.1' > /etc/resolv.confHost (172.16.0.1) and guest (172.16.0.2) can now ping each other; with
step 2 the guest also reaches the internet. Remove the TAP afterwards with
sudo ip tuntap del dev tap0 mode tap.
On macOS, Simmerv uses Apple's vmnet.framework in shared mode, which
supplies DHCP and NAT automatically — the guest just needs to request an
address. vmnet shared mode requires elevated privileges, so run under
sudo. Build first so sudo doesn't rebuild the tree as root:
$ cargo build -r
$ sudo ./target/release/simmerv-cli --vmnet linux/fw_payload.bin,0x80000000 -f linux/rootfs.imgThe guest receives an address on vmnet's subnet (typically 192.168.x.x) with
NAT to the host's network. Ubuntu 26.04 does this by itself at boot: its
netplan (/etc/netplan/50-cloud-init.yaml) turns on DHCP for every en* and
eth* interface through systemd-networkd, so no DHCP client package is needed.
DHCP needs CONFIG_PACKET=y in the guest kernel. Every DHCP client sends
its first request on an AF_PACKET socket, and the guest cannot load Ubuntu's
af_packet.ko, built for Ubuntu's own kernel, into ours. Without it networkd
logs Failed to start LLDP client: Address family not supported by protocol
and never gets an address. The linux/fw_payload.elf shipped here has it built
in; a kernel of your own needs it too, or the static setup below.
If the link did not come up, check networkctl and ask again with whichever
client the image has (ip link shows the interface name):
# in the guest
$ sudo networkctl reconfigure eth0 # Ubuntu: networkd's built-in DHCP
$ sudo dhcpcd eth0 # Ubuntu 26.04 also ships dhcpcd
$ udhcpc -i eth0 # busybox images (linux/rootfs.img)Ubuntu 26.04 has neither dhclient nor udhcpc. With no DHCP at all, set the
address by hand on vmnet's subnet, typically 192.168.64.0/24 with the host
and DNS at .1:
# in the guest
$ sudo ip link set eth0 up
$ sudo ip addr add 192.168.64.50/24 dev eth0
$ sudo ip route add default via 192.168.64.1
$ echo nameserver 192.168.64.1 | sudo tee /etc/resolv.conf(-T/--tap is Linux-only and --vmnet is macOS-only; each errors out on the
other platform.)
The benchmark workload is a Rust compile: rustc is LLVM plus a large frontend
on top, so it has the instruction footprint that a boot or a small kernel like
coremark does not. tools/mk-bench-disk.py builds a disk carrying a pinned
riscv64 Rust toolchain, a gcc link driver, this repo's source and a vendored
registry, so the guest compiles entirely offline -- no networking, and so no
root, on any platform:
$ ./run-bench.sh # the full build, a couple of hours
$ ./run-bench.sh --smoke # a trivial crate instead, a few minutesIt builds the emulator, builds the benchmark disk if it is missing, boots Ubuntu straight into the workload, and prints:
BENCH-ELAPSED 4031.93 s (guest uptime clock)
insns 1005524461313 in 8094.782 s = 124.2 MIPS
The guest powers itself off when the workload finishes, so the run is
unattended, and the exit status reflects whether the compile succeeded.
./run-bench.sh --help lists the rest: --image to benchmark a different
guest, --mem, --rebuild, and --source worktree to benchmark uncommitted
changes rather than HEAD (the reported revision is tagged so a result cannot
be mistaken for a committed one).
Everything the disk carries is pinned -- the Rust version, the Ubuntu suite the
.debs come from, and the source revision -- because changing any of them
makes it a different benchmark. Record them with the result; the generated
bench.sh states all three.
--max-insns N stops after N instructions (a k/M/G suffix is accepted)
and reports the rate. A fixed instruction budget is the same amount of work on
every host, which a fixed wall-clock window is not, so it is the flag to use
when comparing machines or builds:
$ cargo r -rq -- -n --max-insns 200M -m 2048 linux/fw_payload.elf -f linux/rootfs.img
insns 200000124 in 0.799 s = 250.4 MIPSIt fixes the instruction count, not the instruction stream: a Linux boot still takes a slightly different path from run to run, because its timer interrupts follow the host clock. So this makes rates comparable across hosts; it does not by itself make a boot a valid A/B for an emulator change.
--append replaces the device tree's /chosen/bootargs, which is what lets a
run skip userspace entirely:
$ cargo r -rq -- --append "root=/dev/vda1 rw console=ttyS0 init=/bin/sh" \
-m 8192 --rva23 linux/fw_payload.elf -f ubuntu-26.04-preinstalled-server-riscv64.imgBooting Ubuntu 26.04 this way reaches a root shell in about 0.4 s of guest
time. It also keeps systemd and cloud-init, whose ordering follows the host
clock, out of whatever is being measured. Note that Ubuntu 26.04's riscv64 port
is RVA23-baseline: without --rva23 its /bin/sh takes an illegal-instruction
trap and the kernel panics immediately.
It is applied after -d, so it overrides a supplied tree, and before
--dumpdtb, so the dump shows the command line that would really be used.
$ ./run-riscv-tests.shSee wasm/web
See wasm/npm
