Re: Doubt regarindg Virtual Memory

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

 





On Sat, Oct 31, 2009 at 10:54 PM, Zhu Yanhai <zhu.yanhai@xxxxxxxxx> wrote:
2009/10/30 shailesh jain <coolworldofshail@xxxxxxxxx>:
> a) __pa(kaddr) : Translates kernel virtual address to physical address,
> which is just arithmetic operation subtracting PAGE_OFFSET from kaddr.
>
>
> b) #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
> above macro is giving you struct page for a corresponding virtual address.
>
> c) linear address to physical address translation is done by x86 processor
> (32 but without PAE) by doing traversal pgd->pte->page_phys_addr. OS sets up
> this entries and processor uses it.
>
> Yes, above macro is not for ZONE_HIGHMEM. Because ZONE_HIGHMEM is not
> directly mapped by kernel.
>
>
> Shailesh Jain
>
> On Fri, Oct 23, 2009 at 2:01 PM, Shameem Ahamed <shameem.ahamed@xxxxxxxxx>
> wrote:
>>
>> Hi Friends,
>>
>> Please help me to figure out some basic concepts in MM.
>>
>> From the books, i learned that VMA to PA translation consists of
>> traversing the full page directory, which consists of   Global Directory,
>> Middle Directory and Page Table.
>>
>> I have also read that, VMA to PA translation is done using a macro
>> virt_to_page  defined as given below.
>>
>> #define virt_to_page(kaddr) (mem_map + (__pa(kaddr) >> PAGE_SHIFT))
>>
>>
>> If
>> there is a macro, why we need code for traversing all the page
>> directories ?.  This macro is a simple math, which points to an index
>> in global mem_map array, which contains all the pages in the system.
>>
the macro is used by programmers, not by X86 CPU. CPU only knows the
page tables pointed by CR0.


Page table directory is pointed by CR3 register not CR0. Just FYI.
CR0 has PE bit to enable paging.

 
>>
>> So my doubts are,
>> Is the macro only for ZONE_NORMAL (upto 896M, which is directly mapped by
>> kernel)  memory pages ?.
Yes

 
>> Is mem_map array contains pages upto ZONE_NORMAL ?
No, mem_map contains all physical page frames.

>> Is page traversing happens only for HIGH_MEM ?
No, page traversing happens for every page frame that CPU wants to
visit and can't be found in TLB entries.
The point is page directory contains all page mappings, and the parts
of mapping of ZONE_NORMAL is simple
and they can be described by pa and va macros. But, CPU doesn't know
pa and va marcro, and CPU can only
find pages by page tables.
.
>>
>> Regards,
>> Shameem
>>
>>
>>
>>
>>
>> --
>> To unsubscribe from this list: send an email with
>> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
>> Please read the FAQ at http://kernelnewbies.org/FAQ
>>
>
>


[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