Skip to content

fix: alloc_more single-page uses recycled frames, preventing DMA bus error on LoongArch

StellaOS requested to merge merge_618 into main

Root cause: alloc_more() only allocated from the monotonic 'current' pointer, never recycling freed frames. After ~15min of iozone I/O, 'current' advanced past QEMU's actual physical memory boundary (1GB), allocating frames at non-existent physical addresses (e.g., 0xb0000000). On LoongArch, DMW1 access to unmapped physical memory triggers MemoryAccessAddressError (bus error). RISC-V doesn't crash because QEMU RISC-V returns zeros for out-of-range physical addresses instead of generating a bus error.

Fix: single-page alloc_more(1) now delegates to alloc(), which prefers recycled frames. Multi-page alloc_more (requiring physical contiguity for DMA) retains the original linear allocation from 'current'.

Also reverts BTreeSet→Vec in recycled list (back to original design), and fixes two minor syscalls:

  • sys_statfs: return Statfs::default() for pseudo filesystems instead of ENODEV
  • sys_kill: return ESRCH (not ECHILD) per POSIX

Merge request reports