All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] MIPS: Fix HIGHMEM crash in __update_cache().
@ 2015-04-10 13:21 Lars Persson
  2015-04-10 13:47 ` Ralf Baechle
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Persson @ 2015-04-10 13:21 UTC (permalink / raw)
  To: ralf, paul.burton; +Cc: linux-mips, linux-kernel, Lars Persson

Commit 8b5fe5e54b47 ("MIPS: Fix race condition in lazy cache flushing.")
triggered NULL pointer dereferences on systems with HIGHMEM.

The problem was caused by not clearing the PG_dcache_dirty flag in
flush_icache_page() and thus we enter __update_cache() that lacks
support for HIGHMEM.

Signed-off-by: Lars Persson <larper@axis.com>
---
 arch/mips/include/asm/cacheflush.h |    7 +++++--
 arch/mips/mm/cache.c               |   12 ++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/cacheflush.h b/arch/mips/include/asm/cacheflush.h
index 37d5cf9..723229f 100644
--- a/arch/mips/include/asm/cacheflush.h
+++ b/arch/mips/include/asm/cacheflush.h
@@ -51,6 +51,7 @@ extern void (*flush_cache_range)(struct vm_area_struct *vma,
 	unsigned long start, unsigned long end);
 extern void (*flush_cache_page)(struct vm_area_struct *vma, unsigned long page, unsigned long pfn);
 extern void __flush_dcache_page(struct page *page);
+extern void __flush_icache_page(struct vm_area_struct *vma, struct page *page);
 
 #define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 1
 static inline void flush_dcache_page(struct page *page)
@@ -77,8 +78,10 @@ static inline void flush_icache_page(struct vm_area_struct *vma,
 	struct page *page)
 {
 	if (!cpu_has_ic_fills_f_dc && (vma->vm_flags & VM_EXEC) &&
-	    Page_dcache_dirty(page))
-		__flush_dcache_page(page);
+	    Page_dcache_dirty(page)) {
+		__flush_icache_page(vma, page);
+		ClearPageDcacheDirty(page);
+	}
 }
 
 extern void (*flush_icache_range)(unsigned long start, unsigned long end);
diff --git a/arch/mips/mm/cache.c b/arch/mips/mm/cache.c
index f7b91d3..77d96db 100644
--- a/arch/mips/mm/cache.c
+++ b/arch/mips/mm/cache.c
@@ -119,6 +119,18 @@ void __flush_anon_page(struct page *page, unsigned long vmaddr)
 
 EXPORT_SYMBOL(__flush_anon_page);
 
+void __flush_icache_page(struct vm_area_struct *vma, struct page *page)
+{
+	unsigned long addr;
+
+	if (PageHighMem(page))
+		return;
+
+	addr = (unsigned long) page_address(page);
+	flush_data_cache_page(addr);
+}
+EXPORT_SYMBOL_GPL(__flush_icache_page);
+
 void __update_cache(struct vm_area_struct *vma, unsigned long address,
 	pte_t pte)
 {
-- 
1.7.10.4


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

* Re: [PATCH] MIPS: Fix HIGHMEM crash in __update_cache().
  2015-04-10 13:21 [PATCH] MIPS: Fix HIGHMEM crash in __update_cache() Lars Persson
@ 2015-04-10 13:47 ` Ralf Baechle
  2015-04-10 14:31   ` Lars Persson
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2015-04-10 13:47 UTC (permalink / raw)
  To: Lars Persson; +Cc: paul.burton, linux-mips, linux-kernel, Lars Persson

On Fri, Apr 10, 2015 at 03:21:24PM +0200, Lars Persson wrote:

> Commit 8b5fe5e54b47 ("MIPS: Fix race condition in lazy cache flushing.")
> triggered NULL pointer dereferences on systems with HIGHMEM.
> 
> The problem was caused by not clearing the PG_dcache_dirty flag in
> flush_icache_page() and thus we enter __update_cache() that lacks
> support for HIGHMEM.

Thanks, I've folded this patch into the original 8b5fe5e54b47 commit.

  Ralf

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

* Re: [PATCH] MIPS: Fix HIGHMEM crash in __update_cache().
  2015-04-10 13:47 ` Ralf Baechle
