Re: Re: _pa/virt_to_phys and __va/phys_to_virt

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

 



On 7/24/05, mark brown <markbrowni1000@xxxxxxxxx> wrote:

> 
> if you call kmalloc, it gives you a virtual addr. That
> address is constructed by adding PAGE_OFFSET to the
> founded phys addr. and kmalloc returns this addr to
> the caller. I looked at kmalloc func. and didnt see
> this "adding stuff". Perhaps there is a different
> mechanism instead of adding. I dont know. I am
> wondering only this adding stuff.
> 

I havn't looked what kmalloc do, but I can say that the memory
allocation and virtual/physical address mappings are done using page
tables which are built during the boot time (I think it starts from
init_page function in arch/i386/mm/init.c) and the virtual address we
got from memory allocation functions is actually mappings for the page
tables to finally point to the page table entry (PTE) which tells
processor about the physical address ...........

I want to make this more clear that processor in protected / paging
enabled mode not deals with the physical addresses rather it takes the
virtual address and then through the page global table entry address
which was loaded in CR3 register, it moves along the table entries and
then finally reach required to the PTE entry from where if takes
24bits and then adds the 12-LSBs from the virtual address to this PTE
entry to generate the corresponding physical address .....

If the above explaination is not clear to u then u can consult Intel's
IA32 System Programming Guide's Chapter 3 or so ...........

-- 
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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