Re: Translating Linear Address to Physical

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/2/06, Doron Bleiberg <kernel.doron@xxxxxxxxx> wrote:
Hi,
I'm heaving difficulties understanding the way Linux translate linear address into physical one. Let me spread out my understanding of the process, and please correct me where I'm wrong !!! and explain me what I miss !!!

1) Linux uses the same base address (0x0) for both CS and DS. Each segment spans 4MB of memory.
2) Given logical address (i.e SEG:OFFSET) the segment is used as an index to an entry either in the GDT or LDT
3) The system then takes the base address noted in the segment descriptor (pointed by the given selector) and adds it the offset from earlier step. Considering base address is always 0x0, we get that the offset is our linear address under all circumstances.
4) At this point we take our linear address (which is effectively our offset) and translate it using paging mechanism. 10 bit for directory index, 10 bits for page table and 12 bits for offset within the page.

What I don't understand is how can we manage the linear address to 'have the right value' such that the paging will work as we expect it to. After all we take the offset and split it into (10, 10, 12) bits values. How can I be sure that this split will work and the given page directory, page table and page offset will have the correct values? What makes this magic works?


--
Respectfully yours,

Doron Bleiberg
E-Mail: kernel.doron@xxxxxxxxx


Not sure if that what you ment but...
Linux provides a few macros and functions to handle the page tables. The first set of
functions are used for the navigation and examination of the page table entries. For
example, pgd_offset(), pmd_offset() and pte_offset() enable to 'walk'
the page table and reach the physical page pointed by a specific virtual address. The
second set of functions are used to translate and set the page table entries as mk_pte()
and set_pte(). These functions update the page table entries and form a new entry.
The last set of functions deal with the allocation and freeing of page table using functions
as pgd_alloc() and pgd_free(). you may want to check mm/vmalloc.c to actually see how a virtual address space is allocated and mapped to a physical one.
Eliad.
http://www.eliad.net



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux