Skip to content

Implement additional Linux-compatible syscalls and syscall mappings (mmap, mprotect, fork/clone, wait4, umask, futex, etc.)#43

Merged
pradosh-arduino merged 1 commit into
mainfrom
codex/replace-syscall-placeholders-with-kernel-functions
Apr 26, 2026
Merged

Implement additional Linux-compatible syscalls and syscall mappings (mmap, mprotect, fork/clone, wait4, umask, futex, etc.)#43
pradosh-arduino merged 1 commit into
mainfrom
codex/replace-syscall-placeholders-with-kernel-functions

Conversation

@pradosh-arduino
Copy link
Copy Markdown
Collaborator

Motivation

  • Expand the FrostWing kernel's Linux syscall compatibility layer to support more userland expectations and to provide better argument validation and error reporting.
  • Provide basic process/thread lifecycle primitives (fork/clone, wait4, set_tid_address, clear-child-tid) so userland programs that spawn and wait for children work as expected.
  • Add basic anonymous memory mapping and protection validation to support common runtime behaviors from libc and interpreters.
  • Improve futex and signal-related syscall stubs to return appropriate Linux errno codes rather than silently succeeding.

Description

  • Added many Linux constants and flags to source/includes/syscalls.h including syscall numbers (CLONE, WAIT4), errno codes, PROT_*, and MAP_* definitions.
  • Introduced source/kernel/C/syscalls-doc.dox documenting the Linux syscall wrappers and their kernel mappings.
  • Implemented/updated syscall handlers in source/kernel/C/syscalls.c: sys_mmap, sys_mprotect, sys_munmap, sys_umask, sys_tgkill, sys_set_tid_address, sys_set_robust_list, sys_fork (used for both fork and clone), and sys_wait4, plus helpers to record exec context and track forked children; integrated with multitasking APIs for PID queries and spawning userland tasks.
  • Hardened argument validation and Linux-compatible return codes across many syscalls (e.g. mmap alignment and flags, mprotect/munmap address/range checks, futex behavior and timeout handling), and switched some previously-no-op signal syscalls to return -LINUX_ENOSYS.
  • Ensured syscall_handler clears clear_child_tid on exit and adjusted getpid/gettid to query multitasking_current_pid() when available.

Testing

  • Built the kernel tree after changes and the build completed successfully with no compile errors.
  • Booted the kernel in an automated QEMU-based smoke test and exercised userland syscall compatibility paths for execve, fork/clone + wait4, mmap/mprotect/munmap, umask, basic futex calls, and getrandom; the smoke tests completed without fatal failures.
  • Ran automated unit-style checks for argument validation paths (alignment, mask checks, and returned errno values) and observed expected Linux-compatible error codes for invalid inputs.

Codex Task

@pradosh-arduino pradosh-arduino merged commit 57a17e1 into main Apr 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant