504 Commits

Author SHA1 Message Date
Matthew Leach
41ffd1b157 Merge pull request #284 from arihant2math/ext4plus-bump2
Bump ext4plus
2026-04-17 11:21:48 +01:00
Ashwin Naren
1793e24cb8 bump ext4plus 2026-04-16 21:06:52 -07:00
Ashwin Naren
dbc01b8977 fix issues for systemd bringup 2026-04-14 16:16:30 -07:00
Matthew Leach
8ec17724d9 libkernel: add documentation and cargo metadata
Fix up missing documentaiton and add metadata to the cargo definition.
2026-04-13 11:37:57 -07:00
Matthew Leach
3f87c1f3d9 libkernel: add feature gates
Add feature gates for different libkernel features. Specifically:

 - alloc: Memory allocation APIs.
 - paging: Paging related types & functions.
 - fs: Filesystem implementations.
 - proc_vm: Process VM management.
 - kbuf: Circular, page-backed, kernel buffer.

Also gate crate dependencies bsaed upon selected features.
2026-04-13 11:37:57 -07:00
Ashwin Naren
07c1739654 implement setuid, setgid, setreuid, setregid, setresuid, setresgid 2026-04-12 09:57:01 -07:00
Matthew Leach
bc2ad1f042 Merge pull request #278 from arihant2math/pselect6-timeout
pselect6: Handle more parameters
2026-04-05 07:27:24 +01:00
Ashwin Naren
4f691d3e60 handle timeout, writefds, and mask correctly in pselect6 2026-04-04 19:45:43 -07:00
Matthew Leach
7984272376 Merge pull request #271 from arihant2math/ext4plus-bump
Use as_any to downcast inodes for updating in ext4
2026-04-03 08:53:40 +01:00
Matthew Leach
d0e77a883d Merge pull request #276 from arihant2math/dont-leak-fd
sys_pipe2: prevent file descriptor leak on copy_to_user failure
2026-04-03 08:51:38 +01:00
Matthew Leach
083bbd621b Merge pull request #277 from arihant2math/more-proc-pid-stat
More proc_pid_stat memory reporting
2026-04-03 08:50:39 +01:00
Ashwin Naren
5da64ab419 memory info in /proc/pid/stat 2026-03-30 19:48:29 -07:00
Ashwin Naren
5dd4bb2bf8 proc_pid_stat add processor and num_threads 2026-03-30 11:32:43 -07:00
Ashwin Naren
92089907ee sys_pipe2: prevent file descriptor leak on copy_to_user failure 2026-03-30 11:10:01 -07:00
Ashwin Naren
e55a47d006 implement sched affinity syscalls 2026-03-29 09:35:19 -07:00
Matthew Leach
c7552ee3f7 Merge pull request #273 from hexagonal-sun/ptrace-thread
ptrace thread
2026-03-24 06:10:57 +00:00
Ashwin Naren
7edfe622f5 Use as_any to downcast inodes at will and bump ext4plus 2026-03-23 21:52:36 -07:00
Matthew Leach
a3836bb88b thread_group: wait: separate out ptrace events from child events
ptrace 'child' events are treated differently during a wait than
'normal' child events.  Speciecially, a process that is being traced
receives events for all threads (all `Tid`s) from a process, rather than
the `Tgid`.

This fixes running strace on multi-threaded programs.
2026-03-23 17:30:08 +00:00
Matthew Leach
bf4d1dbac4 process: make Tid globally unique
Make the `Tid` globally unique, rather than `Tgid` creating a new number
space. This allows ptrace to differentiate between threads when using
`-f` on a program which spawns threads.
2026-03-23 06:08:21 +00:00
Ashwin Naren
f49a3f9b65 implement getcpu(2) 2026-03-20 23:54:32 -07:00
Ashwin Naren
9ec0447c40 post-rebase fixes 2026-03-20 12:59:36 -07:00
Ashwin Naren
819e3671cc address review 2026-03-20 12:59:36 -07:00
Ashwin Naren
15628621d4 mount fixups 2026-03-20 12:59:36 -07:00
Ashwin Naren
a45367b833 mount implementation 2026-03-20 12:59:36 -07:00
Matthew Leach
ac3dcccdf2 arch: arm64: memory: fix cache flush for non-cache aligned addrs
If an object isn't aligned to a cache line boundary, the flush loop
advances by a full cache line stride from the misaligned start address.
This can cause the pointer to overshoot the object end before reaching
the next cache line, leaving it unflushed.

This was observed on secondary CPU bringup where the boot context struct
was not cache-line aligned, causing the secondary core to read stale
data from RAM for fields in the second cache line.

Fix this by aligning the start address down to a cache line boundary
before iterating.
2026-03-20 12:37:23 -07:00
Matthew Leach
d838add05c arm64: secondary: insert isb after cache flush
Insert an instruction barrier to ensure that the cache-flush operation has
completed prior to the PSCI call.
2026-03-20 12:37:23 -07:00
Matthew Leach
bd64a67eae Merge pull request #266 from hexagonal-sun/sched-refactor-part2
sched refactor part2
2026-03-19 23:00:28 +00:00
Matthew Leach
aaac9ffd2c sched: eliminate CUR_TASK_PTR
Replace `CUR_TASK_PTR` with `ProcessCtx`. This allows differentiation
between functions that access process context (take in `ProcessCtx` as a
parameter) and those that don't.

