Separate process address spaces

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
pini

Separate process address spaces

Post by pini »

I want to use paging to build for each process its own address space.
When I want to switch between two processes, I have to save registers for the old process and restore registers values for the new one.
There's no problem with this : I get it work with several processes.
I'm using the quiet simple technique below:

Code: Select all

; push all registers, including cr3
; call C function to save the values on the stack and put the new values in this stack
; pop all registers back, to make the system believe the new process is the one that was interrupted
This goes somewhere in the Timer IRQ and works well

But when I want different paging structures, I have to pop cr3 back (well through a general register at all, but this doesn't matter here).
When I set the new cr3 values, each address after this is interpreted using the new paging structures, including EIP, so the end of my code (which pops back the rest of the registers) is not executed.
Worse : the processor "jumps" to an address that has nothing to deal with code and crashes my kernel.

How can I reload cr3 and continue executing the end of my asm routine ?
pini

Re:Separate process address spaces

Post by pini »

Hum... maybe I should use the cr3 field of the TSS ?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Separate process address spaces

Post by Pype.Clicker »

How can I reload cr3 and continue executing the end of my asm routine ?
there's a very simple solution to this problem: just make sure the code that performs the CR3 change is mapped the same way in every address space...
Post Reply