Show HN: Our space game has a built-in RISC-V emulator that runs Linux
PasRISCV is an in-house RISC-V emulator created for the space game SEEDS, which includes a fully emulated Linux system that runs the game's in-game tools for the player. For example, when a player opens the planetary overview and stats through the program selector on the homebase computer, those apps are native Linux programs: even on a Windows machine, the ELF binaries execute on an emulated 64-bit RISC-V system running Alpine Linux. The emulator is programmed in Object Pascal, is available as free and open-source software, and both PasRISCV and its frontend companion pasriscvemu are licensed under the permissive zlib license; a fastfetch screenshot shows Alpine Linux riscv64 running on PasRISCV.
The developers chose full virtual-machine emulation rather than userspace-only emulation. PasRISCV emulates a complete machine, including display and storage devices, interrupts, and other hardware details, so the running kernel sees what appears to be a complete hardware system even though it is virtual. The emulated machine uses the 64-bit RISC-V ISA, which is an open standard and free to use under a permissive license, unlike proprietary architectures such as x86 and ARM; this means builders of new RISC-V hardware devices do not have to pay royalties for using the ISA itself.
Technically, the system provides SMP/MultiHART, RV64GC, and RVA23 support, including Hypervisor and Vector extensions, plus additional scalar and vector cryptography extensions. The post notes that a full list of emulated features is beyond the introduction and points readers to the PasRISCV repository for a complete overview.
For CPU and FPU emulation, PasRISCV uses a hybrid approach: an interpreter combined with a tracing JIT compiler. The JIT currently is limited to x86-64 hosts but supports about 99% of the instructions encountered, and floating-point operations can be handled directly by the host FPU. An optional mode combines software floating point with the interpreter for stricter behavior, because IEEE 754-2008 specifies some behavior that cannot be reproduced exactly using x86 floating-point hardware.
On the Linux side, launching a new game or loading a saved game in SEEDS means the emulator in the background is already booting the system. A normal Linux kernel can be booted either directly through OpenSBI or through U-Boot; the excerpt ends as it begins to describe this boot process.