mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
handle case of write pages being swapped out upon write release
This commit is contained in:
parent
831100a1f0
commit
04c7933c87
2 changed files with 29 additions and 16 deletions
|
|
@ -1182,7 +1182,7 @@ pub fn evict_page_inner(target_pid: PID, vaddr: usize) -> Result<usize, xous_ker
|
||||||
// return us to the swapper PID -- this call can only originate in the swapper
|
// return us to the swapper PID -- this call can only originate in the swapper
|
||||||
#[cfg(feature = "debug-swap")]
|
#[cfg(feature = "debug-swap")]
|
||||||
{
|
{
|
||||||
crate::arch::mem::MemoryMapping::current().print_map();
|
// crate::arch::mem::MemoryMapping::current().print_map();
|
||||||
println!(
|
println!(
|
||||||
"evict_page_inner() failed sanity check. PTE: {:x?} paddr: {:x} vaddr in PID{}: {:x}",
|
"evict_page_inner() failed sanity check. PTE: {:x?} paddr: {:x} vaddr in PID{}: {:x}",
|
||||||
target_pte,
|
target_pte,
|
||||||
|
|
|
||||||
|
|
@ -870,21 +870,34 @@ impl Swap {
|
||||||
let flash_vaddr = MMAP_VIRT_BASE + flash_offset;
|
let flash_vaddr = MMAP_VIRT_BASE + flash_offset;
|
||||||
// evict_page_inner marks the page as swapped/invalid in src_pid, but also maps the page
|
// evict_page_inner marks the page as swapped/invalid in src_pid, but also maps the page
|
||||||
// into the swapper's address space
|
// into the swapper's address space
|
||||||
let swap_vaddr = crate::arch::mem::evict_page_inner(src_pid, flash_vaddr).unwrap();
|
match crate::arch::mem::evict_page_inner(src_pid, flash_vaddr) {
|
||||||
|
Ok(swap_vaddr) => {
|
||||||
// release the page from the swapper's address space
|
// release the page from the swapper's address space
|
||||||
MemoryManager::with_mut(|mm| {
|
MemoryManager::with_mut(|mm| {
|
||||||
let paddr = crate::arch::mem::virt_to_phys(swap_vaddr).unwrap() as usize;
|
let paddr = crate::arch::mem::virt_to_phys(swap_vaddr).unwrap() as usize;
|
||||||
#[cfg(feature = "debug-swap-verbose")]
|
#[cfg(feature = "debug-swap-verbose")]
|
||||||
println!("Release flash backing page - paddr {:x}", paddr);
|
println!("Release flash backing page - paddr {:x}", paddr);
|
||||||
// this call unmaps the virtual page from the page table
|
// this call unmaps the virtual page from the page table
|
||||||
crate::arch::mem::unmap_page_inner(mm, swap_vaddr).expect("couldn't unmap page");
|
crate::arch::mem::unmap_page_inner(mm, swap_vaddr).expect("couldn't unmap page");
|
||||||
// This call releases the physical page from the RPT - the pid has to match that of
|
// This call releases the physical page from the RPT - the pid has to match that
|
||||||
// the original owner. This is the "pointy end" of the stick;
|
// of the original owner. This is the "pointy end" of
|
||||||
// after this call, the memory is now back into the free pool.
|
// the stick; after this call, the memory is now back
|
||||||
mm.release_page_swap(paddr as *mut usize, src_pid)
|
// into the free pool.
|
||||||
.expect("couldn't free page that was swapped out");
|
mm.release_page_swap(paddr as *mut usize, src_pid)
|
||||||
});
|
.expect("couldn't free page that was swapped out");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Err(xous_kernel::Error::BadAddress) => {
|
||||||
|
#[cfg(feature = "debug-swap")]
|
||||||
|
println!("Written page wasn't mapped {:x}", flash_vaddr);
|
||||||
|
// in this case, it wasn't mapped into memory. We have been returned to the
|
||||||
|
// swapper's memory space, and we can just move to
|
||||||
|
// checking the next page
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
panic!("Unexpected error in WriteToFlash page free")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Unhalt IRQs
|
// Unhalt IRQs
|
||||||
self.swap_restore_irq();
|
self.swap_restore_irq();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue