Commit Graph

116 Commits

Author SHA1 Message Date
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
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
Ashwin Naren
5da64ab419 memory info in /proc/pid/stat 2026-03-30 19:48:29 -07:00
Ashwin Naren
7edfe622f5 Use as_any to downcast inodes at will and bump ext4plus 2026-03-23 21:52:36 -07: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
Ashwin Naren
4a12208d9f fix linux incompatibilities 2026-03-07 17:42:57 -08:00
Ashwin Naren
9fea27a427 dependency updates (#248) 2026-03-06 23:47:10 -08:00
Matthew Leach
4a98779020 Add virtio-rng driver and ProbeError::NoMatch for silent probe skipping
Add a virtio-rng entropy source driver that registers with the kernel
RNG subsystem. Introduce `ProbeError::NoMatch` so virtio drivers can
silently reject empty or wrong-type MMIO slots without spamming the boot
log with fatal errors or leaving devices stuck in the deferred queue.
2026-03-07 07:33:31 +00:00
Ashwin Naren
a3a324148e Socket implementation (#127) 2026-03-06 18:54:36 -08:00
Ashwin Naren
1523b9ccef switch to crates.io ext4plus 2026-03-04 15:48:18 -08:00
Ashwin Naren
edca499714 distinguish between file permissions and file mode 2026-03-02 11:53:06 -08:00
Ashwin Naren
bd5235fc71 fix rename semantics 2026-02-26 23:14:31 -08:00
Ashwin Naren
2ecfda3cb9 fix unneeded inode cloning 2026-02-26 23:14:31 -08:00
Ashwin Naren
93e540bc5c support symlink creation 2026-02-26 23:14:31 -08:00
Ashwin Naren
f354fa7eaf implement rename_from 2026-02-26 23:14:31 -08:00
Ashwin Naren
1d5fb030b4 support directory creation 2026-02-26 23:14:31 -08:00
Ashwin Naren
c77ea09264 support file writing beyond block boundaries 2026-02-26 23:14:31 -08:00
Ashwin Naren
d21c449b5c support file creation 2026-02-26 23:14:31 -08:00
Ashwin Naren
28e3f4ab02 support linking and unlinking 2026-02-26 23:14:31 -08:00
Ashwin Naren
b28d2baa7f bump dependencies and use workspace dependencies when possible 2026-02-26 23:14:31 -08:00
Matthew Leach
91cde85422 libkernel: smalloc: fix Miri errors
Miri is failing the smalloc tests due to poorly written tests, mainly
due to the fact that raw pointers were derived from mutable refs.  Fixup
the tests to use the global allocator funcitons directly.
2026-02-23 05:34:03 +00:00
Matthew Leach
39a5ef331d libkernel/slab: fix UB and accounting bugs identified by Miri
Fix several issues in the slab allocator identified by the heap stress
tests (intermittent) and running the tests under Miri.

1. Fix Undefined Behavior. Previously, the allocator created temporary
   `&mut Frame` references while raw pointers to that frame existed in the
   intrusive `partial` or `free` lists. Under Miri's strict aliasing rules,
   creating a unique reference to the whole struct invalidated the list
   pointers.

   The fix implements "split borrowing": we now maintain raw pointers to
   the frame and only create mutable references to the `.state` field
   when needed, ensuring the `.link` field remains valid for the
   intrusive list.

2. Fix `free_list_sz` accounting. In `try_alloc`, the `free_list_sz`
   counter was not being decremented when a slab was successfully popped
   from the free list. This caused the allocator to believe it had free
   slabs when the list was actually empty, leading to panics during
   batch-free operations.

3. Increase heap stress tests. The test suite now runs the stress test
   in a loop to catch state persistence bugs and ensures the allocator is
   fully torn down and reset between iterations.

Fixes: #220
2026-02-21 14:38:18 -08:00
Ashwin Naren
37def9264e implement copy_file_range 2026-02-19 12:51:20 -08:00
Ashwin Naren
600f228d69 address review 2026-02-19 12:51:11 -08:00
Ashwin Naren
2fa3b490d3 implement rwlock 2026-02-19 12:51:11 -08:00
Matthew Leach
ba0ff25b20 Merge pull request #203 from arihant2math/statfs
Implement `sys_statfs` and `sys_fstatfs`
2026-02-15 20:05:13 +00:00
Matthew Leach
d85fe47374 Merge pull request #209 from arihant2math/update-ext4
Update ext4-view fork
2026-02-15 19:52:07 +00:00
Ashwin Naren
6aebef2168 enable clippy lints for libkernel 2026-02-13 10:24:13 -08:00
Ashwin Naren
901a2b3303 update ext4-view fork 2026-02-12 14:18:39 -08:00
Matthew Leach
141fbf8a1b Merge pull request #202 from hexagonal-sun/slab-alloc-stress-test 2026-02-10 07:21:18 +00:00
Ashwin Naren
f1c0cba3b8 statfs 2026-02-09 16:59:15 -08:00
Ashwin Naren
2855ef7a51 Merge pull request #201 from arihant2math/hostname
Store hostname and allow for updates via `sys_sethostname`
2026-02-09 16:48:10 -08:00
Ashwin Naren
8281ea798f Merge pull request #197 from arihant2math/sysfs 2026-02-09 13:59:28 -08:00
Matthew Leach
9f21618058 libkernel: memory: slab: heap: new
Add a new module which implements the high-level heap logic (implements
`GlobalAlloc`) for the slab allocator.

Also implement a multi-threaded stress test of the heap ensuring
concurrent allocation is unique (doesn't corrupt other allocs) and all
memory is free'd back to the `FrameAllocator` when all caches are
purged.
2026-02-09 07:00:13 +00:00
Ashwin Naren
ef10631dc4 Merge pull request #195 from hexagonal-sun/slab-allocator
slab allocator
2026-02-08 16:51:29 -08:00
Ashwin Naren
c07dd2140c implement hostname properly 2026-02-08 00:39:55 -08:00
Ashwin Naren
479926f767 stub cgroup fs 2026-02-07 18:25:30 -08:00
Ashwin Naren
4c69c969e2 report and edit nlinks 2026-02-07 16:37:41 -08:00
Matthew Leach
424d6b126e libkernel: memory: slab: cache: new
Add a new per-cpu slab cache for caching slab allocations on a given
CPU.
2026-02-07 08:26:35 +00:00
Matthew Leach
1bdaaef14a libkernel: memory: slab: allocator: new
Add a new slab allocator implementation. The `SlabAllocator` manages
lists of slabs for each size class.
2026-02-07 08:26:35 +00:00
Matthew Leach
a2f636cebb libkernel: memory: slab: slab: new
Add a new module for managing objects within a slab. The `Slab` struct
manages objects of a given set within a contiguous set of pages. It is
the handle to the underlying memory, allowing for objects to be
allocated, and free'd. It manages a free list of 'indexes' within the
object slots themselves.
2026-02-07 08:26:35 +00:00
Matthew Leach
c0ecac05f3 libkernel: memory: PageAllocGetter: return ref to allocator
Rather than returning a reference to the `OnceCell` wrapping the
allocator, return a static reference to the allocator itself. This
allows flexibility for how the allocator is wrapped.
2026-02-07 08:26:35 +00:00
Matthew Leach
1b8ef1bc88 libkernel: memory: allocs: move FrameList impl into frame
Move the FrameList logic out of the physical memory allocator into its
own module. This allows `FrameList` to be shared between the physical
memory allocator and the slab allocator.
2026-02-07 08:26:35 +00:00
Matthew Leach
972f023edc libkernel: memory: reorganise allocators
Create a new submodule within `memory`, `allocators` which contains all
memory allocators. Also split out the `Frame` struct from the `pg_alloc`
module, allowing it to be used by other modules.
2026-02-07 08:26:35 +00:00
Ashwin Naren
c394e18231 tmp 2026-02-07 00:20:37 -08:00
Matthew Leach
8a84ba0fb9 libkernel: arm64: pg_tables; pg_tear_down: new
Add a new module which walks the page table hierarchy for a given
address space and applies a freeing closure to every allocated frame.
2026-01-30 19:39:59 -08:00
Matthew Leach
c49396ed35 libkernel: arm64: pg_tables: get_idx: new
Add a function which returns a descriptor from a page table by it's
numerical index.
2026-01-30 19:39:59 -08:00