RISC-V Proxy Kernel
The RISC-V Proxy Kernel (pk) is a minimal, user-mode execution environment used to run RISC-V binaries on simulators and emulators. In the Swimmer-RISCV toolchain it serves two roles:
Application loader — When running an ELF binary compiled with
riscv64-unknown-elf-gcc, the proxy kernel is passed to Swimmer-RISCV through the--use-pkoption. The simulator loads the binary and the proxy kernel together so that the program can execute as if it were running natively under a Unix-like environment.Berkeley Boot Loader (bbl) — When simulating RISC-V Linux built with Freedom-U-SDK, the proxy kernel is produced as
freedom-u-sdk/work/riscv-pk/bbland passed to Swimmer-RISCV via--binfileto boot the Linux image.
Usage with Swimmer-RISCV
The proxy kernel is integrated with Swimmer-RISCV through the following CLI options (taken from the Swimmer-RISCV README):
--use-pk <path>— Specify the location of the RISC-V Proxy Kernel.--binfile <path>— RISC-V binary file to be simulated.--hexfile <path>— RISC-V srec (hex) file to be simulated.--stop-host— Simulator stops when accessingtohost/fromhostmemory addresses (the proxy kernel's host-call interface).--vmlinux <path>— Specify location of thevmlinuxobject, used for simulating RISC-V Linux (often built on top ofriscv-pk/bbl).
Running a user program
$ cat test.c
#include <stdio.h>
main () { printf("Hello\n"); }
$ riscv64-unknown-elf-gcc test.c -o test.elf
$ swimmer_riscv --binfile test.elf --use-pk ${RISCV}/riscv64-unknown-elf/bin/pk
Hello
Booting Freedom-U-SDK Linux
$ swimmer_riscv --binfile freedom-u-sdk/work/riscv-pk/bbl
Relationship to Swimmer-RISCV
Swimmer-RISCV is a configurable RISC-V instruction set simulator written in C++. It depends on riscv-pk for:
- Hosting user-mode RISC-V ELF programs (via
--use-pk). - Providing the Berkeley Boot Loader that wraps a Linux kernel image for booting via
--binfile(and optionally--vmlinux).
The proxy kernel therefore acts as the primary bridge between compiled RISC-V binaries and the Swimmer-RISCV simulator, enabling both application-level and full-Linux simulation flows.