Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Confused with Page Directory self-mapping

303 views
Skip to first unread message

Christopher Jackson

unread,
Oct 3, 2002, 7:23:27 PM10/3/02
to
In some tutorials on OS development, I came acrossed a few that
discussed ever-so-lightly about using the last entry of a Page
Directory to map back to the physical address of the Directory itself.

Granted, many aspects of OS-dev can easily spin one's head, but this
one has taken me far beyond the spinning point.

May I inquire of you to clear my head by explaining 3 points of this:

1) Why would one do this.. what will it accomplish?

2) What other benifits might one reap?

3) What dis-advantages { other than this confusion } might one run up
against?


My thanks in advance,

Christopher.


P.S. In reply to your answer, I am likely to ask about alternatives
to this method, as well as discuss the efficiences of each.

Thanks once again.

Chris Fallin

unread,
Oct 3, 2002, 8:51:07 PM10/3/02
to
On Thu, 03 Oct 2002 16:23:27 -0700, Christopher Jackson wrote:

> In some tutorials on OS development, I came acrossed a few that
> discussed ever-so-lightly about using the last entry of a Page Directory
> to map back to the physical address of the Directory itself.

> 1) Why would one do this.. what will it accomplish?

It will give you a 4MB region of linear space that is an array of all
PTEs. This happens because the page directory contains addresses of page
tables; when the pdir is used as a ptab then the ptab pointers become page
frame pointers, thus each present page table becomes a page in the linear
space. This will also give you a page in linear space that is the page
directory. Think about it from the perspective of the MMU - follow the
pointers in the tables like it would, and I think it'll clear up your
confusion.



> 2) What other benifits might one reap?

Easy access to the PTEs and PDEs, without having to have access to the
physical memory directly. You can also map in other address spaces' page
directories as page tables, allowing you to manipulate another processes'
address space.

> 3) What dis-advantages { other than this confusion } might one run up
> against?

Not many, really. The only thing to watch out for is that not-present page
tables will give not-present pages in the 4MB region.

Hope this helps

--
Chris Fallin
Email : ch...@cfallin.org
speck OS: http://speck.cfallin.org/

Maxim S. Shatskih

unread,
Oct 4, 2002, 4:24:13 PM10/4/02
to
> 1) Why would one do this.. what will it accomplish?

Automatic mapping of PTE tables to some virtual addresses.

> 3) What dis-advantages { other than this confusion } might one run
up
> against?

I see no of them. All OSes known to me use this - though not necessary
the last PTE, maybe, say, PTE #768.

Max

Christopher Jackson

unread,
Oct 6, 2002, 10:51:34 AM10/6/02
to
Chris, Max,

Thank you both for your input.

Yes, I can see why the self-mapping would not *have* to be the last
entry, as moving the self-mapping to another point in the Dir would
move the PDE as PTE, to just another place in the Virt. Address
space... correct??

Are there currently any other alternatives to this method??

Thanks again,

Christopher.

Marven Lee

unread,
Oct 6, 2002, 12:40:35 PM10/6/02
to

Christopher Jackson wrote...

Yes, by using 2 page directories per process.

Allocate 2 page directories per process and map them
somewhere in the kernel virtual memory area.

The 'real' page directory is used by the processor and
contains the flags and the physical addresses of the page
tables.

The 'virtual' page directory is used to find the location
of the page tables in the kernel's virtual memory area.

Whenever a page table is allocated map it into the
kernel virtual memory area.

Set the entry in the 'real' page directory to its physical
address. Set the entry in the 'virtual' page directory to
the virtual address it was mapped into the kernel virtual
memory area.

The page tables and directories of all processes will
be visible within the kernel area of memory.

Do a search of Google Groups for "virtual page directory"
"real page directory", or "KernelPage". I've explained it
in a previous post in more detail.

Marv


0 new messages