feat: exhaustive STUB instrumentation - 241 panic sites across VMM/kernel + whitelist alignment

- VMM cluster: XJ3-E/LIN-E/VMM-E/VMX-E/EPT-E/IPC-E/VVB-E (124 sites)

- kernel cluster: TST-E/MM-E/UTRW-E/LAPIC-E/IDT-E/SAS-E/PRB-E/NETST-E/DKM-E (117 sites)

- whitelist fixes: vmm_init env probes E10-E14 fallback, disk_log read-only block path, DSL-E05 non-FAT32 device 0 probe

- QEMU smoke: wizard -> USER.CONF -> login -> desktop ready, zero spurious panic
This commit is contained in:
Linehu
2026-10-03 21:26:04 +08:00
parent 506d1b18c6
commit 174af71b39
62 changed files with 667 additions and 36 deletions
+7
View File
@@ -1,6 +1,7 @@
#include <utsm/dma.h>
#include <utsm/log.h>
#include <utsm/types.h>
#include <utsm/panic.h>
#include "../arch/x86_64/limine.h"
#define PAGE_SIZE 4096ULL
@@ -54,6 +55,8 @@ void dma_init(void) {
}
if (!g_hhdm_offset || !g_memmap_request.response) {
log_warn("[DMA] missing HHDM or memmap response");
panic_full("MM-E20 MISSING HHDM OR MEMMAP",
"dma_init: HHDM or memmap response missing", 0);
return;
}
@@ -84,6 +87,8 @@ void dma_init(void) {
if (g_free_pages == 0) {
log_warn("[DMA] no usable low pages found");
panic_full("MM-E21 NO USABLE LOW PAGES",
"dma_init: no usable low-4G pages in memmap", 0);
return;
}
@@ -133,6 +138,8 @@ int dma_alloc_pages(u64 page_count, u64 alignment, u64 max_phys, dkm_dma_buffer
log_warn("[DMA] alloc failed");
log_hex64("[DMA] req pages=", page_count);
log_hex64("[DMA] free pages=", g_free_pages);
panic_full("MM-E22 DMA ALLOC FAILED",
"dma_alloc_pages: no free pages satisfying request", 0);
return -2;
}
+7
View File
@@ -0,0 +1,7 @@
mm/dma.o: mm\dma.c include\utsm\dma.h include\utsm\types.h \
include\utsm\log.h include\utsm\panic.h mm\..\arch\x86_64\limine.h
include\utsm\dma.h:
include\utsm\types.h:
include\utsm\log.h:
include\utsm\panic.h:
mm\..\arch\x86_64\limine.h:
Binary file not shown.
+19
View File
@@ -2,6 +2,7 @@
#include <utsm/dma.h>
#include <utsm/log.h>
#include <utsm/types.h>
#include <utsm/panic.h>
#include "../arch/x86_64/limine.h"
#define MM_PAGE_SIZE 4096ULL
@@ -79,11 +80,15 @@ static void mm_lazy_init(void) {
g_max_phys_addr_bits = 0;
if (!g_hhdm_request.response) {
log_warn("[MM] missing HHDM response");
panic_full("MM-E10 MISSING HHDM RESPONSE",
"mm_lazy_init: Limine HHDM response missing", 0);
return;
}
g_hhdm = g_hhdm_request.response->offset;
if (!g_hhdm) {
log_warn("[MM] null HHDM offset");
panic_full("MM-E11 NULL HHDM OFFSET",
"mm_lazy_init: HHDM offset is zero", 0);
return;
}
@@ -95,6 +100,8 @@ static void mm_lazy_init(void) {
log_error("[MM] LA57 5-level paging ACTIVE — REFUSING to proceed");
log_error("[MM] This kernel requires 4-level paging (48-bit virtual)");
log_error("[MM] Disable LA57 in BIOS/firmware settings");
panic_full("MM-E12 LA57 ACTIVE REFUSE",
"mm_lazy_init: 5-level paging active; 4-level walk required", 0);
return;
}
@@ -113,6 +120,8 @@ static void mm_lazy_init(void) {
log_hex64("[MM] CPU MaxPhysAddr bits=", g_max_phys_addr_bits);
if (g_max_phys_addr_bits > 52) {
log_error("[MM] physical address width > 52 bits — PTE cannot represent");
panic_full("MM-E13 PHYS ADDR WIDTH EXCEEDED",
"mm_lazy_init: physical address width exceeds 52 bits", 0);
return;
}
} else {
@@ -126,6 +135,8 @@ static void mm_lazy_init(void) {
g_window_base = mm_find_window();
if (!g_window_base) {
log_error("[MM] no free PML4 slot for mmio window");
panic_full("MM-E14 NO FREE PML4 SLOT",
"mm_lazy_init: no free PML4 slot for mmio window", 0);
return;
}
g_window_end = g_window_base + MM_WINDOW_SIZE;
@@ -153,6 +164,8 @@ static u64 *mm_walk_create(u64 virt) {
dkm_dma_buffer buf;
if (dma_alloc_pages(1, MM_PAGE_SIZE, 0, &buf) != 0) {
log_warn("[MM] page table alloc failed");
panic_full("MM-E15 PAGE TABLE ALLOC FAILED",
"mm_walk_create: page table page alloc failed", 0);
return 0;
}
table[idx] = buf.phys | PTE_PRESENT | PTE_RW;
@@ -185,6 +198,8 @@ void *mm_map_mmio(u64 phys, u64 size) {
log_error("[MM] phys address exceeds CPU MaxPhysAddr");
log_hex64("[MM] phys=", phys);
log_hex64("[MM] max_phys=", max_phys);
panic_full("MM-E16 PHYS EXCEEDS MAXADDR",
"mm_map_mmio: physical address exceeds CPU MaxPhysAddr", 0);
return 0;
}
}
@@ -197,6 +212,8 @@ void *mm_map_mmio(u64 phys, u64 size) {
u64 vbase = g_window_next;
if (vbase < g_window_base || vbase + total > g_window_end) {
log_error("[MM] mmio window exhausted");
panic_full("MM-E17 MMIO WINDOW EXHAUSTED",
"mm_map_mmio: MMIO virtual window exhausted", 0);
return 0;
}
@@ -207,6 +224,8 @@ void *mm_map_mmio(u64 phys, u64 size) {
if (!pte || (*pte & PTE_PRESENT)) {
/* 冲突/失败:回滚本次已建立的映射 */
log_error("[MM] map conflict");
panic_full("MM-E18 MAP CONFLICT",
"mm_map_mmio: page table walk conflict or failure", 0);
for (u64 j = 0; j < mapped; j++) {
u64 v = vbase + j * MM_PAGE_SIZE;
u64 *p = mm_walk_query(v);
+9
View File
@@ -0,0 +1,9 @@
mm/mmio.o: mm\mmio.c include\utsm\mm.h include\utsm\types.h \
include\utsm\dma.h include\utsm\log.h include\utsm\panic.h \
mm\..\arch\x86_64\limine.h
include\utsm\mm.h:
include\utsm\types.h:
include\utsm\dma.h:
include\utsm\log.h:
include\utsm\panic.h:
mm\..\arch\x86_64\limine.h:
+19 -3
View File
@@ -15,6 +15,7 @@
#include <utsm/paging.h>
#include <utsm/dma.h>
#include <utsm/log.h>
#include <utsm/panic.h>
#include "../arch/x86_64/limine.h"
extern volatile struct limine_hhdm_request g_hhdm_request;
@@ -90,7 +91,12 @@ static int paging_map_mmio_impl(u64 phys, u64 size) {
u64 idx4 = (v >> 39) & 0x1FF;
if (!(pml4[idx4] & PTE_PRESENT)) {
u64 t = paging_alloc_table();
if (!t) { log_error("[PAGING] alloc PDPT failed"); return -2; }
if (!t) {
log_error("[PAGING] alloc PDPT failed");
panic_full("MM-E01 PDPT ALLOC FAILED",
"paging_map_mmio: PDPT page alloc failed", 0);
return -2;
}
pml4[idx4] = t | PTE_PRESENT | PTE_RW;
}
@@ -100,7 +106,12 @@ static int paging_map_mmio_impl(u64 phys, u64 size) {
if (pdpt[idx3] & PTE_PS) { skipped++; continue; } /* 1G 大页已覆盖 */
} else {
u64 t = paging_alloc_table();
if (!t) { log_error("[PAGING] alloc PD failed"); return -3; }
if (!t) {
log_error("[PAGING] alloc PD failed");
panic_full("MM-E02 PD ALLOC FAILED",
"paging_map_mmio: PD page alloc failed", 0);
return -3;
}
pdpt[idx3] = t | PTE_PRESENT | PTE_RW;
}
@@ -110,7 +121,12 @@ static int paging_map_mmio_impl(u64 phys, u64 size) {
if (pd[idx2] & PTE_PS) { skipped++; continue; } /* 2M 大页已覆盖 */
} else {
u64 t = paging_alloc_table();
if (!t) { log_error("[PAGING] alloc PT failed"); return -4; }
if (!t) {
log_error("[PAGING] alloc PT failed");
panic_full("MM-E03 PT ALLOC FAILED",
"paging_map_mmio: PT page alloc failed", 0);
return -4;
}
pd[idx2] = t | PTE_PRESENT | PTE_RW;
}
+9
View File
@@ -0,0 +1,9 @@
mm/paging.o: mm\paging.c include\utsm\paging.h include\utsm\types.h \
include\utsm\dma.h include\utsm\log.h include\utsm\panic.h \
mm\..\arch\x86_64\limine.h
include\utsm\paging.h:
include\utsm\types.h:
include\utsm\dma.h:
include\utsm\log.h:
include\utsm\panic.h:
mm\..\arch\x86_64\limine.h: