Commit Graph

547 Commits

Author SHA1 Message Date
Matthew Leach
052ca0e4e3 libkernel: smalloc: add claim_region for downstream allocators
Introduce Smalloc::claim_region, which removes a sub-region from the
free memory pool and transfers ownership to another allocator. The
region is punched out of the memory list rather than being added to the
reservation list.
2026-05-10 13:57:49 -07:00
Matthew Leach
72ef61fb10 libkernel: pg_tear_down: add more flexibility
The current tear down implementation assumes that all data mappings &
intermediate tables need to be free'd. That might not provide enough
flexibility for all tear-down scenarios.

Provide a more flexible API, passing current walk state into a control
function which makes a descision regarding tear-down and recursion.
2026-05-10 13:57:49 -07:00
Matthew Leach
d0b10adf7c libkernel: move SmallocPageAlloc into libkernel
The `SmallocPageAlloc` type is generic and architecture-independent, so
it belongs in libkernel rather than the kernel's arm64-specific code. It
is placed in memory::paging::smalloc_page_allocator and gated by the
existing paging feature.

The kernel's copy is replaced with a thin re-export so all call sites
are unaffected.
2026-05-10 13:57:49 -07:00
Matthew Leach
80af2e8852 libkernel: pg_offset: decouple from VirtualMemory trait
Since the only requirement for a `PageOffsetTranslator` is a constant
offset, pass that in as a generic parameter, allowing it to be decoupled
from the `VirtualMemory` trait.
2026-05-10 13:57:49 -07:00
Matthew Leach
370aae9697 libkernel: CpuOps: make interrupt flags a associated type
Rather than hard-coding the interrupt flags as a `usize`. Allow each CPU
architecture to define it's own interrupt flags type via an associated
type.
2026-05-10 13:57:49 -07:00
Ashwin Naren
20c17b69c5 implement F_DUPFD_CLOEXEC for fcntl 2026-04-26 21:21:20 -07:00
Matthew Leach
d7d9bfcddc Merge pull request #287 from hexagonal-sun/libkernel-v0-1-1
libkernel: v0.1.1
2026-04-23 21:35:21 +01:00
Matthew Leach
8f4692253e libkernel: v0.1.1 2026-04-23 21:15:23 +01:00
Matthew Leach
5af78647b0 Merge pull request #274 from arihant2math/better-timers 2026-04-23 17:36:24 +01:00
Matthew Leach
4a6ef6f3de Merge pull request #257 from arihant2math/unix-dgram 2026-04-23 17:36:01 +01:00
Ashwin Naren
99d72786ad address review 2026-04-23 09:10:51 -07:00
Matthew Leach
6e3a306d28 Merge pull request #286 from hexagonal-sun/libkernel-fix-last-entry-pg-table-walking 2026-04-23 06:04:40 +01:00
Matthew Leach
6d41e485b3 libkernel: pg_walk: use saturating arithmetic to avoid overflow at last page-table entry
The generic RecursiveWalker computed the coverage region for each
page-table entry as:

    VirtMemoryRegion::new(entry_va, table_coverage).intersection(region)

For the last entry at the PML4 level (PML4[511]) in the kernel
high-half, entry_va + table_coverage wraps past usize::MAX, causing an
arithmetic overflow panic inside end_address().

Fix this in walk.rs by computing the intersection bounds with
saturating_add/min/max directly.

Add regression tests for all levels, ensuring last-element walking is
correct.
2026-04-21 15:56:56 +01:00
Ashwin Naren
bf73a8914f use generic wakeup instead of specialized 2026-04-18 18:39:28 -07:00
Ashwin Naren
65d0581736 implement itimer syscalls 2026-04-18 18:39:28 -07:00
Ashwin Naren
6b97bab57f wake signalfd readers on signal delivery
- add per-task signal waiter notifier
- wake waiters when task/group signals are queued
- replace signalfd polling sleep with waker-based waiting
- route SIGCHLD and other signal enqueue sites through shared helpers
2026-04-17 14:22:15 -07:00
Ashwin Naren
14ae01767d address review 2026-04-17 14:22:15 -07:00
Ashwin Naren
2654126644 fix usertest warning 2026-04-17 14:22:15 -07:00
Ashwin Naren
defa422243 signal4fd syscall 2026-04-17 14:22:15 -07:00
Ashwin Naren
e2202e1cb8 epoll implementation 2026-04-17 14:22:15 -07:00
Ashwin Naren
3ddcc8e7b3 pidfd stub 2026-04-17 14:22:15 -07:00
Matthew Leach
68e1b57739 libkernel: error: fix doc error
Fix a doc error in the libkernel::error module.
2026-04-17 22:17:40 +01:00
Matthew Leach
6a876bb0ed Merge pull request #283 from hexagonal-sun/libkernel/x86_64-paging
libkernel/x86 64 paging
2026-04-17 22:14:09 +01:00
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
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
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