Tulio A M Mendes [Tue, 10 Feb 2026 04:12:07 +0000 (01:12 -0300)]
fix: implement real irq_save/irq_restore for ARM, RISC-V, MIPS
spinlock.h had no-op irq_save/irq_restore for non-x86 architectures,
meaning spin_lock_irqsave would not actually disable interrupts on
ARM, RISC-V, or MIPS — breaking all critical sections.
Add proper implementations:
- ARM: mrs/msr CPSR with cpsid i
- RISC-V: csrrci/csrsi mstatus MIE bit
- MIPS: mfc0/di/ei on CP0 Status IE bit
Tulio A M Mendes [Tue, 10 Feb 2026 04:09:56 +0000 (01:09 -0300)]
fix: replace hardcoded 0xC0000000 in pmm.c with hal_mm_kernel_virt_base()
pmm.c used raw 0xC0000000 to detect higher-half kernel and adjust
physical addresses. Replace with hal_mm_kernel_virt_base() so the
PMM works correctly on architectures with different kernel virtual
base addresses.
Tulio A M Mendes [Tue, 10 Feb 2026 04:08:02 +0000 (01:08 -0300)]
fix: replace hardcoded 0xC0000000 in syscall.c with hal_mm_kernel_virt_base()
sys_brk and mmap used hardcoded 0xC0000000U (x86 kernel virtual
base) for bounds checking. Replace with hal_mm_kernel_virt_base()
so the code is architecture-independent.
Tulio A M Mendes [Tue, 10 Feb 2026 04:05:52 +0000 (01:05 -0300)]
fix: wrap pci.c in #if x86 guard with stubs for other architectures
PCI config space I/O port access (0xCF8/0xCFC) using outl/inl is
x86-only. The driver had no architecture guard, so it would fail
to compile on ARM, RISC-V, and MIPS.
Wrap the full implementation in #if defined(__i386__) and provide
no-op stubs for non-x86 targets.
Tulio A M Mendes [Tue, 10 Feb 2026 04:04:05 +0000 (01:04 -0300)]
fix: replace hardcoded 0xC0000000 in slab.c with hal_mm_phys_to_virt()
slab.c used 'base + 0xC0000000U' to convert physical to virtual
addresses, which is x86 higher-half specific. This breaks on ARM,
RISC-V, and MIPS where the kernel virtual base differs.
Add hal_mm_phys_to_virt(), hal_mm_virt_to_phys(), and
hal_mm_kernel_virt_base() to the HAL mm interface with proper
implementations for x86 (0xC0000000 offset) and identity-mapped
stubs for ARM, RISC-V, MIPS.
Tulio A M Mendes [Tue, 10 Feb 2026 04:01:02 +0000 (01:01 -0300)]
fix: move VBE framebuffer VA from 0xD0000000 to 0xE0000000
The kernel heap starts at KHEAP_START=0xD0000000 and spans 10MB.
The VBE framebuffer was also mapped at 0xD0000000, causing a
virtual address collision that would corrupt the heap when a
framebuffer is present.
Move VBE mapping to 0xE0000000 which is safely above the heap.
Tulio A M Mendes [Tue, 10 Feb 2026 03:59:11 +0000 (00:59 -0300)]
fix: add rq_enqueue on wake in keyboard, tty, pty drivers
keyboard.c, tty.c, pty.c all transition processes from BLOCKED to
READY without enqueuing them into the O(1) scheduler runqueue.
This causes woken processes to be invisible to rq_pick_next(),
leading to starvation until the active/expired swap rescues them.
Add sched_enqueue_ready() public API in scheduler.c and call it
from all three wake sites.
Passes: make, cppcheck, QEMU smoke test (10s, all init tests OK).
x86: add sigreturn trampoline and fix execve stack usage
Implement SYSCALL_SIGRETURN and userland signal trampoline/sigframe so handlers can return safely.
Fix x86 signal delivery stack layout to avoid clobbering sigframe/trampoline.
Fix execve heap corruption by avoiding large on-stack argv/envp buffers and adding cleanup.
Add init.elf smoke test for sigreturn.
Add a minimal select() syscall implemented as a wrapper over poll(). Uses uint64_t read/write fd masks (nfds<=64), timeout semantics aligned with poll, and a userland smoke test with a pipe.
Handle ISR14 page faults from ring3 by terminating the current process with a SIGSEGV-like status (128+11) instead of kernel panic. Add userland smoke test that triggers a NULL write and validates waitpid status.
Introduce a minimal kill(pid,sig) syscall with SIGKILL support. Implement process_kill() to mark target as zombie, close its FDs with refcounting, and wake a waiting parent. Add ESRCH and a userland init.elf smoke test.
Replace remaining -1 style returns in core helpers used by syscalls and early init with negative errno codes (vfs_mount, tmpfs_add_file/mkdir_p, initrd alloc/path helpers). Add missing errno constants (EEXIST/ENOTDIR/ENOSPC).
Return proper -errno from remaining syscall helpers (pipe/fd allocation) and harden copy_to_user to require writable user mappings on x86. copy_{to,from}_user now return -EFAULT on invalid ranges.
Add a minimal devfs mounted at /dev providing /dev/null and /dev/tty char devices. Implement tty_read_kbuf/tty_write_kbuf to support VFS-backed tty IO and allow open/read/write through FS_CHARDEVICE nodes. Add userland smoke tests.
Adopt negative errno return convention across waitpid/open/fd_close and TTY read/write, add missing errno constants, and return ENOSYS for unknown syscalls.
Fix vmm_as_clone_user to use a heap-allocated 4KB temp buffer instead of a 4KB stack array (kernel stacks are 4KB). Harden heap free/coalesce logic and diagnostics to better catch corruption/double-free.
Copy argv/envp from user memory and build a minimal initial user stack in the new address space during execve(). Improve errno reporting (EFAULT/ENOENT/ENOMEM/EINVAL).
Implement fork() by cloning user address space and resuming child in ring3 from a saved register frame. Duplicate FD table via refcounting. Remove temporary spawn syscall and update init.elf waitpid test to use fork().
Add refcounted dup/dup2, pipe() ring buffer, and execve() to replace the current process image. Include userland wrappers, smoke tests, and a second user binary (echo.elf) packaged into initrd.