When creating a new class of scheduleable tasks (softirqs, kthreads),
this ensure that those functions cannot call context-sensitive
functions.
2026-03-19 20:58:15 +00:00
Matthew Leach
3d20e28c4f sched: Work: deref into Arc<Task> rather than OwnedTask
Since a Arc<Work> can be obtained from `TASK_LIST`, this would allow the
potential mutation of 'owned'-state from other CPUs thereby causing a
race condition. Thefore, ensure that the deref of an `Arc<Work>` only
permits access to `t_shared`.
2026-03-18 13:52:25 +00:00
Matthew Leach
a8aef0483f Merge pull request #259 from arihant2math/proc-exe 2026-03-18 06:43:08 +00:00
Matthew Leach
cc099bfbb1 Merge pull request #261 from arihant2math/retain-cpu-affin 2026-03-18 06:42:21 +00:00
Ashwin Naren
c2dba9762c retain CPU affinity when rescheduling 2026-03-17 15:54:58 -07:00
Matthew Leach
4f3f758c82 Merge pull request #263 from arihant2math/more-proc-stat 2026-03-16 07:52:54 +00:00
Ashwin Naren
267af05a9b implement procs_running and procs_blocked in /proc/stat 2026-03-15 19:23:23 -07:00
Matthew Leach
eed4d1d889 Merge pull request #262 from arihant2math/mark-syscalls
Update some syscall info in `etc/syscalls_linux_aarch64.md`
2026-03-15 10:58:08 +00:00
Ashwin Naren
234c3a7a33 update some syscall info in etc/syscalls_linux_aarch64.md 2026-03-14 17:51:17 -07:00
Ashwin Naren
98719b0557 Merge pull request #260 from hexagonal-sun/sched-refactor
sched refactor
2026-03-13 23:47:37 -07:00
Ashwin Naren
a3d85ced59 implement /proc/<pid>/exe 2026-03-12 10:33:30 -07:00
Matthew Leach
973a93ff65 sched: runqueue: fix tick and runqueue insertion bug
Ensure that `tick()` is called on the current task, and allow the task
account decide whether we should try to switch to another task.

Also, ensure accounting is updated for freshly inserted tasks into the
runqueue.
2026-03-12 11:26:38 +00:00
Matthew Leach
203055b83e sched: runqueue: derfer task drops and drop Finished tasks
Fix two issues:

1. When a task is dropped from the runqueue, it will trigger the
   destructors for the task to run. This may well call wakers to wake up
   parent processes, other ends of pipes, etc. If we do that while
   `SCHED_STATE` is still borrowed, this causes a double-borrow panic. Fix
   this by deferring all drops until after we have unlocked `SCHED_STATE`.

2. Tasks inside the runqueue which are yet to be scheduled which become
   finished will be returned by `find_next_task` and the state will be set
   to `TaskState::Running` overwriting the fact that this task had
   `Finish`ed. We'd then queue this task forever. Filter finished tasks in
   `find_next_task` and add them to the defered drop list.
2026-03-12 10:53:22 +00:00
Matthew Leach
5ebfc29cd2 sched: introduce Work as the unified scheduleable unit
Refactor the scheduler so all scheduleable work is wrapped in Arc<Work>,
replacing the previous per-CPU wait_q design where sleeping tasks were
bound to a specific CPU. Wakers now hold direct Arc<Work> references and
can re-enqueue tasks on any CPU upon wakeup.

Key changes:

- Add Work struct wrapping OwnedTask with an AtomicTaskState and
  scheduler metadata (SchedulerData), replacing the old SchedulableTask.
  Remove Task::state (Arc<SpinLock<TaskState>>). Work::state is now the
  single source of truth for task state.

- Rewrite the run queue using BinaryHeap-based eligible/ineligible split
  (EEVDF) with a dedicated VClock, replacing the BTreeMap linear scan.
  Extract vclock into its own module.

- Rewrite wakers to hold Arc<Work> directly instead of looking up tasks
  by TaskDescriptor from TASK_LIST.

- Replace lock-based sleep transitions in uspc_ret with atomic CAS
  (try_sleep_current) that correctly detects concurrent Woken state.

- Simplify least-tasked-CPU metric to use only run-queue weight, since
  sleeping tasks are no longer bound to any CPU.

- Add current_work() accessor.
2026-03-12 10:53:22 +00:00
Matthew Leach
e12af349ad Merge pull request #258 from arihant2math/ext4plus-update
Update ext4plus to 0.1.0-alpha.5
2026-03-12 09:54:06 +00:00
Ashwin Naren
654b31efc6 bump to 0.1.0-alpha.5 2026-03-11 00:32:33 -07:00
Ashwin Naren
136fb16275 set time of creation correctly 2026-03-10 23:37:29 -07:00
Ashwin Naren
4212b85e6c update ext4plus to 0.1.0-alpha.4 2026-03-10 17:08:46 -07:00
Matthew Leach
5becb38531 Merge pull request #253 from arihant2math/socket-fixups 2026-03-08 05:40:57 +00:00
Matthew Leach
ce156c1bd8 Merge pull request #255 from arihant2math/fix-uart-freeze 2026-03-08 05:36:24 +00:00
Matthew Leach
9491549ae9 Merge pull request #256 from arihant2math/arm-gic-v2 2026-03-08 05:35:56 +00:00
Ashwin Naren
0d466dce19 finish implementation of arm GIC v2 driver 2026-03-07 18:40:40 -08:00
Ashwin Naren
50dcaf2f14 proper draining of uart 2026-03-07 18:00:07 -08:00