public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] do not try to sync identity map for non-mapped pages
@ 2013-03-07 16:31 Dave Hansen
  2013-03-07 21:59 ` [tip:x86/urgent] x86: Do " tip-bot for Dave Hansen
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Dave Hansen @ 2013-03-07 16:31 UTC (permalink / raw)
  To: linux-kernel
  Cc: bp, hpa, penguin-kernel, x86, akpm, suresh.b.siddha, khlebnikov,
	bhelgaas, Dave Hansen


The original bug reporter says this fixes it for him, so I'm
broadening the cc list a bit.  I assume this should just get
sucked in to the x86 tree.

The double-signed-off-by from my is because my IBM email is
going away very shortly.

--

kernel_map_sync_memtype() is called from a variety of contexts.  The
pat.c code that calls it seems to ensure that it is not called for
non-ram areas by checking via pat_pagerange_is_ram().  It is important
that it only be called on the actual identity map because there *IS*
no map to sync for highmem pages, or for memory holes.

The ioremap.c uses are not as careful as those from pat.c, and call
kernel_map_sync_memtype() on PCI space which is in the middle of the
kernel identity map _range_, but is not actually mapped.

This patch adds a check to kernel_map_sync_memtype() which probably
duplicates some of the checks already in pat.c.  But, it is necessary
for the ioremap.c uses and shouldn't hurt other callers.

I have reproduced this bug and this patch fixes it for me and the
original bug reporter:

	https://lkml.org/lkml/2013/2/5/396

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
Signed-off-by: Dave Hansen <dave@sr71.net>
Tested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
---

 linux-2.6.git-dave/arch/x86/mm/pat.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -puN arch/x86/mm/pat.c~dont-flush-map-for-non-ram-pages arch/x86/mm/pat.c
--- linux-2.6.git/arch/x86/mm/pat.c~dont-flush-map-for-non-ram-pages	2013-03-07 08:14:10.065558743 -0800
+++ linux-2.6.git-dave/arch/x86/mm/pat.c	2013-03-07 08:14:10.069558781 -0800
@@ -563,6 +563,13 @@ int kernel_map_sync_memtype(u64 base, un
 	if (base > __pa(high_memory-1))
 		return 0;
 
+	/*
+	 * some areas in the middle of the kernel identity range
+	 * are not mapped, like the PCI space.
+	 */
+	if (!page_is_ram(base >> PAGE_SHIFT))
+		return 0;
+
 	id_sz = (__pa(high_memory-1) <= base + size) ?
 				__pa(high_memory) - base :
 				size;
_


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH] do not try to sync identity map for non-mapped pages
@ 2013-03-06 23:10 Dave Hansen
  2013-03-07 10:19 ` Tetsuo Handa
  0 siblings, 1 reply; 10+ messages in thread
From: Dave Hansen @ 2013-03-06 23:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: bp, hpa, penguin-kernel, Dave Hansen


kernel_map_sync_memtype() is called from a variety of contexts.  The
pat.c code that calls it seems to ensure that it is not called for
non-ram areas by checking via pat_pagerange_is_ram().  It is important
that it only be called on the actual identity map because there *IS*
no map to sync for highmem pages, or for memory holes.

The ioremap.c uses are not as careful as those from pat.c, and call
kernel_map_sync_memtype() on PCI space which is in the middle of the
kernel identity map _range_, but is not actually mapped.

This patch adds a check to kernel_map_sync_memtype() which probably
duplicates some of the checks already in pat.c.  But, it is necessary
for the ioremap.c uses and shouldn't hurt other callers.

I have reproduced this bug and this patch fixes it for me

	https://lkml.org/lkml/2013/2/5/396

Signed-off-by: Dave Hansen <dave@linux.vnet.ibm.com>
---

 linux-2.6.git-dave/arch/x86/mm/pat.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff -puN arch/x86/mm/pat.c~dont-flush-map-for-non-ram-pages arch/x86/mm/pat.c
--- linux-2.6.git/arch/x86/mm/pat.c~dont-flush-map-for-non-ram-pages	2013-03-06 15:03:56.403628100 -0800
+++ linux-2.6.git-dave/arch/x86/mm/pat.c	2013-03-06 15:03:56.419628258 -0800
@@ -563,6 +563,13 @@ int kernel_map_sync_memtype(u64 base, un
 	if (base > __pa(high_memory-1))
 		return 0;
 
+	/*
+	 * some areas in the middle of the kernel identity range
+	 * are not mapped, like the PCI space.
+	 */
+	if (!page_is_ram(base >> PAGE_SHIFT))
+		return 0;
+
 	id_sz = (__pa(high_memory-1) <= base + size) ?
 				__pa(high_memory) - base :
 				size;
diff -puN arch/x86/mm/ioremap.c~dont-flush-map-for-non-ram-pages arch/x86/mm/ioremap.c
_


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-04-08 20:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-07 16:31 [PATCH] do not try to sync identity map for non-mapped pages Dave Hansen
2013-03-07 21:59 ` [tip:x86/urgent] x86: Do " tip-bot for Dave Hansen
2013-03-07 22:05 ` [PATCH] do " Tetsuo Handa
2013-03-07 22:13   ` H. Peter Anvin
2013-04-07 13:33 ` Borislav Petkov
2013-04-07 16:34   ` H. Peter Anvin
2013-04-07 17:25     ` Borislav Petkov
2013-04-08 20:33     ` Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2013-03-06 23:10 Dave Hansen
2013-03-07 10:19 ` Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox