Re: "x86-64, mm: Put early page table high" causes crash on Xen

From: Stefano Stabellini
Date: Tue Mar 08 2011 - 12:41:19 EST


On Tue, 8 Mar 2011, Yinghai Lu wrote:
> On Tue, Mar 8, 2011 at 4:14 AM, Stefano Stabellini
> <stefano.stabellini@xxxxxxxxxxxxx> wrote:
> >> > [ Â Â0.000000] DEBUG alloc low page(cf965000, 00001000)
> >>
> >> these are not mapped yet, and need to use early_ioremap.
> >
> > In fact we are mapping them inside alloc_low_page. No need for
> > map_low_page, right?
>
> alloc_low_page return virtual address, but it can not be used to
> access that position right away.
> so in that case map_low_page is used to convert that virtual address
> to phy address and then to early map address.

Are you sure?
I am looking at this piece of code under kernel_physical_mapping_init:


---
pud = alloc_low_page(&pud_phys);
last_map_addr = phys_pud_init(pud, __pa(start), __pa(next),
page_size_mask);
unmap_low_page(pud);
---

and the implementaion of alloc_low_page is:

---
static __ref void *alloc_low_page(unsigned long *phys)
{
unsigned long pfn = pgt_buf_end++;
void *adr;

if (after_bootmem) {
adr = (void *)get_zeroed_page(GFP_ATOMIC | __GFP_NOTRACK);
*phys = __pa(adr);

return adr;
}

if (pfn >= pgt_buf_top)
panic("alloc_low_page: ran out of memory");

adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
clear_page(adr);
*phys = pfn * PAGE_SIZE;
return adr;
}
---

It looks to me that map_low_page is never called in this code path.
If I read the code correctly map_low_page is only used to map pagetable
pages that are already mapped (see the debug logging I posted in the
previous email) so it is not useful.