add basic support of the system calls 'fork' and 'spawn_process'#970
Open
stlankes wants to merge 10 commits into
Open
add basic support of the system calls 'fork' and 'spawn_process'#970stlankes wants to merge 10 commits into
stlankes wants to merge 10 commits into
Conversation
3fcf25e to
10fc90a
Compare
In the long term, Hermit will also be usable as a monolithic OS. To prepare for this, an example of calling the fork system call is being integrated. In the case of a unikernel, the fork call will return an error (ENOSYS).
Add the system call `spawn_process`, which creates a new process from the executable file.
In the long term, Hermit will also be usable as a monolithic OS. To prepare for this, an example of calling the fork system call is being integrated. In the case of a unikernel, the fork call will return an error (ENOSYS).
Replace all `-22` placeholders in the user-side syscall layer with real `syscall!` invocations and extend `SyscallNo` with the matching numbers (18–53) for spawn/join, file metadata, condvars, task blocking and the socket API.
- extend the fork example to test the system call `exec`
Mirrors hermit/src/syscall/x86_64.rs for the aarch64 target so that
common-os user-space binaries can issue syscalls into the kernel.
Convention follows the Linux-like AArch64 SVC ABI:
- svc #0 triggers the exception
- syscall number in x8 (input only)
- arguments in x0..x5 (up to six, like the existing macro)
- return value in x0 (`inlateout` for syscall1+, plain `lateout`
for syscall0)
- PSTATE.NZCV is preserved across the SVC, so options(preserves_flags)
is sound
The macro and the syscall0..syscall6 helper signatures match the x86_64
side verbatim, so the rest of the crate (sys_open, sys_read, sys_write,
sys_fork, sys_waitpid, …) compiles unchanged on aarch64.
dfdd348 to
0377355
Compare
+ revert obsolete changes
- add a small benchmark to measure the overhead
Wires up the sys_mmap user-space stub (hermit_abi PROT_* flags, plumbing in syscall/mod.rs and Cargo.toml) and switches the Talck- based user heap from a 64 KiB static buffer to an mmap-backed heap that can grow on demand: - the first sys_malloc reserves an initial MIN_SIZE region via sys_mmap (anonymous, demand-paged), and HEAP_END tracks its current upper bound; - a later allocation that exceeds the existing heap extends the same VMA via sys_mmap(extend_size, …, &mut heap_end) and tells the allocator about the new region with ALLOC.extend(…).
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.
In the long term, Hermit will also be usable as a monolithic OS. To prepare for this, an example of calling the system calls
forkandspawn_processare being integrated. In the case of a unikernel, the fork call will return an error (ENOSYS).