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?
paging and process mapping
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: paging and process mapping
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
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.
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.
If something looks overcomplicated, most likely it is.
Re: paging and process mapping
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.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.
Re: paging and process mapping
Yes, that's what I was missing. Thank you so much for your help.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.