mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
patch PTEs mapped to swapper with virtual addresses
The addresses put into the swapper's page table are physical addresses, which are unusable by the swapper itself. This patches the PTEs with the repsective virtual address, so we don't have to do a PT walk inside the swapper when handling a swap event. Also fix an off-by-one on the processes count. This is sort of an old architectural bug in the loader that would be nice to fix someday.
This commit is contained in:
parent
edf3e84fad
commit
be98a88a75
1 changed files with 10 additions and 17 deletions
|
|
@ -221,22 +221,15 @@ pub fn phase_2(cfg: &mut BootConfig, fs_prehash: &[u8; 64]) {
|
||||||
}
|
}
|
||||||
// now chase down any entries in the roots, and map valid pages
|
// now chase down any entries in the roots, and map valid pages
|
||||||
for p in 0..cfg.processes.len() {
|
for p in 0..cfg.processes.len() {
|
||||||
let root_pt = unsafe { &*(cfg.swap_root[p] as *const PageTable) };
|
let root_pt = unsafe { &mut *(cfg.swap_root[p] as *mut PageTable) };
|
||||||
for &entry in root_pt.entries.iter() {
|
for entry in root_pt.entries.iter_mut() {
|
||||||
if entry & FLG_VALID != 0 {
|
if *entry & FLG_VALID != 0 {
|
||||||
let paddr = (entry & !0x3FF) << 2;
|
let paddr = (*entry & !0x3FF) << 2;
|
||||||
println!(
|
let vaddr = SWAP_PT_VADDR + swap_pt_vaddr_offset;
|
||||||
"Mapping L2 swap PT to PID 2 @paddr {:x} -> vaddr {:x}",
|
cfg.map_page(root, paddr, vaddr, FLG_R | FLG_W | FLG_U | FLG_VALID, SWAPPER_PID);
|
||||||
paddr,
|
// patch the entry to point at the virtual address
|
||||||
SWAP_PT_VADDR + swap_pt_vaddr_offset
|
*entry &= 0x3FF;
|
||||||
);
|
*entry |= (vaddr & !0xFFF) >> 2;
|
||||||
cfg.map_page(
|
|
||||||
root,
|
|
||||||
paddr,
|
|
||||||
SWAP_PT_VADDR + swap_pt_vaddr_offset,
|
|
||||||
FLG_R | FLG_W | FLG_U | FLG_VALID,
|
|
||||||
SWAPPER_PID,
|
|
||||||
);
|
|
||||||
swap_pt_vaddr_offset += PAGE_SIZE;
|
swap_pt_vaddr_offset += PAGE_SIZE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +250,7 @@ pub fn phase_2(cfg: &mut BootConfig, fs_prehash: &[u8; 64]) {
|
||||||
let swap_spec = unsafe { (swap_spec_ptr as *mut SwapSpec).as_mut().unwrap() };
|
let swap_spec = unsafe { (swap_spec_ptr as *mut SwapSpec).as_mut().unwrap() };
|
||||||
if let Some(desc) = cfg.swap {
|
if let Some(desc) = cfg.swap {
|
||||||
swap_spec.key.copy_from_slice(&desc.key);
|
swap_spec.key.copy_from_slice(&desc.key);
|
||||||
swap_spec.pid_count = cfg.init_process_count as u32;
|
swap_spec.pid_count = cfg.init_process_count as u32 + 1;
|
||||||
swap_spec.rpt_len_bytes = cfg.runtime_page_tracker.len() as u32;
|
swap_spec.rpt_len_bytes = cfg.runtime_page_tracker.len() as u32;
|
||||||
swap_spec.swap_base = desc.ram_offset;
|
swap_spec.swap_base = desc.ram_offset;
|
||||||
swap_spec.swap_len = desc.ram_size;
|
swap_spec.swap_len = desc.ram_size;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue