All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: Yinghai Lu <yinghai@kernel.org>
Cc: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>,
	"linux-kernel@vger.kernel.org" <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: Wed, 2 Mar 2011 15:23:48 +0000	[thread overview]
Message-ID: <alpine.DEB.2.00.1103021123140.2968@kaball-desktop> (raw)
In-Reply-To: <4D6D6980.7060304@kernel.org>

On Tue, 1 Mar 2011, Yinghai Lu wrote:
> 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.
 
I think I have figured out a way to update the logic of mask_rw_pte to
account for the new way of allocating kernel pagetables.
The appended patch fix the boot crash for me.

---

xen: update mask_rw_pte after kernel page tables init changes

Already existing kernel page table pages can now be mapped using
early_ioremap too so we need to update mask_rw_pte to make sure these
pages are still mapped RO.
We do that by mapping RO all the pages mapped using early_ioremap apart
from the last one that has been allocated because it is not a page table
page yet (it has been hooked into the page tables yet).

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index 62192cd..2ff68be 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -1440,10 +1440,12 @@ static __init pte_t mask_rw_pte(pte_t *ptep, pte_t pte)
 	/*
 	 * 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.
+	 * early_ioremap fixmap slot as a freshly allocated page, make sure
+	 * it is RO.
 	 */
-	if (!is_early_ioremap_ptep(ptep) &&
-	    pfn >= pgt_buf_start && pfn < pgt_buf_end)
+	if (((!is_early_ioremap_ptep(ptep) &&
+			pfn >= pgt_buf_start && pfn < pgt_buf_end)) ||
+			(is_early_ioremap_ptep(ptep) && pfn != (pgt_buf_end - 1)))
 		pte = pte_wrprotect(pte);
 
 	return pte;

  reply	other threads:[~2011-03-02 15:23 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
2011-03-02 15:23   ` Stefano Stabellini [this message]
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=alpine.DEB.2.00.1103021123140.2968@kaball-desktop \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Jeremy.Fitzhardinge@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yinghai@kernel.org \
    /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.