diff options
Diffstat (limited to 'rsdos/src/main.rs')
| -rw-r--r-- | rsdos/src/main.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/rsdos/src/main.rs b/rsdos/src/main.rs index cbbf2ba..806f150 100644 --- a/rsdos/src/main.rs +++ b/rsdos/src/main.rs | |||
| @@ -344,9 +344,38 @@ pub unsafe extern "efiapi" fn efi_main(image_handle: Handle, system_table: *mut | |||
| 344 | } else { | 344 | } else { |
| 345 | rsnix::serial_println!("cursor: no mouse — overlay disabled"); | 345 | rsnix::serial_println!("cursor: no mouse — overlay disabled"); |
| 346 | } | 346 | } |
| 347 | // TEST HOOK: reproduce the OptiPlex '0xaaaaaa' uninit-drop crash in | ||
| 348 | // QEMU. The real hardware's stack carries 0xAA fill left by | ||
| 349 | // firmware; any shell value that is dropped without being written | ||
| 350 | // then frees garbage and trips the dealloc guard. Filling the | ||
| 351 | // shell's future stack region with 0xAA here makes the same bug | ||
| 352 | // visible on QEMU (serial + gdb available) instead of only on the | ||
| 353 | // OptiPlex. | ||
| 354 | stack_fill_aa(); | ||
| 347 | shell::run(); | 355 | shell::run(); |
| 348 | } | 356 | } |
| 349 | 357 | ||
| 358 | /// Write 0xAA over the stack region the shell's frames will reuse, | ||
| 359 | /// leaving the current frames (top 4 KiB) intact. 128 KiB covers the | ||
| 360 | /// whole shell frame chain on QEMU and the OptiPlex. Best-effort: the | ||
| 361 | /// region is below rsp inside the boot stack mapping. | ||
| 362 | fn stack_fill_aa() { | ||
| 363 | let rsp: usize; | ||
| 364 | unsafe { | ||
| 365 | core::arch::asm!("mov {}, rsp", out(reg) rsp); | ||
| 366 | } | ||
| 367 | let top = rsp - 0x1000; | ||
| 368 | let bottom = rsp - 0x21000; | ||
| 369 | unsafe { | ||
| 370 | let mut p = bottom; | ||
| 371 | while p < top { | ||
| 372 | core::ptr::write_volatile(p as *mut u64, 0xAAAAAAAAAAAAAAAA); | ||
| 373 | p += 8; | ||
| 374 | } | ||
| 375 | } | ||
| 376 | rsnix::serial_println!("stack: 0xAA-fill 0x{:x}..0x{:x}", bottom, top); | ||
| 377 | } | ||
| 378 | |||
| 350 | // --------------------------------------------------------------------------- | 379 | // --------------------------------------------------------------------------- |
| 351 | // Print a memory summary from the stashed memory map | 380 | // Print a memory summary from the stashed memory map |
| 352 | // --------------------------------------------------------------------------- | 381 | // --------------------------------------------------------------------------- |
