Supported Targets

Kona seeks to support all FPVM targets that LLVM and rustc can offer introductory support for. Below is a matrix of features that Kona offers for each FPVM target:

TargetBuild PipelineIOmallocProgram Stages
cannon & cannon-rs
asterisc

If there is a feature that you would like to see supported, please open an issue or consider contributing!

Cannon (MIPS32r2)

Cannon is based off of the mips32r2 target architecture, supporting 55 instructions:

CategoryInstructionDescription
ArithmeticaddiAdd immediate (with sign-extension).
ArithmeticaddiuAdd immediate unsigned (no overflow).
ArithmeticadduAdd unsigned (no overflow).
LogicalandBitwise AND.
LogicalandiBitwise AND immediate.
BranchbUnconditional branch.
Conditional BranchbeqBranch on equal.
Conditional BranchbeqzBranch if equal to zero.
Conditional BranchbgezBranch on greater than or equal to zero.
Conditional BranchbgtzBranch on greater than zero.
Conditional BranchblezBranch on less than or equal to zero.
Conditional BranchbltzBranch on less than zero.
Conditional BranchbneBranch on not equal.
Conditional BranchbnezBranch if not equal to zero.
LogicalclzCount leading zeros.
ArithmeticdivuDivide unsigned.
Unconditional JumpjJump.
Unconditional JumpjalJump and link.
Unconditional JumpjalrJump and link register.
Unconditional JumpjrJump register.
Data TransferlbLoad byte.
Data TransferlbuLoad byte unsigned.
Data TransferluiLoad upper immediate.
Data TransferlwLoad word.
Data TransferlwrLoad word right.
Data TransfermfhiMove from HI register.
Data TransfermfloMove from LO register.
Data TransfermoveMove between registers.
Data TransfermovnMove conditional on not zero.
Data TransfermovzMove conditional on zero.
Data TransfermtloMove to LO register.
ArithmeticmulMultiply (to produce a word result).
ArithmeticmultuMultiply unsigned.
ArithmeticneguNegate unsigned.
No OpnopNo operation.
LogicalnotBitwise NOT (pseudo-instruction in MIPS).
LogicalorBitwise OR.
LogicaloriBitwise OR immediate.
Data TransfersbStore byte.
LogicalsllShift left logical.
LogicalsllvShift left logical variable.
ComparisonsltSet on less than (signed).
ComparisonsltiSet on less than immediate.
ComparisonsltiuSet on less than immediate unsigned.
ComparisonsltuSet on less than unsigned.
LogicalsraShift right arithmetic.
LogicalsrlShift right logical.
LogicalsrlvShift right logical variable.
ArithmeticsubuSubtract unsigned.
Data TransferswStore word.
Data TransferswrStore word right.
SerializationsyncSynchronize shared memory.
System CallssyscallSystem call.
LogicalxorBitwise XOR.
LogicalxoriBitwise XOR immediate.

Syscalls

$v0system call$a0$a1$a2Effect
4090mmapuint32 addruint32 len🚫Allocates a page from the heap. See heap for details.
4045brk🚫🚫🚫Returns a fixed address for the program break at 0x40000000
4120clone🚫🚫🚫Returns 1
4246exit_groupuint8 exit_code🚫🚫Sets the Exited and ExitCode states to true and $a0 respectively.
4003readuint32 fdchar *bufuint32 countSimilar behavior as Linux/MIPS with support for unaligned reads. See I/O for more details.
4004writeuint32 fdchar *bufuint32 countSimilar behavior as Linux/MIPS with support for unaligned writes. See I/O for more details.
4055fcntluint32 fdint32 cmd🚫Similar behavior as Linux/MIPS. Only the F_GETFL (3) cmd is supported. Sets errno to 0x16 for all other commands

For all of the above syscalls, an error is indicated by setting the return register ($v0) to 0xFFFFFFFF (-1) and errno ($a3) is set accordingly. The VM must not modify any register other than $v0 and $a3 during syscall handling. For unsupported syscalls, the VM must do nothing except to zero out the syscall return ($v0) and errno ($a3) registers.

Note that the above syscalls have identical syscall numbers and ABIs as Linux/MIPS.

Asterisc (RISC-V)

Asterisc is based off of the rv64gc target architecture, which defines the following extensions:

  • RV32I support - 32 bit base instruction set
    • FENCE, ECALL, EBREAK are hardwired to implement a minimal subset of systemcalls of the linux kernel
      • Work in progress. All syscalls used by the Golang risc64 runtime.
  • RV64I support
  • RV64C: Compressed instructions
  • RV32M+RV64M: Multiplication support
  • RV32A+RV64A: Atomics support
  • RV{32,64}{D,F,Q}: no-op: No floating points support (since no IEEE754 determinism with rounding modes etc., nor worth the complexity)
  • Zifencei: FENCE.I no-op: No need for FENCE.I
  • Zicsr: no-op: some support for Control-and-status registers may come later though.
  • Ztso: no-op: no need for Total Store Ordering
  • other: revert with error code on unrecognized instructions

asterisc supports a plethora of syscalls, documented in the repository. kona offers an interface for programs to directly invoke a select few syscalls:

  1. EXIT - Terminate the process with the provided exit code.
  2. WRITE - Write the passed buffer to the passed file descriptor.
  3. READ - Read the specified number of bytes from the passed file descriptor.