OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 5:10 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Paging Idea for a Microkernel (not sure if it would work)
PostPosted: Wed Jun 22, 2016 10:16 am 
Offline

Joined: Sat Sep 15, 2012 5:02 pm
Posts: 15
Note: This may be a bad idea, but I'm not sure... it should *ONLY* work for a microkernel or a similar design...

Idea:

Let's say you have a page directory initialization function that creates a map of the current address space, giving a pointer that can be moved to CR3. What if the page directory for user processes does not map the kernel address space, AKA marking it as not present? On the event of a task switch or a software interrupt, for example, the task switch IRQ handler or the interrupt handler are already placed into user memory, running at CPL=0 when called so they can re-map the kernel-space as present. Once everything needed to be executed in the kernel and user-mode servers has run, the kernel remaps CR3 to not include kernel space every level of the software interrupt or task switch. While the kernel and the servers are communicating (IPC), they don't switch CR3 until they are *completely* finished (no one wants to make the system slower by adding too many CR3 swaps for no good reason).

This would involve work in the kernel to re-map many functions outside of it, which is a good thing for a microkernel design. Of course, there would need to be adequate memory protection for userspace as well.

This is, of course, a theoretical concept at the moment.

_________________
https://github.com/christophersacchi/RazorOS
"... you notice that this scanner will... woah!"
"Moving right along!"
"That must be, uh. That must be why we're not shipping Windows 98 yet..."
"Absolutely. Absolutely."


Top
 Profile  
 
 Post subject: Re: Paging Idea for a Microkernel (not sure if it would work
PostPosted: Wed Jun 22, 2016 11:02 am 
Offline
Member
Member

Joined: Sat Nov 07, 2015 3:12 pm
Posts: 145
So basically you want a " iceberg" design where only the tip of it is permanently mapped ( for interrupts & syscalls )
This can work . But what benefit does it brings you ?
Do you want to save TLB space until the next syscall ?

The only reason I would do that is to be able to hook/mock / sandbox syscalls for a given process.


Top
 Profile  
 
 Post subject: Re: Paging Idea for a Microkernel (not sure if it would work
PostPosted: Wed Jun 22, 2016 11:04 am 
Offline
Member
Member

Joined: Sat Oct 16, 2010 3:38 pm
Posts: 587
Then every single address space (of every process) would need to include those interrupt handlers, and since they're in userspace, they could easily be corruped.

My solution to this is that there is only one paging structure per CPU; i.e. there is only one value for CR3 on each CPU, and is never changed. I only change the first PDPT depending on process, which gives 512 GB of virtual userspace memory per process, and that is certainly enough, and avoids the overhead of copying all kernel page structure into every address space. It also avoids the security flaw I mentioned above.


Top
 Profile  
 
 Post subject: Re: Paging Idea for a Microkernel (not sure if it would work
PostPosted: Wed Jun 22, 2016 11:37 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1146
Sounds interesting from a security point of view - only privileged (and presumably trusted) code can enter the kernel address space.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
 Post subject: Re: Paging Idea for a Microkernel (not sure if it would work
PostPosted: Wed Jun 22, 2016 11:50 am 
Offline
Member
Member
User avatar

Joined: Sat Jan 15, 2005 12:00 am
Posts: 8561
Location: At his keyboard!
Hi,

onlyonemac wrote:
Sounds interesting from a security point of view - only privileged (and presumably trusted) code can enter the kernel address space.


Not really - the "always present" part of the kernel would have to enable/map the majority of the kernel every time the kernel needs to do anything; which means the only time the "temporarily not mapped" part of the kernel would actually be "not present" is when you're running at CPL=3 and wouldn't be able to touch it if it was present.

Essentially; it probably won't be any better for security than a traditional micro-kernel. It'll just be much much slower due to frequent "kernel TLB flush" problems.


Cheers,

Brendan

_________________
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 67 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group