mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: mem: don't unilaterally hand memory to userspace
If it's needed for use in the kernel, don't hand it over. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
a31c4722fa
commit
0be1b8b94c
1 changed files with 4 additions and 2 deletions
|
|
@ -349,7 +349,7 @@ impl MemoryManager {
|
|||
|
||||
/// Attempt to allocate a single page from the default section.
|
||||
/// Note that this will be backed by a real page.
|
||||
pub fn map_zeroed_page(&mut self, pid: PID) -> Result<*mut usize, xous::Error> {
|
||||
pub fn map_zeroed_page(&mut self, pid: PID, is_user: bool) -> Result<*mut usize, xous::Error> {
|
||||
let virt =
|
||||
self.find_virtual_address(0 as *mut usize, PAGE_SIZE, xous::MemoryType::Default)?;
|
||||
|
||||
|
|
@ -372,7 +372,9 @@ impl MemoryManager {
|
|||
|
||||
// Zero-out the page
|
||||
unsafe { virt.write_bytes(0, PAGE_SIZE / mem::size_of::<usize>()) };
|
||||
crate::arch::mem::hand_page_to_user(virt)?;
|
||||
if is_user {
|
||||
crate::arch::mem::hand_page_to_user(virt)?;
|
||||
}
|
||||
Ok(virt)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue