From: Yinghai Lu <yinghai@kernel.org>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: linux-kernel@vger.kernel.org,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
Jeremy Fitzhardinge <Jeremy.Fitzhardinge@citrix.com>
Subject: Re: "x86-64, mm: Put early page table high" causes crash on Xen
Date: Tue, 01 Mar 2011 13:47:44 -0800 [thread overview]
Message-ID: <4D6D6980.7060304@kernel.org> (raw)
In-Reply-To: <alpine.DEB.2.00.1103011517280.2917@kaball-desktop>
On 03/01/2011 09:21 AM, Stefano Stabellini wrote:
> Yinghai Lu,
> while testing tip/x86/mm on Xen I found out that the commit "x86-64, mm:
> Put early page table high" reliably crashes Linux at boot.
> The reason is well explained by the commit message of
> fef5ba797991f9335bcfc295942b684f9bf613a1:
>
> "Xen requires that all pages containing pagetable entries to be mapped
> read-only. If pages used for the initial pagetable are already mapped
> then we can change the mapping to RO. However, if they are initially
> unmapped, we need to make sure that when they are later mapped, they
> are also mapped RO.
>
> We do this by knowing that the kernel pagetable memory is pre-allocated
> in the range e820_table_start - e820_table_end, so any pfn within this
> range should be mapped read-only. However, the pagetable setup code
> early_ioremaps the pages to write their entries, so we must make sure
> that mappings created in the early_ioremap fixmap area are mapped RW.
> (Those mappings are removed before the pages are presented to Xen
> as pagetable pages.)"
>
> In other words mask_rw_pte (called by xen_set_pte_init) should mark RO
> the already existing pagetable pages (like the ones belonging to the
> initial mappings), while it should mark RW the new pages not yet hooked
> into the pagetable. This is what the following lines used to achieve,
> but don't anymore:
>
> /*
> * If the new pfn is within the range of the newly allocated
> * kernel pagetable, and it isn't being mapped into an
> * early_ioremap fixmap slot, make sure it is RO.
> */
> if (!is_early_ioremap_ptep(ptep) &&
> pfn >= pgt_buf_start && pfn < pgt_buf_end)
> pte = pte_wrprotect(pte);
>
> Unfortunately now we map the already existing initial pagetable pages a
> second time and the new zeroed pages using map_low_page, so we are
> unable to distinguish between the two.
>
> Can we go back to the previous way of accessing pagetable pages from
> kernel_physical_mapping_init, while keeping the new pagetable allocation
> strategy? It seems to me that the introduction of map_low_page is not
> actually required, is it? In that case we could just revert that bit...
> (appended partial revert example).
We do need map_low_page ( BTW, that name is totally misleading...)
the reason is we put page_table high and at that time is not under max_pfn_mapped. (aka not mapped).
So have to use
adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
to early map it and Read/Write to it.
Thanks
Yinghai
next prev parent reply other threads:[~2011-03-01 21:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-01 17:21 "x86-64, mm: Put early page table high" causes crash on Xen Stefano Stabellini
2011-03-01 21:47 ` Yinghai Lu [this message]
2011-03-02 15:23 ` Stefano Stabellini
2011-03-02 17:06 ` Konrad Rzeszutek Wilk
2011-03-07 15:55 ` Stefano Stabellini
2011-03-07 15:47 ` Stefano Stabellini
2011-03-07 19:17 ` Yinghai Lu
2011-03-08 12:14 ` Stefano Stabellini
2011-03-08 16:39 ` Yinghai Lu
2011-03-08 17:40 ` Stefano Stabellini
2011-03-08 18:54 ` Yinghai Lu
2011-03-08 20:09 ` Stefano Stabellini
2011-03-08 20:21 ` Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D6D6980.7060304@kernel.org \
--to=yinghai@kernel.org \
--cc=Jeremy.Fitzhardinge@citrix.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stefano.stabellini@eu.citrix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.