Add pages to use for head and tail of buffers in userscheme
This commit is contained in:
@@ -2,10 +2,12 @@ use alloc::sync::Arc;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::vec::Vec;
|
||||
use alloc::collections::VecDeque;
|
||||
use core::alloc::{GlobalAlloc, Layout};
|
||||
use core::cmp::Ordering;
|
||||
use core::mem;
|
||||
use spin::Mutex;
|
||||
|
||||
use arch::paging::PAGE_SIZE;
|
||||
use context::arch;
|
||||
use context::file::FileDescriptor;
|
||||
use context::memory::{Grant, Memory, SharedMemory, Tls};
|
||||
@@ -119,6 +121,10 @@ pub struct Context {
|
||||
pub cpu_id: Option<usize>,
|
||||
/// Current system call
|
||||
pub syscall: Option<(usize, usize, usize, usize, usize, usize)>,
|
||||
/// Head buffer to use when system call buffers are not page aligned
|
||||
pub syscall_head: Box<[u8]>,
|
||||
/// Tail buffer to use when system call buffers are not page aligned
|
||||
pub syscall_tail: Box<[u8]>,
|
||||
/// Context is halting parent
|
||||
pub vfork: bool,
|
||||
/// Context is being waited on
|
||||
@@ -161,6 +167,9 @@ pub struct Context {
|
||||
|
||||
impl Context {
|
||||
pub fn new(id: ContextId) -> Context {
|
||||
let syscall_head = unsafe { Box::from_raw(::ALLOCATOR.alloc(Layout::from_size_align_unchecked(PAGE_SIZE, PAGE_SIZE)) as *mut [u8; PAGE_SIZE]) };
|
||||
let syscall_tail = unsafe { Box::from_raw(::ALLOCATOR.alloc(Layout::from_size_align_unchecked(PAGE_SIZE, PAGE_SIZE)) as *mut [u8; PAGE_SIZE]) };
|
||||
|
||||
Context {
|
||||
id: id,
|
||||
pgid: id,
|
||||
@@ -176,6 +185,8 @@ impl Context {
|
||||
running: false,
|
||||
cpu_id: None,
|
||||
syscall: None,
|
||||
syscall_head: syscall_head,
|
||||
syscall_tail: syscall_tail,
|
||||
vfork: false,
|
||||
waitpid: Arc::new(WaitMap::new()),
|
||||
pending: VecDeque::new(),
|
||||
|
||||
@@ -68,6 +68,7 @@ impl Grant {
|
||||
pub fn map_inactive(from: VirtualAddress, to: VirtualAddress, size: usize, flags: EntryFlags, new_table: &mut InactivePageTable, temporary_page: &mut TemporaryPage) -> Grant {
|
||||
let mut active_table = unsafe { ActivePageTable::new() };
|
||||
|
||||
//TODO: Do not allocate
|
||||
let mut frames = VecDeque::with_capacity(size/PAGE_SIZE);
|
||||
|
||||
let start_page = Page::containing_address(from);
|
||||
|
||||
@@ -127,6 +127,7 @@ impl UserInner {
|
||||
i += 1;
|
||||
}
|
||||
|
||||
//TODO: Use syscall_head and syscall_tail to avoid leaking data
|
||||
grants.insert(i, Grant::map_inactive(
|
||||
VirtualAddress::new(from_address),
|
||||
VirtualAddress::new(to_address),
|
||||
|
||||
Reference in New Issue
Block a user