I'm tring to setup a recursive page directory and was wondering, do I have to completly map
the last page table and pages? I would think so but this paging has been realy hard for me
to totally understand and I'm not sure.
Thank You
Bo Hunter
recursive page directory?
Re: recursive page directory?
If you're new to paging and finding it hard to grasp, it might be easier to not use the so-called 'recursive' pgdir straight away. It certainly is a good 'trick', and can be used without understanding how it works, but it's not necessarily the best way if you're still in learning mode.
If a trainstation is where trains stop, what is a workstation ?
Re: recursive page directory?
It's simple. You must have one self link in page dir. Just one important point: you should protect kernel on PDE level, else user space will be invalid.
If you have seen bad English in my words, tell me what's wrong, please.
-
- Posts: 9
- Joined: Tue Sep 14, 2010 5:13 pm
Re: recursive page directory?
"Just one important point: you should protect kernel on PDE level, else user space will be invalid."
You mean I should set pagetable to present,rw only for the pagetable that the kernel is mapped?
What do you mean that user pace will be invalid. I know what userspace is, I just don't know what
you mean by invalid.
Thank You
Bo Hunter
You mean I should set pagetable to present,rw only for the pagetable that the kernel is mapped?
What do you mean that user pace will be invalid. I know what userspace is, I just don't know what
you mean by invalid.
Thank You
Bo Hunter
Re: recursive page directory?
You must control U/S bit in self link PDE to protect full 4 mb page tab region, else page tab will be accessible from user space i.e. user space will be invalid. I missed when I said about all kernel because I use only PDE level protection.
If you have seen bad English in my words, tell me what's wrong, please.
Re: recursive page directory?
Hi,
I found the recursive page directory easier to understand if you try to calculate how the linear address translation yourself.
For example, I choose the PDE #1023 entry to link with itself
(I set just the present bit for simplification)
So, upon any access with the last 4M address, the MMU will lookup the PDE itself as a PTE entry
Now try some address,
0xFFC00000 -> the physical address is recorded on the 1st entry of the PDE, which is the page of #0 PTE entry
0xFFC10000 -> the #1 PTE
etc
0xFFFFF000 -> the #1023 entry, which is the physical address of the PDE itself.
This trick will be extremely convenient for example if you need to add a new PTE entry when you write your MM,
without recursive you may need to map the PTE somewhere else, zero/setup and un-map it.
I found the recursive page directory easier to understand if you try to calculate how the linear address translation yourself.
For example, I choose the PDE #1023 entry to link with itself
Code: Select all
mov dword [PHYADDR(PDE) + 1023*4], PHYADDR(PDE) +1
So, upon any access with the last 4M address, the MMU will lookup the PDE itself as a PTE entry
Now try some address,
0xFFC00000 -> the physical address is recorded on the 1st entry of the PDE, which is the page of #0 PTE entry
0xFFC10000 -> the #1 PTE
etc
0xFFFFF000 -> the #1023 entry, which is the physical address of the PDE itself.
This trick will be extremely convenient for example if you need to add a new PTE entry when you write your MM,
without recursive you may need to map the PTE somewhere else, zero/setup and un-map it.