Skip to content

GatOS Kernel v2.1.0 (Critical Fixes & Maintenance)

Latest

Choose a tag to compare

@ApparentlyPlus ApparentlyPlus released this 21 Jul 14:11

The GatOS Kernel has been updated from v2.0.0 to v2.1.0, following the merge of branch QOL.

This version is a stability, performance, and polish release that touches nearly every subsystem: 99 files changed, ~9,100 insertions and ~5,000 deletions. It fixes several long-standing memory corruption bugs, restores full FPU/SSE code generation across the kernel, and roughly doubles the written documentation.

  • Restored full floating point and SSE code generation across the kernel. Instead of building the entire kernel with -mno-sse -mno-sse2 -mno-mmx -mno-80387, the build system now maintains an explicit KERNEL_INTERRUPT_PATH set (interrupt dispatcher, scheduler, timers, keyboard/xHCI IRQ handlers, and the demand-paging path through vmm.c, pmm.c and avl.c) and restricts SSE emission only for those files. Every other translation unit, including drivers, klibc and kernel threads, compiles with full vector support, with the lazy FPU mechanism handling state save and restore.
  • Fixed a catastrophic firmware memory corruption bug in kernel_main. Non-MULTIBOOT_MEMORY_AVAILABLE regions were registered as MMIO but then fell through into pmm_populate, handing reserved firmware, ACPI, and MMIO ranges to the physical allocator as free memory. A missing continue was silently arming the kernel to overwrite firmware structures at runtime.
  • Rebuilt the PMM around a cleaner buddy allocator with a first-class exclusion table. pmm_exclude_range() registers up to eight physical ranges that must never be handed out, pmm_init derives its order count from the managed range, and population is now firmware-robust across machines with unusual E820/multiboot maps.
  • Implemented USB hotplug. The xHCI driver now runs a dedicated hotplug process and thread that polls hub status-change endpoints, handles C_PORT_CONNECTION and C_PORT_RESET events, clears port features over the control pipe, enumerates newly attached devices, and tears down downstream slots with Disable Slot on disconnect. Devices can now be plugged and unplugged at runtime instead of only at boot enumeration.
  • Added a full power management subsystem (power.c / power.h). power_off() walks the FADT to the DSDT, parses the _S5_ package for the SLP_TYPa/b values, enables ACPI mode via SMI_CMD, and writes PM1a/PM1b_CNT. reboot() cascades through the 0xCF9 reset register, the ACPI FADT reset register, the PS/2 controller, and finally a triple fault. Intel RAPL energy sampling was added on top, exposing live average package wattage through power_avg_watts().
  • Massively improved klibc and ulibc performance. kmemset, kmemcpy, kmemmove, and their userspace twins now align to an 8-byte boundary, run a 64-bit word loop over the bulk of the buffer, and fall back to bytewise copies only for the head and tail, replacing the original one-byte-at-a-time loops used by every subsystem in the kernel.
  • Added long and long long parsing support to scanf/vscanf in both klibc and ulibc. The l and ll length modifiers are now honored for %d, %i, %o, %u, and %x, routing through kstrtol/kstrtoul with correct destination widths instead of truncating everything to int.
  • Implemented dirty-cell tracking and batched rendering in the console. Each console carries a bitmap of dirty character cells; flush_display now redraws only the cells that actually changed since the last flush, and a deferred-render toggle lets callers batch many writes into a single screen update. Glyph and fill blitting gained a fully unrolled 32bpp fast path that writes eight pixels per glyph row directly into the framebuffer.
  • Reworked the syscall ABI and dispatcher. syscall_dispatcher now receives a single cpu_context_t* built on the per-thread kernel stack rather than a raw register array indexed by magic offsets, making argument and return-value handling explicit. MSR_STAR now programs the user base as 0x13 so SYSRETQ produces CS=0x23/SS=0x1B without relying on the CPU forcing SS.RPL=3, a behavior some Intel microarchitectures get wrong. User buffer validation now runs with interrupts disabled so the buffer cannot be swapped between the vmm_check_buffer and the copy, and SYS_MMAP masks user-supplied flags down to VM_FLAG_WRITE | VM_FLAG_EXEC | VM_FLAG_LAZY.
  • Rewrote the Kernel Dashboard renderer as a layout engine. Sections, key/value column grids, standalone and paired progress bars, and unified column alignment are now computed from a layout_t derived from console dimensions, instead of hardcoded positioning. The CPU section gained live package power draw from RAPL, and the whole dashboard renders through the deferred-render path so a refresh is a single batched flush.
  • Added a MONITOR/MWAIT idle thread to the scheduler, with an automatic hlt fallback when the CPU does not advertise MONITOR/MWAIT. Idle and total tick accounting is exposed through sched_cpu_usage(), giving the dashboard real CPU utilization instead of an estimate.
  • Added LAPIC TSC-Deadline timer support. lapic_tsc_arm() programs the LVT timer in TSC-Deadline mode and writes IA32_TSC_DEADLINE directly, replacing periodic-count rearming on hardware that supports it, with lapic_timer_stop() disarming both modes.
  • Fixed a TTY teardown leak where threads parked in a TTY's wait queue were left dangling on destroy. tty_destroy now flushes the entire wait queue into the dead queue, and active_tty was made volatile to stop the compiler from caching a stale focus pointer across interrupt-driven focus changes.
  • Fixed process creation to allocate fresh physical pages for the userspace BSS and explicitly zero them, rather than reusing whatever the allocator handed back, eliminating a class of nondeterministic userspace startup failures.
  • Corrected reserve_required_tablespace parameter passing and added an assertion that required page-table space never exceeds available memory, catching a bad-argument bug that could under-reserve table space on large-memory machines.
  • Enabled link-time optimization and stripping in the build pipeline. Kernel objects compile with -flto and link through gcc (so the LTO plugin is actually loaded) with --gc-sections, followed by x86_64-elf-strip; userspace objects build with -ffast-math. The test profile now inherits the fast optimization flags instead of building unoptimized.
  • Restored 16-byte stack alignment in generic_interrupt_handler before calling into interrupt_dispatcher, and reworked interrupt-context zeroing to avoid emitting SSE instructions that would clobber the interrupted thread's XMM state.
  • Extended CPU feature detection to cover SSE3/SSSE3/SSE4.1/SSE4.2, AVX, VMX, SVM, PAE, and the full CPUID brand string, with cpu_enable_feature wiring up SSE, AVX, SMEP and SMAP at boot and the dashboard reporting each one.
  • Added two new documentation chapters, namely C6 (Interrupts, Panics, and Spinlocks) and C7 (PMM and Slab Allocators), ~2,450 lines combined. I also substantially rewrote C0 through C5.
  • Sweeping readability and consistency work across the tree: heap.c shed roughly 400 lines through shortened type names (heap_block_header_t -> blk_hdr_t) and de-duplicated statistics helpers, vmm.c, slab.c, process.c, scheduler.c, gdt.c, apic.c and acpi.c were restructured, every test file was tidied, and comments and authorship headers were made consistent throughout.