Page 1 of 1

paging and process mapping

Posted: Sun Jun 27, 2010 3:54 am
by icecoder
Hi guys, I've searched everywhere and read the intel ASD manual vol 3A before posting, but didn't find answers to this question (assuming 32bit paging with no PAE):

Assuming 32bit paging is enabled, how can I isolate a process from the other ones?
Should I create a page directory for every process I run?

A linear address points simultaneously to the PDE, PTE and offset, so if I load "prog1.bin" to virtual address 0x00004000, and then want to load "prog2.bin" and map it to the same virtual address, EIP (let's say they're both plain binary files) will point for both to 0x00004000! This means that when the processor wants to find the physical address, it loads PDE 0, PTE 1, and offset 0 for both, and will point to the same physical location.. What am I missing?

Re: paging and process mapping

Posted: Sun Jun 27, 2010 5:29 am
by Combuster
What you are missing is that the linear-to-physical mappings for each process is by design required to be different. So two processes can't use the exact same set of page tables or page directories - if it would it would be the same process.

Re: paging and process mapping

Posted: Sun Jun 27, 2010 5:53 am
by Velko
Yes, you create a separate page directory for every process. And also separate page tables.

You work with your processes one-at-a-time. Load CR3 with address of prog1.bin's PD, let it run for a some time. Then reload CR3 with address of prog2.bin's PD. Since this is different PD along with different PTs, now the same virtual addresses points to different physical addresses.

Physical addresses are about what is in your PDs and PTs, virtual addresses - where it is in your paging structures.

Re: paging and process mapping

Posted: Sun Jun 27, 2010 6:04 am
by icecoder
Combuster wrote:What you are missing is that the linear-to-physical mappings for each process is by design required to be different. So two processes can't use the exact same set of page tables or page directories - if it would it would be the same process.
Thank you, now it makes really more sense. I've just realized I searched the wrong places.. cr3 must also be saved during context switches.

Re: paging and process mapping

Posted: Sun Jun 27, 2010 6:05 am
by icecoder
Velko wrote:Yes, you create a separate page directory for every process. And also separate page tables.

You work with your processes one-at-a-time. Load CR3 with address of prog1.bin's PD, let it run for a some time. Then reload CR3 with address of prog2.bin's PD. Since this is different PD along with different PTs, now the same virtual addresses points to different physical addresses.

Physical addresses are about what is in your PDs and PTs, virtual addresses - where it is in your paging structures.
Yes, that's what I was missing. Thank you so much for your help.