Merge branch 'fixes-for-grant-maps-and-others' into 'aarch64-rebase'
Fixes for grant maps and others See merge request redox-os/kernel!162
This commit is contained in:
@@ -81,7 +81,8 @@
|
||||
/// Offset to user TLS
|
||||
pub const USER_TLS_OFFSET: usize = USER_SIGSTACK_OFFSET + PML4_SIZE;
|
||||
pub const USER_TLS_PML4: usize = (USER_TLS_OFFSET & PML4_MASK)/PML4_SIZE;
|
||||
pub const USER_TLS_SIZE: usize = 64 * 1024;
|
||||
// Maximum TLS allocated to each PID, should be approximately 8 MB
|
||||
pub const USER_TLS_SIZE: usize = PML4_SIZE / 65536;
|
||||
|
||||
/// Offset to user temporary image (used when cloning)
|
||||
pub const USER_TMP_OFFSET: usize = USER_TLS_OFFSET + PML4_SIZE;
|
||||
|
||||
@@ -392,6 +392,7 @@ impl PhysicalAddress {
|
||||
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct VirtualAddress(usize);
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum VirtualAddressType {
|
||||
User,
|
||||
Kernel
|
||||
|
||||
@@ -87,10 +87,14 @@ impl Context {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_page_table(&self) -> usize {
|
||||
pub fn get_page_utable(&self) -> usize {
|
||||
self.ttbr0_el1
|
||||
}
|
||||
|
||||
pub fn get_page_ktable(&self) -> usize {
|
||||
self.ttbr1_el1
|
||||
}
|
||||
|
||||
pub fn set_fx(&mut self, _address: usize) {
|
||||
}
|
||||
|
||||
|
||||
@@ -371,7 +371,7 @@ impl Grant {
|
||||
}
|
||||
|
||||
pub fn map_inactive(from: VirtualAddress, to: VirtualAddress, size: usize, flags: EntryFlags, desc_opt: Option<FileDescriptor>, new_table: &mut InactivePageTable, temporary_page: &mut TemporaryPage) -> Grant {
|
||||
let mut active_table = match to.get_type() {
|
||||
let mut active_table = match from.get_type() {
|
||||
VirtualAddressType::User => unsafe { ActivePageTable::new(PageTableType::User) },
|
||||
VirtualAddressType::Kernel => unsafe { ActivePageTable::new(PageTableType::Kernel) }
|
||||
};
|
||||
@@ -386,6 +386,11 @@ impl Grant {
|
||||
frames.push_back(frame);
|
||||
}
|
||||
|
||||
let mut active_table = match to.get_type() {
|
||||
VirtualAddressType::User => unsafe { ActivePageTable::new(PageTableType::User) },
|
||||
VirtualAddressType::Kernel => unsafe { ActivePageTable::new(PageTableType::Kernel) }
|
||||
};
|
||||
|
||||
active_table.with(new_table, temporary_page, |mapper| {
|
||||
let start_page = Page::containing_address(to);
|
||||
let end_page = Page::containing_address(VirtualAddress::new(to.data() + size - 1));
|
||||
|
||||
@@ -460,7 +460,7 @@ where F: FnOnce(*mut u8) -> Result<()>
|
||||
|
||||
let mut active_page_table = unsafe { ActivePageTable::new(PageTableType::User) };
|
||||
let mut target_page_table = unsafe {
|
||||
InactivePageTable::from_address(context.arch.get_page_table())
|
||||
InactivePageTable::from_address(context.arch.get_page_utable())
|
||||
};
|
||||
|
||||
// Find the physical frames for all pages
|
||||
|
||||
@@ -123,7 +123,7 @@ impl UserInner {
|
||||
let context_lock = context_weak.upgrade().ok_or(Error::new(ESRCH))?;
|
||||
let mut context = context_lock.write();
|
||||
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_utable()) };
|
||||
let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
|
||||
|
||||
let mut grants = context.grants.lock();
|
||||
@@ -154,7 +154,7 @@ impl UserInner {
|
||||
let context_lock = self.context.upgrade().ok_or(Error::new(ESRCH))?;
|
||||
let mut context = context_lock.write();
|
||||
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_utable()) };
|
||||
let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
|
||||
|
||||
let mut grants = context.grants.lock();
|
||||
|
||||
@@ -599,7 +599,7 @@ fn empty(context: &mut context::Context, reaping: bool) {
|
||||
if reaping {
|
||||
println!("{}: {}: Grant should not exist: {:?}", context.id.into(), unsafe { ::core::str::from_utf8_unchecked(&context.name.lock()) }, grant);
|
||||
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_table()) };
|
||||
let mut new_table = unsafe { InactivePageTable::from_address(context.arch.get_page_utable()) };
|
||||
let mut temporary_page = TemporaryPage::new(Page::containing_address(VirtualAddress::new(crate::USER_TMP_GRANT_OFFSET)));
|
||||
|
||||
grant.unmap_inactive(&mut new_table, &mut temporary_page);
|
||||
|
||||
Reference in New Issue
Block a user