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

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

 



Hi Ed,

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

But the whole traversing starts with pgd_offset:

    #define pgd_offset(mm, address) ((mm)->pgd+pgd_index(address))

Isn't mm_struct's pgd a pointer to a *physical* address? Since pgd's value
is used in the cr3 register I thought you had to be a *physical* address...

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

One of the big issues I'm having is knowing when the code is using physical,
virtual, or linear address spaces.

Question: When in kernel mode, can you refer to a value/address by a
physical address *or* a virtual address and have it magically work???? If
you're running kernel code and you try to access a virtual address n, does
the MMU magically know to subtract PAGE_OFFSET from n? Otherwise, trying to
access virtual address n would result in a memory addressing error if you
had < 3 GB of physical RAM?

Please forgive my complete ignorance ;) Hopefully I'm just missing something
obvious.

Thanks,
Kirk

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