Commit Graph

244 Commits

Author SHA1 Message Date
Ashwin Naren
bc68aae677 stub sys_clock_nanosleep
# Conflicts:
#	src/arch/arm64/exceptions/syscall.rs
2026-01-13 16:48:01 -08:00
Ashwin Naren
ff13b392f1 some support for ext4 writing 2026-01-13 16:47:51 -08:00
Matthew Leach
d9de03096a Merge pull request #152 from hexagonal-sun/tty-implement-termios2-syscalls 2026-01-13 04:53:08 +00:00
Ashwin Naren
cff5005c06 execute scripts
checks for shebang and executes the specified program
2026-01-12 14:23:49 -08:00
Matthew Leach
b0bc8e5abd tty: implement termios2 ioctls
We currently implement `TCGETS`, `TCSETS` and `TCSETSW` which operate on
a `Termios` struct.  glibc uses the `Termios2` variants of these
syscalls to additionally get the terminal baud rate.

Use a `Termios2` as the main state of the tty.  Return that struct
verbatim  for the newly implemented `Termios2` ioctls.  Convert to/from
the legacy `Termios` struct for the currently implemented ioctls.
2026-01-12 21:44:38 +00:00
Matthew Leach
64bc004cdb process: sys_wait4: return ECHILD with no children
If the calling process has no children and no pending exit events to
handle, return ECHILD instead of waiting forever.
2026-01-11 19:23:47 -08:00
Matthew Leach
a003ab8f71 syscall: sys_exit*: add ptrace events
Add ptrace events for the exit family of syscalls.
2026-01-11 19:23:47 -08:00
Matthew Leach
f4557c1f0f arch: arm64: syscall: don't return result on task exit
If a task has called one of `sys_exit` or `sys_exit_group`, don't follow
the standard syscall exit path. Since the task is dead and it will never
be rescheduled, there's no point in processing the result of sys_exit.
2026-01-11 19:23:47 -08:00
Matthew Leach
abbc8261c5 kill: awake sleepy tasks on SIGKILL
If a SIGKILL has been received, ensure all sleepy tasks are set to
runnable so that they can action the signal.
2026-01-11 19:23:47 -08:00
Matthew Leach
df578992b8 syscalls: sys_process_vm_readv: implement
Implement the `sys_process_vm_readv` syscall.
2026-01-11 19:23:47 -08:00
Matthew Leach
ede1ef39d9 process: sys_rt_sigprocmask: fix UNMASKABLE_SIGNALS
We currently union the UNMASKABLE_SIGNALS set with the new signal mask.
This does the complete opposite of what we wnat, we want to *remove*
those signals from the newly computed signal mask.

This patch removes the UNMASKABLE_SIGNALS set from any newly computed
signal mask.
2026-01-11 19:23:47 -08:00
Matthew Leach
f9e02d9227 process: get_page: new
Add a function that allows an owned page to be atomically obtained from
a new process.
2026-01-11 19:23:47 -08:00
Matthew Leach
64b337ca63 ptrace: send SIGSTOP and PTRACE_EVENT_STOP for stoppable signal
When a new child stops due to a stoppable-signal after PTRACE_TRACEME,
send a SIGSTOP with a `PTRACE_EVENT_STOP`.
2026-01-11 19:23:47 -08:00
Matthew Leach
3a0e1f80e1 ptrace: implement PTRACE_SETOPTIONS
Add option definitions `PTRACE_O_*` and change the ptrace state
depdening upon which options are set in the call.
2026-01-11 19:23:47 -08:00
Matthew Leach
5911eb49ef ptrace: handle continuiation calls
handle `PTRACE_CONT` and `PTRACE_SYSCALL` operations.
2026-01-11 19:23:47 -08:00
Matthew Leach
70d9d730c0 ptrace: add event waiting
Make it such that when a ptrace event is hit:

 - The current regset is saved in the ptrace state.
 - The current task is put to sleep.
 - Arrange for a SIGCHLD to be set to the parent.
 - Notify any waiters with the appopriate signal.
2026-01-11 19:23:47 -08:00
Matthew Leach
c304ec07fe uspc_ret: ensure task is dropped before exiting
Fix current task double-borrow bug when exiting with a signal.
2026-01-11 19:23:47 -08:00
Ashwin Naren
6d8854fe30 initial ptrace 2026-01-11 19:23:47 -08:00
Ashwin Naren
15c70a1aea ext4 timestamps 2026-01-10 10:11:52 -08:00
Matthew Leach
e604b0ad6c Merge pull request #142 from hexagonal-sun/signal-fixups
signal fixups
2026-01-09 08:24:22 +00:00
Matthew Leach
1d79d6b2df process: refactor signal handling and fix action table sharing
This commit refactors the signal handling subsystem to address a bug in
process creation and to improve the separation of concerns between
signal delivery and signal disposition.

1. Fix Action Table Sharing:
Previously, the signal action table was wrapped in an `Arc`, causing
forked child processes to inadvertently share signal dispositions with
the parent. `SignalActionState` now contains a direct `SigActionSet` and
implements Clone, ensuring that processes receive a private copy of the
action table upon fork/clone.

2. Decouple Signal Selection from Execution:
The logic for selecting a pending signal has been moved from the
disposition state into a new `take_signal` method on `OwnedTask`. This
decouples the "taking" of a signal (respecting masks and priorities)
from the "actioning" of that signal. This is a prerequisite for
implementing ptrace.

