Skip to content

Syscall Reference

Rumpk syscalls are invoked via ecall (RISC-V) or svc #0 (ARM64). The syscall number is in a7/x8, arguments in a0-a2/x0-x2, return value in a0/x0.

VFS Operations

NrNameArgsReturnsDescription
0x200SYS_OPENpath, flagsfd or -1Open file in VFS (/sysro, /nexus, /state)
0x201SYS_CLOSEfd0 or -1Close file descriptor
0x202SYS_LISTbuf, maxlencountList directory entries
0x203SYS_READfd, buf, lenbytes readRead from fd (stdin blocks until input)
0x204SYS_WRITEfd, buf, lenbytes writtenWrite to fd (stdout/stderr to PTY or console)
0x205SYS_IOCTLfd, request0I/O control (stub)
0x206SYS_FCNTLfd, cmd, argvariesFile control (F_DUPFD supported)

Process Control

NrNameArgsReturnsDescription
0x01SYS_EXITstatusTerminate current fiber
0x65SYS_NANOSLEEPns0Sleep for ns nanoseconds
0x66SYS_GET_TIMEnsGet current time in nanoseconds
0x100SYS_SPAWNpath, argfiber_idSpawn new fiber from ELF
0x101SYS_PLEDGEmask0 or -1Narrow pledge mask (can only restrict, never widen)
0x102SYS_JOINfiber_id0Wait for fiber to exit
0x500SYS_CHECKPOINTblob_ptr, blob_len0 or -1Save fiber checkpoint (Phase 6.4)

LWF Operations (Sovereign Networking)

NrNameArgsReturnsDescription
0x700SYS_LWF_RECVbuf, maxlenframe_len or 0Pop LWF frame from chan_lwf_rx (non-blocking)
0x701SYS_LWF_SENDbuf, lenlen or 0Push LWF frame to chan_lwf_tx
0x702SYS_UTCP_RECVbuf, maxlenframe_len or 0Pop UTCP frame from chan_utcp_rx
0x703SYS_UTCP_SENDbuf, lenlen or 0Push UTCP frame to chan_utcp_tx

Capability gating: LWF_RECV requires capability 0x600 (PERM_READ). LWF_SEND requires 0x601 (PERM_WRITE). Capabilities are granted via BKDL manifest embedded in the capsule ELF.

User buffer bounce: For fibers with per-fiber address spaces (Cell 1+), the kernel uses user_copy_in/user_copy_out to translate between per-fiber VA and kernel PA. The bounce temporarily activates the fiber's worker SATP with interrupts disabled, copies the data, then restores the kernel identity map.

AEAD Cryptography (M5.2 Membrane-Capsule Bridge)

NrNameArgsReturnsDescription
0x800SYS_AEAD_SEALargs_ptr, args_lensealed_len or 0XChaCha20-Poly1305 encrypt
0x801SYS_AEAD_UNSEALargs_ptr, args_lenplaintext_len or 0XChaCha20-Poly1305 decrypt

Backend: Monocypher crypto_aead_lock/crypto_aead_unlock (C reference implementation).

SYS_AEAD_SEAL (0x800)

Encrypts plaintext with XChaCha20-Poly1305. Output format: [24-byte nonce][ciphertext][16-byte Poly1305 tag].

Args struct (56 bytes at a0, a1 = struct size):

OffsetSizeFieldDescription
032key256-bit symmetric key
328plaintext_ptrPointer to plaintext in user memory
408plaintext_lenPlaintext length (max 2000 bytes)
488ad_ptrPointer to additional authenticated data
568ad_lenAD length (max 256 bytes)
648out_ptrPointer to output buffer in user memory
728out_lenOutput buffer max size

Returns: Sealed length (plaintext_len + 40) on success, 0 on error.

SYS_AEAD_UNSEAL (0x801)

Decrypts and authenticates XChaCha20-Poly1305 sealed payload. Rejects tampered data.

Args struct (same layout as SEAL, with sealed data instead of plaintext):

OffsetSizeFieldDescription
032key256-bit symmetric key
328sealed_ptrPointer to sealed data [nonce][ct][tag]
408sealed_lenSealed length (must be >= 40)
488ad_ptrPointer to AD (must match what was used for sealing)
568ad_lenAD length
648out_ptrPointer to plaintext output buffer
728out_lenOutput buffer max size

Returns: Plaintext length (sealed_len - 40) on success, 0 on authentication failure.

Pledge Enforcement

Every syscall is checked against the fiber's pledge mask before dispatch. Pledges can only be narrowed (SYS_PLEDGE with a mask that's a subset of the current mask). Attempting to widen returns -1.

Pledge BitNameSyscalls Gated
0x01PLEDGE_STDIOSYS_READ (fd=0), SYS_WRITE (fd=1,2)
0x02PLEDGE_RPATHSYS_OPEN (read), SYS_READ (fd>=3)
0x04PLEDGE_WPATHSYS_OPEN (write), SYS_WRITE (fd>=3)
0x08PLEDGE_INETSYS_LWF_, SYS_UTCP_, SYS_AEAD_*
0x10PLEDGE_EXECSYS_SPAWN