Re: x86 pages, page tables, and page table entries

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

 



On Jan 22, 2008 10:31 AM, Vegard Nossum <vegard.nossum@xxxxxxxxx> wrote:
> On Jan 21, 2008 11:43 PM, Vegard Nossum <vegard.nossum@xxxxxxxxx> wrote:
> > Hi,
> >
> > I am experiencing something strange about pages and ptes on x86. I am
> > calling alloc_pages() with order = 1 (should be 2 pages). This returns
> > a struct page with virtual address c7800000 (returned by
> > page_address()). Now I call lookup_address() on the same address, and
> > the pte is located at c0438c78. So far, so good. But if I try to call
> > lookup_address() on the next page (i.e. address 7801000), this returns
> > a pte which is located at c7800004. How can this happen? This would
> > mean that the pte is inside the previous page, which is nonsense,
> > since it was just returned to me by the page allocator.
>
> I will follow up to say that it was my own code that changed the pte.
> My code was based on the (invalid) assumption that all pages have
> different pte_t*s.
>
> Why don't all pages have different pte_t*s? Take the following code:
>
>                 struct page *pga, *pgb;
>                 pga = alloc_pages(flags, 0);
>                 pgb = alloc_pages(flags, 0);
>                 printk("pte for %08x = %p\n", page_address(pga),
> lookup_address(page_address(pga)));
>                 printk("pte for %08x = %p\n", page_address(pgb),
> lookup_address(page_address(pgb)));
>
> It allocates two pages and prints out the virtual address of the page
> itself, then the pte_t* of that address. When run, I get this:
>
> pte for c7802000 = c0438c78
> pte for c7803000 = c0438c78
>
> So it seems that the two pages actually share a pte. How is this
> possible? Am I using lookup_address() wrongly?

Further investigations indicate that the pte returned by
lookup_address() is not a pte, but a huge pmd. Now: Is there a way to
allocate pages such that each page allocated has its own, separate
pte?

Thanks.

Vegard

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