The problem with trying to explain exactly how address translation is done
is that it varies from machine to machine.
On a current x86 CPU address translation is done by taking the segment
register and offset register and computing the linear address. In Windows,
that linear address is the virtual address. The CPU then first looks in a
page translation cache it maintains (the “translation lookaside buffer”) to
see if it already knows the virtual to physical page translation. If there
is no entry in the cache, it then uses the physical address in the CR3
register as the base address of the page tables.
The format of the page tables is defined by the x86 processor. You’d think
it would be simple, but it isn’t. For a typical machine (that is, an x86
that is not using some of the unusual options) the CR3 is the address of the
page directory. There are 1024 entries, with each entry being 4 bytes long.
Each 4 byte entry can address a single page (it uses 20 bits for this, the
other bits are control information). That new page is a “page table”. A
single page table consists of 1024 entries, each being 4 bytes long. Each
entry can address a single page (again, using 20 bits to do it). If it does
address a page, that is actually the page containing the data.
So, if you have a 32 bit linear address, the 10 most significant bits are
used to find the correct entry in the page directory (since 2^10 = 1024).
The next 10 bits are used to find the correct entry in the page table
(again, 2^10 = 1024). That means you have the low 12 bits - and 2^12 is
4096, the exact size of one page. So the low 12 bits of the address are
used to find the correct BYTE on the page.
One of the control bits in both the page directory as well as the page table
is the “Valid” bit. If this bit is cleared, it tells the hardware that the
entry is NOT valid, which will cause a page fault. If this bit is set, it
tells the hardware that the entry is valid, so that it may use the 20 bits
that represent a page address.
Again, please note that I restricted my example to one specific case of the
x86. The process is SIMILAR in other cases. For example, the AMD-64 in
LONLONG mode uses five levels of translation in its page tables and each
entry is 8 bytes. The IA-64 uses 8 byte entries and pages are 8KB.
I hope this helps.
Regards,
Tony
Tony Mason
Consulting Partner
OSR Open Systems Resources, Inc.
http://www.osr.com
-----Original Message-----
From: Naushahi [mailto:xxxxx@hotmail.com]
Sent: Wednesday, May 14, 2003 12:56 AM
To: NT Developers Interest List
Subject: [ntdev] Re: “Page Fault article” how H/W translate address
Hi, Walter Oney
thanx for reply. i Found this article from OSROnline, to give the
reference i am pasting this
So What Is A Page Fault?
OSR Staff | Published: 06-May-03| Modified: 07-May-03
may u read this in detail to get concept.
another thing u say “address translation hardware”. is there any physical
programe code hardware? with it operating system and CPU interact for
address tanslation, explain about this.
thankx with regard
Naushahi
You are currently subscribed to ntdev as: xxxxx@osr.com
To unsubscribe send a blank email to xxxxx@lists.osr.com