Re: Why is a PA converted to a VA in pmd_page?

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

 



I think I'm finally getting the hang of this sort of thing, at least
for lowmem x86 situations, so I'll try to answer.

"Kirk True" <ktrue@movaris.com> writes:

> Hi all,
>
> In <asm>/pgtable.h, it defines the following:
>
>     323 #define pmd_page(pmd) \
>     324 ((unsigned long) __va(pmd_val(pmd) & PAGE_MASK))
>
> Why does it convert the physical address provided by pmd_val to a virtual
> one? The addresses returned from pgd_offset and pmd_offset represent a
> physical address, correct? 

I don't think so.

> Then why the switch to a virtual address for the
> pte_offset?
>
> Aren't these methods called from the kernel in the physical address space
> rather than the linear/virtual address space?
>
> I'm confused, please help ;)

In memory.c:free_one_pmd there's an example of how pmd_page is used.
It yields a pointer to the struct page in the mem_map that corresponds
to the page frame where the pmd is stored.  That pointer is a virtual
address.

On lowmem x86, for kernel data, the relationship between a virtual
address and a physical address is just the addition or subtraction of
0xC0000000.  The __va macro just adds 0xC0000000 to the physical
address.

-- 
--Ed L Cashin            |   PGP public key:
  ecashin@uga.edu        |   http://noserose.net/e/pgp/

--
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