3. Various cleanup bits:
- Renamed `SignalState` to `SignalActionState` to more accurately
  reflect that it manages signal dispositions.
- Removed the `pending` signal set out of the action state and directly
  into the `ThreadGroup` and `OwnedTask`.
- Renamed `set_pending` to `set_signal` for consistency.
- Simplified the signal delivery loop in `dispatch_userspace_task`
  using the new `take_signal` API.
2026-01-09 06:49:48 +00:00
Matthew Leach
97c07cd31f arch: arm64: signal: use VDSO for sigreturn
Support non SA_RESTORER sigactions by using the trampoline in the kernel
VDSO.
2026-01-09 06:49:48 +00:00
Matthew Leach
4101e9ff11 arch: arm64: vdso: new
Add a very basic VDSO module which allow the kernel to provide various
functions to userspace, such as `sig_return`.
2026-01-09 06:49:48 +00:00
Ashwin Naren
a905a996b4 stub fadvise and process_madvise 2026-01-08 15:36:53 -08:00
Matthew Leach
e8d6c304ae syscalls: wait4: implement WNOHANG
Implement WNOHANG logic within the sys_wait4 system call. If this is
flag is set, remove the process from the ChildNotifiers set without
waiting.
2026-01-08 15:29:42 -08:00
Ashwin Naren
914126917f upload image on CI 2026-01-07 10:58:05 -08:00
Ashwin Naren
1f3b1bc72b free pages when using munmap 2026-01-07 00:59:47 -08:00
Ashwin Naren
5a1d7c1f2d update README 2026-01-06 23:23:26 -08:00
Matthew Leach
a2a37146ff main: init: add arg init option
Add a new option `--init-arg` which allows arguments to be passed to
init when invoked by the kernel. This allows the `-i` parameter to be
passed through to bash such that it will be started in interactive mode.
2026-01-06 16:22:59 -08:00
Matthew Leach
9753639255 syscalls: sys_setfs{uid,gid}: implement
Implement deprecated syscalls sys_setfs{uid,gid}. We simply return the
euid and egid in this case.
2026-01-06 16:22:14 -08:00
Matthew Leach
450880bf8d Merge pull request #133 from arihant2math/fix-fstat-on-char-device 2026-01-06 19:38:14 +00:00
Ashwin Naren
7195772506 run CI tests to completion even if one fails 2026-01-06 11:19:14 -08:00
Ashwin Naren
2afaec7e22 fix fstat for char device 2026-01-06 10:14:23 -08:00
Matthew Leach
a4db1debac syscalls: prctl: add stub impl
Implement PR_CAPBSET_READ with a very basic implementation.
2026-01-06 08:52:52 -08:00
Matthew Leach
bb8b3fec29 libkernel: ext4: add inode id to metadata
Add the proper inode and fs id to the `FileAttr` struct returned by
`getattr`. This prevents the dynamic loader from skipping files which it
considers to be hard-links (share the same inode ID).
2026-01-06 08:52:52 -08:00
Ashwin Naren
f0771dde4f exec with interpreter 2026-01-06 08:52:52 -08:00
Ashwin Naren
a8200dc067 Check and parse PT_INTERP in ELF 2026-01-06 08:52:52 -08:00
Ashwin Naren
626492cf58 error on sys_getaffinity 2026-01-05 11:59:57 -08:00
ootinnyoo
42a2ea2901 use an ext4 rootfs with busybox symlinks 2026-01-03 17:00:13 -08:00
Matthew Leach
74aa508197 futex: implement bitset variants
Implement FUTEX_{WAKE,WAIT}_BITSET by using a `u32` as a data
discriminant value.

Also add a bunch of tests to `usertest` to ensure proper functionality.
2026-01-03 14:36:06 -08:00
Matthew Leach
957e3f04cf libkernel: waker_set: allow data to be associted
Allow data to be associated with a waker set. This allows discriminating
upon which wakes should be woken up via the new `wake_if` function.
2026-01-03 14:36:06 -08:00
Matthew Leach
d8bcc015de arch: arm64: detect kernel stack overflow condition
Currently, when a kernel stack overflow occures, the exception handler
blindly attempts to write the current context to the stack. If the SP
isn't valid this causes another fault, and so on - locking up the
system.

This commit re-arranges the stack layout, performs SP validation before
usage and switches to an emergency stack when SP isn't valid. This
allows the handler to run and panic gracefully.

Fixes: #98
2026-01-03 14:33:51 -08:00
Matthew Leach
57e0aa364c process: task_group: implement pg priority
Currently, each task implements it's own priority value. In Linux, each
thread group (process) has a default process which all tasks in that
group inherit. Tasks can, however, override the default process
priority.

Implement that logic here which also fixes the current compilation error
on master.
2026-01-02 18:16:11 -08:00
Ashwin Naren
477215e641 optimize lookup 2026-01-02 17:01:02 -08:00
Ashwin Naren
8677d7a404 support readlink 2026-01-02 17:01:02 -08:00
Ashwin Naren
40e092faa8 switch qemu-runner back 2026-01-02 17:01:02 -08:00
Ashwin Naren
9d8379c311 fix readdir 2026-01-02 17:01:02 -08:00
Ashwin Naren
d14d2ff355 add note about lookup being suboptimal 2026-01-02 17:01:02 -08:00
Ashwin Naren
dcd74e4e73 optimize read_at 2026-01-02 17:01:02 -08:00
Ashwin Naren
b5138c30f9 working ext4 2026-01-02 17:01:02 -08:00