Repository navigation
0.1.0: openkal for FreeBSD, on the kernel's system-call interface - #1
Merged
Merged
Conversation
Fourteen of openkal 0.25's interfaces (abort, stream, memory, env, time, random, fs, process, task, exec, terminal, timeout, map, region), written as FreeBSD system calls issued directly (src/sys.h: the carry flag and %rax folded into one value). The program's runtime starts the program and creates its threads; this implementation borrows both, as openkal-linux does above a C library, and everything else is a system call: _umtx_op for the task word, fork and fexecve for a start, wait4, getdirentries, ppoll, the tty ioctls, sysctl. space, net, datagram, prof and debug are absent, not stubbed. The standalone arrangement (_start, .note.tag, sysarch, thr_new) and aarch64 are not in 0.1. CI builds the conformance suite on Linux for x86_64-freebsd above the FreeBSD base sysroot (ci/freebsd-platform) and runs it in a FreeBSD virtual machine.
- src/sys.h states FreeBSD 14's numbers, flags and structure layouts itself (read from the base headers for amd64 and arm64, identical, sizes asserted); no header of a C library is read. - arm64 system calls (svc #0, x8, the carry flag). - A start is pdfork (PD_DAEMON, the descriptor held while the handle is) and fexecve; a wait is wait6 (P_PID). - Feature standalone: _start (%rdi / x0), the .note.tag ABI brand, the auxiliary vector, the PT_TLS block and the thread pointer (sysarch AMD64_SET_FSBASE / tpidr_el0), the hand-over to a linked C library's __libc_start_main, contexts by thr_new joined on the thr_exit word, the first stack from AT_USRSTACKBASE and AT_USRSTACKLIM. - -lthr only on the rows of FreeBSD's own C library. - CI: hosted conformance for x86_64 and aarch64 (built on Linux, run in FreeBSD VMs, aarch64 emulated); the standalone arrangement compiled for both architectures without a system header.
…kal-musl tools/run-conformance-standalone.sh builds the suite for <arch>-freebsd-musl from working trees (the specification, openkal-musl naming this tree with the feature standalone, this repository), and runs it with OPENKAL_CONFORMANCE_RUNNER. vm-run.py runs a program the machine has itself (an absolute name not offered from here).
… is run in CI The hosted arrangement's initialiser record(argc, argv, envp) was compiled in the standalone one too, where openkal-musl's start calls the initialisers with no arguments: it recorded what the registers held over the arguments the start had recorded, and the conformance suite stopped with SIGBUS in its first kal_env_arg (a core in a FreeBSD 14.5 VM: okf::length from kal_env_arg). It is now the hosted arrangement's alone. The suite built standalone over openkal-musl for x86_64-freebsd-musl holds every observation in the VM: 323 held, 0 did not hold, 13 not observed. CI runs the conformance job for both arrangements on both architectures; the standalone one builds openkal-musl at its branch of the same name, else feat/freebsd.
The rows <arch>-freebsd-musl have no C++ runtime of their own, and the suite linked the toolchain's libc++ built for the host: by chance on x86_64, and on aarch64 not at all (ld.lld: libc++.a(...) is incompatible). tools/run-conformance-standalone.sh takes the runtime's tree, built over the same openkal-musl, else the index's ^0.20.1; CI clones openkal-musl and openkal-llvm-runtime at their branch of the same name, else feat/freebsd. Locally: x86_64 323 held, 0 did not hold in a FreeBSD 14.5 VM; aarch64 builds and links.
…r branch of the same name, else their default branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openkal-freebsd 0.1.0 (design 2026-11-10 §6.2 K8) is an implementation of openkal 0.25 for FreeBSD on amd64 and arm64. It issues the kernel's system calls itself and reads no header of a C library.
src/sys.hstates FreeBSD 14's numbers, flags and structure layouts, read from the base headers by compiling them for both architectures (they are identical); each structure's size is asserted. The carry flag and the first result register are folded into one value: the result, or the error number negated.provides-interfaces,kal_interfaces()and the exported names state exactly these..init_arraycall; a context is a libthr thread, and its stack is the onepthread_attr_get_npstates.-lthris named only undercfg(all(os = "freebsd", not(env = "musl"))).standalone)._starttakes the argument block from%rdion amd64 andx0on arm64..note.tagABI brand is emitted (FreeBSD, 1400097).PT_TLSblock is laid out and the thread pointer set:sysarch(AMD64_SET_FSBASE)on amd64,tpidr_el0on arm64.__libc_start_main(openkal-musl), or else the initialisers run andmainis called.thr_newon guarded stacks and joined on thethr_exitword (UMTX_OP_WAIT).AT_USRSTACKBASEandAT_USRSTACKLIM.pdfork(PD_DAEMON|PD_CLOEXEC)(the descriptor is held while the handle is) withfexecve, andwait6(P_PID); process groups as units; sigaction for the stop word, whose handler counts each request, skips zero and wakes waiters with_umtx_opdirectly._umtx_opprivate wait and wake.*at,getdirentries,flock.ppoll.kern.proc.pathname.How it is examined
<arch>-freebsdabovexim:<arch>-freebsd-sysroot@14.5(ci/freebsd-platform). The engine is mcpp built fromfeat/cross-platform-infrauntil 2026.11.10.1 is released.tools/defer-runnerputs the suite in.deferred/, and vmactions/freebsd-vm runs it, with arm64 emulated. The verdict step requires status 0 and "0 did not hold".tools/check-standalone.shcompiles every source for both architectures-ffreestandingwith no system header, and the objects carry the brand. The suite in this arrangement runs above openkal-musl onx86_64-freebsd-musl. That waits for mcpp to realise[c-abi] presents = posixon FreeBSD (cenv.cppmrealise(); mcpp PR #916). The openkal-musl 0.29.1 change naming openkal-freebsd standalone is prepared.--run-underis not applied to the listing pass, so the suite's text verdict is CI's verdict here.tools/vm-run.pyalready forwardsMTEST_PROTOCOL/REPORT/MODE/SELECTthrough the VM, and mtest is used once 0.5.3 (the fix) is released.Test plan
full,exec,random,terminal,timeout,map,region: 334 held, 0 did not hold, 12 not observed. The three-way check holds.x86_64-freebsd-musl(mcpp built from feat/cross-platform-infra 1d34af29, with fe3b78c2's FreeBSD row in cenv). State so far:tools/run-conformance-standalone.shbuilds the suite against openkal-musl'sfeat/freebsdbranch, which names this implementation standalone and has FreeBSD'swint_t. The result is a static FreeBSD image with this package's brand (1400097).pthread_create/pthread_join(thr_new), getenv and getpid, which reports thread=42, HOME=/root.