From: Tulio A M Mendes Date: Fri, 6 Feb 2026 11:42:02 +0000 (-0300) Subject: sched: make early allocations safe under higher-half/identity constraints X-Git-Url: https://projects.tadryanom.me/sitemap.xml?a=commitdiff_plain;h=117ff8be06504981c4ce752ec8d406ac90aad864;p=AdrOS.git sched: make early allocations safe under higher-half/identity constraints --- diff --git a/src/kernel/scheduler.c b/src/kernel/scheduler.c index d2ac8cd..106700e 100644 --- a/src/kernel/scheduler.c +++ b/src/kernel/scheduler.c @@ -20,7 +20,8 @@ static void* pmm_alloc_page_low(void) { for (int tries = 0; tries < 1024; tries++) { void* p = pmm_alloc_page(); if (!p) return 0; - if ((uint32_t)p < 0x00400000) { + // boot.S currently identity-maps a large low window; keep allocations within it. + if ((uint32_t)p < 0x20000000) { return p; } // Not safe to touch yet; put it back. @@ -36,6 +37,11 @@ void process_init(void) { // Initial Kernel Thread (PID 0) - IDLE TASK struct process* kernel_proc = (struct process*)pmm_alloc_page_low(); + if (!kernel_proc) { + spin_unlock_irqrestore(&sched_lock, flags); + uart_print("[SCHED] OOM allocating kernel process struct.\n"); + for(;;) hal_cpu_idle(); + } kernel_proc->pid = 0; kernel_proc->state = PROCESS_RUNNING;