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:
@@ -6,6 +6,7 @@
|
||||
#include <utsm/pe.h>
|
||||
#include <utsm/linux_compat.h>
|
||||
#include <utsm/instr.h>
|
||||
#include <utsm/panic.h>
|
||||
#include "../arch/x86_64/limine.h"
|
||||
#include "../../tools/fat32_lfn.h"
|
||||
|
||||
@@ -215,6 +216,8 @@ static u32 fat32_get_next_cluster(u32 fat_start_byte, u32 clus,
|
||||
log_error("[UTSM] FAT32: on-demand FAT sector read failed");
|
||||
log_hex64("[UTSM] FAT32: fat_sec_lba=", fat_sec_lba);
|
||||
log_hex64("[UTSM] FAT32: clus=", clus);
|
||||
panic_full("DSL-E01 FAT SECTOR READ FAILED",
|
||||
"fat32_get_next_cluster: on-demand FAT sector read failed", 0);
|
||||
return 0x0FFFFFFF;
|
||||
}
|
||||
return fat32_read_u32(g_dsk_fat32_fat_sec + ent_off_in_sec) & 0x0FFFFFFF;
|
||||
@@ -223,11 +226,14 @@ static u32 fat32_get_next_cluster(u32 fat_start_byte, u32 clus,
|
||||
static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
const dkm_kernel_api *api = dkm_get_kernel_api();
|
||||
if (!api || !api->block || !api->block->device_count) {
|
||||
/* 【插桩白名单】设计内双路径回退:无块设备时由调用方回退
|
||||
* Limine boot module(CLAUDE.md 两阶段 DSK 加载设计)。 */
|
||||
log_error("[UTSM] FAT32: no block api available");
|
||||
return -1;
|
||||
}
|
||||
u32 count = api->block->device_count();
|
||||
if (count == 0 || api->block->sector_size(0) != 512) {
|
||||
/* 【插桩白名单】同上:无块设备属设计内回退路径。 */
|
||||
log_error("[UTSM] FAT32: no block device or wrong sector size");
|
||||
log_hex64("[UTSM] FAT32: device_count=", count);
|
||||
return -1;
|
||||
@@ -239,12 +245,17 @@ static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
if (st != 0) {
|
||||
log_error("[UTSM] FAT32: BPB read failed");
|
||||
log_hex64("[UTSM] FAT32: read status=", (u64)(i64)st);
|
||||
panic_full("DSL-E04 BPB READ FAILED",
|
||||
"dsk_load_from_block_fat32: BPB 256-sector read failed", 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
const fat32_bpb *bpb = (const fat32_bpb *)disk;
|
||||
if (bpb->boot_sig != 0xAA55 || bpb->bytes_per_sector != 512) {
|
||||
log_error("[UTSM] FAT32: invalid BPB signature or sector size");
|
||||
/* 【插桩白名单】设计内设备探测:device 0 可能是 GPT 主盘(LBA0 为
|
||||
* 保护性 MBR,带 0x55AA 签名但非 FAT32 VBR)。非 FAT32 卷时由调用
|
||||
* 方回退 Limine boot module(CLAUDE.md 两阶段 DSK 加载设计)。 */
|
||||
log_error("[UTSM] FAT32: not a FAT32 volume on device 0 (fallback to boot module)");
|
||||
log_hex64("[UTSM] FAT32: boot_sig=", bpb->boot_sig);
|
||||
log_hex64("[UTSM] FAT32: bps=", bpb->bytes_per_sector);
|
||||
return -1;
|
||||
@@ -271,6 +282,8 @@ static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
log_error("[UTSM] FAT32: dir cluster read failed");
|
||||
log_hex64("[UTSM] FAT32: clus=", clus);
|
||||
log_hex64("[UTSM] FAT32: lba=", clus_lba);
|
||||
panic_full("DSL-E06 DIR CLUSTER READ FAILED",
|
||||
"dsk_load_from_block_fat32: root dir cluster read failed", 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -294,6 +307,8 @@ static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
|
||||
if (!found_clus || found_size == 0) {
|
||||
log_error("[UTSM] FAT32: DESHAB.ELF not found in root dir");
|
||||
panic_full("DSL-E07 DESHAB ELF NOT FOUND",
|
||||
"dsk_load_from_block_fat32: DESHAB.ELF not found in root dir", 0);
|
||||
return -1;
|
||||
}
|
||||
log_hex64("[UTSM] FAT32: found_clus=", found_clus);
|
||||
@@ -301,6 +316,8 @@ static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
|
||||
if (found_size > sizeof(g_dsk_fat32_filedata)) {
|
||||
log_error("[UTSM] FAT32: file exceeds 2MB buffer");
|
||||
panic_full("DSL-E08 DSK FILE EXCEEDS BUFFER",
|
||||
"dsk_load_from_block_fat32: deshab.elf exceeds file buffer", 0);
|
||||
return -1;
|
||||
}
|
||||
u8 *dst = g_dsk_fat32_filedata;
|
||||
@@ -319,6 +336,8 @@ static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
log_error("[UTSM] FAT32: data cluster read failed");
|
||||
log_hex64("[UTSM] FAT32: fc=", fc);
|
||||
log_hex64("[UTSM] FAT32: lba=", fc_lba);
|
||||
panic_full("DSL-E09 DATA CLUSTER READ FAILED",
|
||||
"dsk_load_from_block_fat32: file data cluster read failed", 0);
|
||||
return -1;
|
||||
}
|
||||
for (u32 b = 0; b < fc_bytes; b++) dst[b] = chunk[b];
|
||||
@@ -334,6 +353,8 @@ static int dsk_load_from_block_fat32(const void **out_addr, u64 *out_size) {
|
||||
if (!file_buf) {
|
||||
log_error("[UTSM] FAT32: arena alloc failed");
|
||||
log_hex64("[UTSM] FAT32: size=", found_size);
|
||||
panic_full("DSL-E10 ARENA ALLOC FAILED",
|
||||
"dsk_load_from_block_fat32: arena alloc for DSK image failed", 0);
|
||||
return -1;
|
||||
}
|
||||
for (u32 i = 0; i < found_size; i++) file_buf[i] = g_dsk_fat32_filedata[i];
|
||||
@@ -1070,7 +1091,9 @@ int dsk_load_and_jump(void) {
|
||||
if (fat32_ok == 0) {
|
||||
log_info("[UTSM] DSK loaded from FAT32 block provider");
|
||||
} else {
|
||||
/* 2) fallback: Limine boot module */
|
||||
/* 2) fallback: Limine boot module
|
||||
* 【插桩白名单】设计内双路径回退:块设备读 deshab.elf 失败时
|
||||
* 回退 Limine boot module 预加载,按任务要求保持原样不插桩。 */
|
||||
log_info("[UTSM] FAT32 block path unavailable; trying Limine module");
|
||||
struct limine_file *file = dsk_find_module();
|
||||
if (!file) {
|
||||
@@ -1086,6 +1109,8 @@ int dsk_load_and_jump(void) {
|
||||
if (status != 0) {
|
||||
log_error("[UTSM] DSK ELF rejected");
|
||||
log_hex64("[UTSM] DSK ELF status=", (u64)(i64)status);
|
||||
panic_full("DSL-E11 DSK ELF REJECTED",
|
||||
"dsk_load_and_jump: deshab.elf ELF check rejected", 0);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1094,12 +1119,16 @@ int dsk_load_and_jump(void) {
|
||||
if (status != 0) {
|
||||
log_error("[UTSM] DSK load failed");
|
||||
log_hex64("[UTSM] DSK load status=", (u64)(i64)status);
|
||||
panic_full("DSL-E12 DSK LOAD FAILED",
|
||||
"dsk_load_and_jump: DSK ELF image load failed", 0);
|
||||
return status;
|
||||
}
|
||||
|
||||
dsk_boot_context *ctx = (dsk_boot_context *)kmem_alloc_aligned(sizeof(dsk_boot_context), 16);
|
||||
if (!ctx) {
|
||||
log_error("[UTSM] DSK context allocation failed");
|
||||
panic_full("DSL-E13 DSK CONTEXT ALLOC FAILED",
|
||||
"dsk_load_and_jump: boot context allocation failed", 0);
|
||||
return -1;
|
||||
}
|
||||
dsk_fill_boot_context(ctx);
|
||||
@@ -1169,5 +1198,7 @@ int dsk_load_and_jump(void) {
|
||||
entry(ctx);
|
||||
|
||||
log_error("[UTSM] DSK returned unexpectedly");
|
||||
panic_full("DSL-E14 DSK RETURNED UNEXPECTEDLY",
|
||||
"dsk entry point returned to UTSM", 0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
kernel/dsk_loader.o: kernel\dsk_loader.c include\utsm\dsk.h \
|
||||
include\utsm\types.h include\utsm\arena.h include\utsm\dkm.h \
|
||||
include\utsm\dma.h include\utsm\block.h include\utsm\net.h \
|
||||
include\utsm\paging.h include\utsm\log.h include\utsm\pe.h \
|
||||
include\utsm\linux_compat.h include\utsm\instr.h include\utsm\panic.h \
|
||||
kernel\..\arch\x86_64\limine.h kernel\..\..\tools\fat32_lfn.h
|
||||
include\utsm\dsk.h:
|
||||
include\utsm\types.h:
|
||||
include\utsm\arena.h:
|
||||
include\utsm\dkm.h:
|
||||
include\utsm\dma.h:
|
||||
include\utsm\block.h:
|
||||
include\utsm\net.h:
|
||||
include\utsm\paging.h:
|
||||
include\utsm\log.h:
|
||||
include\utsm\pe.h:
|
||||
include\utsm\linux_compat.h:
|
||||
include\utsm\instr.h:
|
||||
include\utsm\panic.h:
|
||||
kernel\..\arch\x86_64\limine.h:
|
||||
kernel\..\..\tools\fat32_lfn.h:
|
||||
Binary file not shown.
+14
-1
@@ -190,7 +190,10 @@ static void disk_log_flush(void) {
|
||||
log_info("[UTSM] disk_log: BOOTLOG.TXT written");
|
||||
log_hex64("[UTSM] disk_log: bytes=", len);
|
||||
} else {
|
||||
log_error("[UTSM] disk_log: FAT32 write failed");
|
||||
/* 【插桩白名单】设计内只读块路径:AHCI provider 当前仅注册最小
|
||||
* read(CLAUDE.md ahci 驱动说明),write 恒为空,bootlog 落盘
|
||||
* 失败属环境能力缺失而非数据读写错误。诊断日志不得阻断启动。 */
|
||||
log_error("[UTSM] disk_log: FAT32 write failed (read-only block path, skip)");
|
||||
log_hex64("[UTSM] disk_log: rc=", (u64)(i64)rc);
|
||||
}
|
||||
}
|
||||
@@ -258,6 +261,8 @@ void kernel_main(void) {
|
||||
if (cr4 & (1ULL << 12)) {
|
||||
log_error("[UTSM] LA57 is ACTIVE — this kernel requires 4-level paging");
|
||||
log_error("[UTSM] Refusing to boot. Disable LA57 in firmware settings.");
|
||||
panic_full("VMM-E11 LA57 ACTIVE REFUSE BOOT",
|
||||
"5-level paging active; kernel requires 4-level paging", 0);
|
||||
arch_halt_forever();
|
||||
}
|
||||
}
|
||||
@@ -404,6 +409,8 @@ void kernel_main(void) {
|
||||
* (configured separately) may still work. Force-continue regardless. */
|
||||
if (vmm_st != 0) {
|
||||
log_warn("[UTSM] VMM self-test FAIL, but continuing to Linux guest");
|
||||
panic_full("VMM-E12 VMM SELFTEST FAIL",
|
||||
"VMM self-test failed; force-continue removed by instrumentation", 0);
|
||||
vmm_st = 0; /* force pass to continue to Linux guest */
|
||||
}
|
||||
if (vmm_st == 0) {
|
||||
@@ -476,6 +483,8 @@ void kernel_main(void) {
|
||||
INSTR_TS_END(ts_vmm, "vmm_init+selftest");
|
||||
log_error("[UTSM] VMM self-test FAIL");
|
||||
log_hex64("[UTSM] VMM st=", (u64)(i64)vmm_st);
|
||||
panic_full("VMM-E13 VMM SELFTEST FAIL",
|
||||
"VMM self-test failed (non-zero status)", 0);
|
||||
}
|
||||
|
||||
/* === OpenXJ380 guest — 可通过 FUCK [boot] xj380_guest=0 跳过 ===
|
||||
@@ -532,6 +541,8 @@ void kernel_main(void) {
|
||||
log_info("[UTSM] SELFTEST PASS");
|
||||
} else {
|
||||
log_error("[UTSM] SELFTEST FAIL");
|
||||
panic_full("VMM-E14 SELFTEST FAIL",
|
||||
"utsm_selftest_run returned non-zero", 0);
|
||||
arch_halt_forever();
|
||||
}
|
||||
}
|
||||
@@ -570,6 +581,8 @@ void kernel_main(void) {
|
||||
|
||||
if (dsk_load_and_jump() != 0) {
|
||||
log_error("[UTSM] DSK jump failed");
|
||||
panic_full("VMM-E15 DSK JUMP FAILED",
|
||||
"dsk_load_and_jump returned non-zero", 0);
|
||||
}
|
||||
|
||||
/* ---- 插桩: 启动总耗时(仅在 DSK 跳转失败时可见) ---- */
|
||||
|
||||
Binary file not shown.
@@ -15,6 +15,7 @@
|
||||
#include <utsm/log.h>
|
||||
#include <utsm/types.h>
|
||||
#include <utsm/arena.h>
|
||||
#include <utsm/panic.h>
|
||||
#include "ini_parser.h"
|
||||
|
||||
/* ---- 探测缓冲状态 ---- */
|
||||
@@ -39,6 +40,8 @@ void probe_init(const void *cfg_ptr) {
|
||||
if (!g_probe_buf) {
|
||||
g_instr_probe_enable = 0;
|
||||
log_warn("[PROBE] arena alloc failed, probe disabled");
|
||||
panic_full("PRB-E01 PROBE ARENA ALLOC FAILED",
|
||||
"probe_init: probe buffer arena allocation failed", 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
kernel/probe.o: kernel\probe.c include\utsm\instr.h include\utsm\types.h \
|
||||
include\utsm\log.h include\utsm\arena.h include\utsm\panic.h \
|
||||
kernel\ini_parser.h
|
||||
include\utsm\instr.h:
|
||||
include\utsm\types.h:
|
||||
include\utsm\log.h:
|
||||
include\utsm\arena.h:
|
||||
include\utsm\panic.h:
|
||||
kernel\ini_parser.h:
|
||||
Reference in New Issue
Block a user