mirror of
https://github.com/edera-dev/krata.git
synced 2025-08-05 14:11:32 +00:00
more debugging of page table issues
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
use crate::sys::XEN_PAGE_SHIFT;
|
||||
use crate::XenClientError;
|
||||
use libc::munmap;
|
||||
use std::ffi::c_void;
|
||||
|
||||
use crate::x86::X86_PAGE_SHIFT;
|
||||
use xencall::sys::MmapEntry;
|
||||
@ -104,4 +106,28 @@ impl PhysicalPages<'_> {
|
||||
self.pages.push(page);
|
||||
Ok(addr)
|
||||
}
|
||||
|
||||
pub fn unmap(&mut self, pfn: u64) -> Result<(), XenClientError> {
|
||||
let mut page: Option<&PhysicalPage> = None;
|
||||
for item in &self.pages {
|
||||
if pfn >= item.pfn && pfn < (item.pfn + item.count) {
|
||||
break;
|
||||
}
|
||||
page = Some(item);
|
||||
}
|
||||
if page.is_none() {
|
||||
return Err(XenClientError::new("failed to unmap pfn"));
|
||||
}
|
||||
let page = page.unwrap();
|
||||
unsafe {
|
||||
let err = munmap(
|
||||
page.ptr as *mut c_void,
|
||||
(page.count << X86_PAGE_SHIFT) as usize,
|
||||
);
|
||||
if err != 0 {
|
||||
return Err(XenClientError::new("failed to munmap pfn"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user