From d3fbbd5918a6ea5d2d947d0fcac995d02af2b751 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sun, 21 Aug 2022 13:21:59 -0600 Subject: [PATCH] Pre-allocate x86 kernel PD entries --- rmm | 2 +- src/arch/x86/rmm.rs | 9 +++++++++ src/scheme/sys/context.rs | 5 +---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rmm b/rmm index df733ed..0d4ff5d 160000 --- a/rmm +++ b/rmm @@ -1 +1 @@ -Subproject commit df733ed5714aaa7f7b3e15707bd7ef8a44802779 +Subproject commit 0d4ff5d4f36f26289556c6e7a13e4b40ff736b83 diff --git a/src/arch/x86/rmm.rs b/src/arch/x86/rmm.rs index 7827a7e..cd635d0 100644 --- a/src/arch/x86/rmm.rs +++ b/src/arch/x86/rmm.rs @@ -14,6 +14,7 @@ use rmm::{ FrameCount, FrameUsage, MemoryArea, + PageEntry, PageFlags, PageMapper, PhysicalAddress, @@ -105,6 +106,14 @@ unsafe fn inner( &mut bump_allocator ).expect("failed to create Mapper"); + // Pre-allocate all kernel PD entries so that when the page table is copied, + // these entries are synced between processes + for i in 512..1024 { + let phys = mapper.allocator_mut().allocate_one().expect("failed to map page table"); + let flags = A::ENTRY_FLAG_READWRITE | A::ENTRY_FLAG_DEFAULT_TABLE; + mapper.table().set_entry(i, PageEntry::new(phys.data() | flags)); + } + // Map all physical areas at PHYS_OFFSET for area in areas.iter() { for i in 0..area.size / A::PAGE_SIZE { diff --git a/src/scheme/sys/context.rs b/src/scheme/sys/context.rs index 8602e9b..9555433 100644 --- a/src/scheme/sys/context.rs +++ b/src/scheme/sys/context.rs @@ -76,10 +76,7 @@ pub fn resource() -> Result> { format!("{}", ticks) }; - let mut memory = 0; - if let Some(ref kfx) = context.kstack { - memory += kfx.len(); - } + let mut memory = context.kfx.len(); if let Some(ref kstack) = context.kstack { memory += kstack.len(); }