fix bug where pages were not marked as belonging to USER

it's assumed the kernel would never want to access the flash
directly, so no mode is implemented to support this possibility.
This commit is contained in:
bunnie 2025-05-15 11:52:41 +08:00
parent 3f0b833b90
commit b8c30c32ac

View file

@ -6,7 +6,10 @@ use core::fmt;
use xous_kernel::{MemoryFlags, MemoryRange, PID, arch::*};
pub use crate::arch::mem::MemoryMapping;
use crate::arch::process::Process;
use crate::arch::{
mem::{MMUFlags, flush_mmu, pagetable_entry},
process::Process,
};
#[cfg(feature = "swap")]
use crate::swap::SwapAlloc;
@ -635,6 +638,13 @@ impl MemoryManager {
// not automatically set on write/update). Valid is not set, because it's not
// wired into memory, and "P" (swap) is set to indicate this is a swapper managed page.
mm.reserve_address(self, virt, MemoryFlags::R | MemoryFlags::W | MemoryFlags::P)?;
// now mark the page as USER
let pte = pagetable_entry(virt)?;
unsafe {
pte.write_volatile(pte.read_volatile() | MMUFlags::USER.bits());
flush_mmu();
}
}
// note that the region returned is snapped to the nearest page boundary, even if
// the use called us with unaligned addresses.