Commit Graph

31 Commits

Author SHA1 Message Date
8d2c40cb1e feat(kernel): kernel-owned memory model
- FrameTable: per-frame owner/use, replaces PagePool + ProcessMemory
- Quota per process, page tables charged to owner
- Regions for shared mem + device MMIO, torn down w/ owner
- Platform: create/destroy AS, map/unmap, zero_frame; drop translate_va
- RequestPages/ReleasePages/MapPage(move) checked vs kernel records
- user window 0x1000..32MiB, private pts by construction
- boot loader + device setup go through kernel api
- kernel built in place, boot allocator bounded
- isolation tests, randomized invariant test, FrameTable kani proofs
- fixes: inflated release, unmapped release, dst va unchecked,
  heap overflow, unbounded pt alloc, unzeroed frames, double free
2026-10-26 19:40:50 +01:00
e931485ca7 fix: sched round-robin, cap slot OOB panic, clippy, make ci
- RunList -> intrusive FIFO, no starvation, no silent drop
- cap table sized to CapSlot range (kani caught OOB panic)
- snake food color test uses const
- kani cfg lint, RUST_MIN_STACK for big kernel struct in tests
2026-10-26 19:08:30 +01:00
1c04ddf909 style: cargo fmt kernel crates 2026-10-26 19:07:54 +01:00
cbabe2abfe cleanup: replace magic 1024 page limit with ProcessMemory::DEFAULT_PAGE_LIMIT 2026-10-18 22:43:18 +02:00
d009818caf fix: kernel hardening pass 2 — page tracking, queue overflow, region tracking
Page lifecycle:
- ProcessMemory now tracks (PhysicalAddress, count) pairs for each
  allocation (up to 16). destroy_process iterates and frees all
  pages back to the pool. No more permanent page leaks on exit/fault.
- RequestPages re-adds MemoryRegion entries so ReleasePages works.
  Release test un-ignored, passes.
- RequestPages: VA allocation moved after pool allocation succeeds,
  preventing VA leak on OOM.

IPC hardening:
- WaitQueue overflow (>16 waiters): returns WouldBlock error instead
  of silently dropping the thread. Thread is not blocked if enqueue
  fails.
- debug_assert on pending_messages[sender].take() — invariant that
  a sender in wait queue must have a pending message.

Scheduler:
- remove() now clears current thread if the removed thread was
  current on its core.
- add() asserts push succeeded; bitmap bit only set if thread was
  actually added to RunList.

Cleanup:
- Priority::DEFAULT replaces Priority::new(16).unwrap() in
  spawn_thread and spawn_thread_in.

36 kernel tests pass, 0 ignored.
2026-10-18 22:31:16 +02:00
38f20cc3c4 feat: proper IPC-based boot — init loads servers from storage via IPC, VirtIO GPU driver
Complete microkernel boot pipeline: adapter loads only init + storage + display
from disk. Init bootstraps all other servers by reading binaries from the
storage server via IPC, parsing ELF, creating processes, mapping pages, and
spawning threads.

New syscalls:
- CreateEndpoint: userspace endpoint creation with full capability grant
- DebugPutchar: debug output to UART from userspace
- MapPage: cross-process page mapping (init loads binaries into children)
- SpawnThreadIn: spawn thread in another process via capability

