Commit Graph

519 Commits

Author SHA1 Message Date
Matthew Leach
519fd94eda libkernel: x86_64: pg_tables: ensure canonical address
Ensure that we only try to map canonical addresses in `try_map`.
2026-04-17 22:10:39 +01:00
Matthew Leach
52270c7525 libkernel: pg_tear_down: support block mappings
Support tearing down block mappings when walking the page table
hierarchy.
2026-04-17 22:10:39 +01:00
Matthew Leach
1f6ade8a13 arm64: fix formatting
Fix import formatting.
2026-04-16 21:26:46 +01:00
Matthew Leach
55b441864c libkernel: x86_64: add pg_teardown module
Add a module for tearing down x86_64 userspace page table hierarchies.
2026-04-16 21:22:16 +01:00
Matthew Leach
4eef6cb7f8 libkernel: paging: x86_64: add canonical address tests
Ensure that working with canonical addresses (sign extension of bit 47)
works correctly.
2026-04-16 21:22:16 +01:00
Matthew Leach
34776ab8e9 libkernel: paging: x86_64: implement pg_walk
Implement the pg_walk functionality for x86_64.
2026-04-16 21:22:16 +01:00
Matthew Leach
1e8b115376 libkernel: paging: move NextLevel to TableMapper trait
Move the NextLevel AT into the TableMapper (descriptor-level) trait.
This allows us to provide a blanket implementation of TableMapperTable
for all tables where, Table::Descriptor : TableMapper.
2026-04-16 21:22:16 +01:00
Matthew Leach
b8292cf359 libkernel: memory: move RecursiveWalker to non-arch module
Since the architectural details of descriptor implementation is hidden
behind traits, the code for walking page tables is arch-agnostic.
Therefore, promote it to shared code for use by other architectures.
2026-04-16 21:22:16 +01:00
Matthew Leach
57d35b4ed7 libkernel: paging: move NullTlbInvalidator into shared code
Move the NullTlbInvalidator implementation into shared code since it's
architecturally agnostic.
2026-04-16 21:22:16 +01:00
Matthew Leach
6fa81c234a libkernel: x86_64: fix impl of bit 7
Bit 7 on various descriptors in x86_64 can take on varying values
depending upon the descriptor type. Refelect that in the implementation
and fix a bug whereby the PAT bit would have been set when creating a
PTE.
2026-04-16 21:22:16 +01:00
Matthew Leach
f4910a7c3c libkernel: x86_64: pg_tables: new
Implement page table module for x86_64.
2026-04-16 21:22:16 +01:00
Matthew Leach
7dcc80aafa libkernel: paging: move test harness code out of arm64
The test harness code is useful across architectures. Therefore, move it
out of the arm64 directory so it can be used by other architectures
implementing paging unit-tests.
2026-04-16 21:22:16 +01:00
Matthew Leach
b9dc420aee libkernel: memory: paging: make PageTableEntry contain MAP_SHIFT
We currently define the MAP_SHIFT for a page-table level in two places,
`TableMapper` and `PgTable`. Store only one shift trait constant value
in the `PageTableEntry` trait.
2026-04-16 21:22:16 +01:00
Matthew Leach
a211d82477 libkernel: x86_64: pg_descriptors: new
Add an implementation of x86_64 page descriptors (PML4E, PDPE, PDE,
PTE). Also add corresponding unit tests to ensure correct functionality.
2026-04-16 21:22:16 +01:00
Matthew Leach
ccffa50a0e libkernel: move paging-related arch-agnostic traits out of arch mod
Any traits which are architecture agnostic should be available to be
implemented by other architectures. Move them out from the arm64 module
into a non-architecure specific location.
2026-04-16 21:22:16 +01:00
Matthew Leach
465fcb7acb libkenrel: memory: move paging-related modules to paging module
Move PtePermissions to paging module which is feature-gated behind
`paging`.

Also move all AddressSpace related functionality behind the `proc_vm`
feature gate.
2026-04-16 21:22:16 +01:00
Matthew Leach
3423d738e6 libkernel: arm64: memory: add a MemoryType AT to PaMapper
Allow implementors of the `PaMapper` trait to choose a type which
represents a memory type when mapping a PA region.
2026-04-16 21:22:16 +01: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