Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=6020dff09252e3670a89edb36baaa4afb9b10d15
Commit:     6020dff09252e3670a89edb36baaa4afb9b10d15
Parent:     a6f36be32622730710b2fadacb6e2649defa4371
Author:     Russell King <[EMAIL PROTECTED]>
AuthorDate: Sat Dec 30 23:17:40 2006 +0000
Committer:  Russell King <[EMAIL PROTECTED]>
CommitDate: Mon Jan 8 19:49:58 2007 +0000

    [ARM] Resolve fuse and direct-IO failures due to missing cache flushes
    
    fuse does not work on ARM due to cache incoherency issues - fuse wants
    to use get_user_pages() to copy data from the current process into
    kernel space.  However, since this accesses userspace via the kernel
    mapping, the kernel mapping can be out of date wrt data written to
    userspace.
    
    This can lead to unpredictable behaviour (in the case of fuse) or data
    corruption for direct-IO.
    
    This resolves debian bug #402876
    
    Signed-off-by: Russell King <[EMAIL PROTECTED]>
---
 arch/arm/mm/flush.c          |   39 +++++++++++++++++++++++++++++++++++++++
 include/asm-arm/cacheflush.h |   10 ++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index 628348c..9df507d 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -202,3 +202,42 @@ void flush_dcache_page(struct page *page)
        }
 }
 EXPORT_SYMBOL(flush_dcache_page);
+
+/*
+ * Flush an anonymous page so that users of get_user_pages()
+ * can safely access the data.  The expected sequence is:
+ *
+ *  get_user_pages()
+ *    -> flush_anon_page
+ *  memcpy() to/from page
+ *  if written to page, flush_dcache_page()
+ */
+void __flush_anon_page(struct vm_area_struct *vma, struct page *page, unsigned 
long vmaddr)
+{
+       unsigned long pfn;
+
+       /* VIPT non-aliasing caches need do nothing */
+       if (cache_is_vipt_nonaliasing())
+               return;
+
+       /*
+        * Write back and invalidate userspace mapping.
+        */
+       pfn = page_to_pfn(page);
+       if (cache_is_vivt()) {
+               flush_cache_page(vma, vmaddr, pfn);
+       } else {
+               /*
+                * For aliasing VIPT, we can flush an alias of the
+                * userspace address only.
+                */
+               flush_pfn_alias(pfn, vmaddr);
+       }
+
+       /*
+        * Invalidate kernel mapping.  No data should be contained
+        * in this mapping of the page.  FIXME: this is overkill
+        * since we actually ask for a write-back and invalidate.
+        */
+       __cpuc_flush_dcache_page(page_address(page));
+}
diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h
index d510495..5f531ea 100644
--- a/include/asm-arm/cacheflush.h
+++ b/include/asm-arm/cacheflush.h
@@ -357,6 +357,16 @@ extern void flush_dcache_page(struct page *);
 
 extern void __flush_dcache_page(struct address_space *mapping, struct page 
*page);
 
+#define ARCH_HAS_FLUSH_ANON_PAGE
+static inline void flush_anon_page(struct vm_area_struct *vma,
+                        struct page *page, unsigned long vmaddr)
+{
+       extern void __flush_anon_page(struct vm_area_struct *vma,
+                               struct page *, unsigned long);
+       if (PageAnon(page))
+               __flush_anon_page(vma, page, vmaddr);
+}
+
 #define flush_dcache_mmap_lock(mapping) \
        write_lock_irq(&(mapping)->tree_lock)
 #define flush_dcache_mmap_unlock(mapping) \
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to