@ 2015-04-10 14:31   ` Lars Persson
  2015-04-13 17:08     ` Steven J. Hill
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Persson @ 2015-04-10 14:31 UTC (permalink / raw)
  To: Ralf Baechle; +Cc: Lars Persson, paul.burton, linux-mips, linux-kernel

Ralf,

I came to think that also non-executable mappings for highmem pages could reach the flushing code in __update_cache() and trigger an OOPS.

Until the highmem patches are merged we should block highmem pages in __update_cache().  Could you add this to the patch ?

Sent from my iPhone

> 10 apr 2015 kl. 15:47 skrev Ralf Baechle <ralf@linux-mips.org>:
> 
>> On Fri, Apr 10, 2015 at 03:21:24PM +0200, Lars Persson wrote:
>> 
>> Commit 8b5fe5e54b47 ("MIPS: Fix race condition in lazy cache flushing.")
>> triggered NULL pointer dereferences on systems with HIGHMEM.
>> 
>> The problem was caused by not clearing the PG_dcache_dirty flag in
>> flush_icache_page() and thus we enter __update_cache() that lacks
>> support for HIGHMEM.
> 
> Thanks, I've folded this patch into the original 8b5fe5e54b47 commit.
> 
>  Ralf

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

* Re: [PATCH] MIPS: Fix HIGHMEM crash in __update_cache().
  2015-04-10 14:31   ` Lars Persson
@ 2015-04-13 17:08     ` Steven J. Hill
  2015-04-14  7:30       ` Lars Persson
  0 siblings, 1 reply; 5+ messages in thread
From: Steven J. Hill @ 2015-04-13 17:08 UTC (permalink / raw)
  To: Lars Persson; +Cc: linux-mips

On 04/10/2015 09:31 AM, Lars Persson wrote:
> Ralf,
> 
> I came to think that also non-executable mappings for highmem pages
> could reach the flushing code in __update_cache() and trigger an
> OOPS.
> 
> Until the highmem patches are merged we should block highmem pages in
> __update_cache().  Could you add this to the patch ?
> 
> Sent from my iPhone
> 
Did you look at the patches:

   http://patchwork.linux-mips.org/patch/9284/
   http://patchwork.linux-mips.org/patch/9285/

Your patch seems rather similar to what is found in these. I have been
trying to get these accepted, but so far no luck.

Steve

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

* Re: [PATCH] MIPS: Fix HIGHMEM crash in __update_cache().
  2015-04-13 17:08     ` Steven J. Hill
@ 2015-04-14  7:30       ` Lars Persson
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Persson @ 2015-04-14  7:30 UTC (permalink / raw)
  To: Steven J. Hill; +Cc: linux-mips

On Mon, 2015-04-13 at 19:08 +0200, Steven J. Hill wrote:
> On 04/10/2015 09:31 AM, Lars Persson wrote:
> > Ralf,
> > 
> > I came to think that also non-executable mappings for highmem pages
> > could reach the flushing code in __update_cache() and trigger an
> > OOPS.
> > 
> > Until the highmem patches are merged we should block highmem pages in
> > __update_cache().  Could you add this to the patch ?
> > 
> > Sent from my iPhone
> > 
> Did you look at the patches:
> 
>    http://patchwork.linux-mips.org/patch/9284/
>    http://patchwork.linux-mips.org/patch/9285/
> 
> Your patch seems rather similar to what is found in these. I have been
> trying to get these accepted, but so far no luck.
> 
> Steve


Yes I would like to see these patches merged, they are the ones I
referred to above as "the highmem patches". I think you solve all the
highmem problems that I have observed, except for the icache coherency
race condition that is the main focus of my patch.

If you rebase your patches on top of mine I would be happy to assist
with test and reviewing. 

- Lars

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

end of thread, other threads:[~2015-04-14  7:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-10 13:21 [PATCH] MIPS: Fix HIGHMEM crash in __update_cache() Lars Persson
2015-04-10 13:47 ` Ralf Baechle
2015-04-10 14:31   ` Lars Persson
2015-04-13 17:08     ` Steven J. Hill
2015-04-14  7:30       ` Lars Persson

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.