Key fixes:
- Per-process L1 page tables for VPN[2]=0 (prevents cross-process corruption)
- Separate kernel_pt from page_tables[0] (init pid=0 overwrote kernel PT ref)
- Thread Running state set in switch_to_next (syscalls rejected without it)
- Pending IPC results applied during context switch
- SIE disabled during boot (timer can't preempt into unready processes)
- User heap VA starts at 0x40000 (avoids shared buffer at 0x30000)
- RequestPages maps at user VAs via per-process heap allocator

VirtIO GPU:
- Adapter probes for GPU device, initializes resource/scanout/backing
- Display server writes to mapped framebuffer, flushes via GPU virtqueue
- 640x480 BGRA framebuffer with transfer-to-host and resource-flush

Storage server:
- Userspace VirtIO block driver using pre-mapped MMIO and DMA pages
- FAT16 filesystem reader serving file-read requests via IPC
- Shared buffer protocol: init writes filename, storage writes file data

Echo app for IPC testing (adapter-loaded echo proved the pipeline end-to-end).
2026-10-18 13:02:30 +02:00
b7bc223a79 feat: add Halt syscall, fault notification to fault handler, supervisor with back-off, shutdown with timeout
- Halt syscall: only pid 0 (init) can halt, adapter uses SBI SRST
- Fault notification: kernel delivers fault info to process fault handler endpoint before killing
- Supervisor: tracks restart counts, back-off up to 5 restarts
- Shutdown: notifies servers, waits with timeout, calls halt
- Trap handler: faults now call kernel.handle_fault instead of halting
2026-10-18 03:29:05 +02:00
7724a5bd0a feat: implement context switching, SavedContext with pc/status fields, wire all syscall outcomes and timer preemption 2026-10-18 02:34:36 +02:00
142505d8a4 feat: add SavedContext::with_entry_and_stack, wire SpawnThread to preserve entry point and stack 2026-10-18 01:24:56 +02:00
4833f2e2bb feat(kernel): add Revoke syscall for generation-based capability revocation 2026-10-18 01:23:24 +02:00
192631d506 feat(kernel): implement generation-based capability revocation with proofs and tests 2026-10-18 01:11:24 +02:00
71518a93a4 refactor(proofs): split into per-topic modules with shared helpers across types, domain, and kernel 2026-10-18 01:08:05 +02:00
1278373142 fix: fix mut binding and unused import warnings in Kani proofs 2026-10-18 00:57:33 +02:00
acc59830ff feat: add Kani proofs for delegation non-escalation across types, domain, and kernel 2026-10-18 00:55:52 +02:00
b8c5090fe5 fix(kernel): fix kill wait-queue cleanup, RegionId tracking, ReleasePages ownership, and SwitchTo scheduler state 2026-10-18 00:31:05 +02:00
8912a944b8 feat(kernel): add WaitForInterrupt, AcknowledgeInterrupt, and WaitAny syscalls 2026-10-18 00:26:11 +02:00
07534e52d9 feat(kernel): add SpawnThread, CreateProcess, and Kill syscalls 2026-10-18 00:21:01 +02:00
d0a0ba788f feat(kernel): add Kernel struct, MockPlatform, and simple syscalls (GetTime, GetProcessId, Yield) 2026-10-18 00:15:40 +02:00
8dd36e7d6d refactor(domain): move irq tests to separate file, fix MemoryRegion import in platform 2026-10-17 23:54:16 +02:00
328708ed58 feat(domain): add EndpointTable, IrqRoutingTable, and remaining error variants 2026-10-17 23:51:56 +02:00
ed80fc43a6 feat(domain): add memory module with page pool, per-process tracking, and region table 2026-10-17 23:45:17 +02:00
021b2d83b9 fix(domain): remove all unwrap() from production code in scheduler 2026-10-17 23:40:03 +02:00
c590810fe3 feat(domain): add Message constructor, accessors, and builder 2026-10-17 23:36:44 +02:00
0296776e45 chore: remove old flat process.rs and thread.rs replaced by directories 2026-10-17 23:34:54 +02:00
edb924c27a feat(domain): add MultiCoreScheduler with placement tracking, priority preemption, and load balancing 2026-10-17 23:31:22 +02:00
14b18f7406 feat(domain): add ThreadTable with spawn, get, destroy, and process filtering 2026-10-17 23:29:46 +02:00
6444de69b8 feat(domain): add Thread constructor, accessors, and state machine transitions 2026-10-17 23:28:56 +02:00
42ed5ade29 feat(domain): add ProcessTable with create, get, and destroy 2026-10-17 23:27:28 +02:00
fe0fde7de1 feat(domain): add Process constructor, accessors, and thread slot management 2026-10-17 23:26:14 +02:00
06b51b6712 Implement domain and endpoint modules with capability management, message passing, and scheduling features 2026-10-17 23:09:21 +02:00
bb99c3001d init 2026-10-16 02:32:24 +02:00