Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PARISC] fix vmap flush/invalidate

On parisc, we never implemented invalidate_kernel_vmap_range() because
it was unnecessary for the xfs use case. However, we do need to
implement an invalidate for the opposite use case (which occurred in a
recent NFS change) where the user wants to read through the vmap range
and write via the kernel address. There's an additional complexity to
this in that if the page has no userspace mappings, it might have dirty
cache lines in the kernel (indicated by the PG_dcache_dirty bit). In
order to get full coherency, we need to flush these pages through the
kernel mapping before invalidating the vmap range.

Signed-off-by: James Bottomley <James.Bottomley@suse.de>

authored by

James Bottomley and committed by
James Bottomley
8e1964a9 100b33c8

+17 -7
+17 -7
arch/parisc/include/asm/cacheflush.h
··· 37 37 void flush_cache_all(void); 38 38 void flush_cache_mm(struct mm_struct *mm); 39 39 40 + #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 41 + void flush_kernel_dcache_page_addr(void *addr); 42 + static inline void flush_kernel_dcache_page(struct page *page) 43 + { 44 + flush_kernel_dcache_page_addr(page_address(page)); 45 + } 46 + 40 47 #define flush_kernel_dcache_range(start,size) \ 41 48 flush_kernel_dcache_range_asm((start), (start)+(size)); 42 49 /* vmap range flushes and invalidates. Architecturally, we don't need ··· 57 50 } 58 51 static inline void invalidate_kernel_vmap_range(void *vaddr, int size) 59 52 { 53 + unsigned long start = (unsigned long)vaddr; 54 + void *cursor = vaddr; 55 + 56 + for ( ; cursor < vaddr + size; cursor += PAGE_SIZE) { 57 + struct page *page = vmalloc_to_page(cursor); 58 + 59 + if (test_and_clear_bit(PG_dcache_dirty, &page->flags)) 60 + flush_kernel_dcache_page(page); 61 + } 62 + flush_kernel_dcache_range_asm(start, start + size); 60 63 } 61 64 62 65 #define flush_cache_vmap(start, end) flush_cache_all() ··· 113 96 { 114 97 if (PageAnon(page)) 115 98 flush_user_dcache_page(vmaddr); 116 - } 117 - 118 - #define ARCH_HAS_FLUSH_KERNEL_DCACHE_PAGE 119 - void flush_kernel_dcache_page_addr(void *addr); 120 - static inline void flush_kernel_dcache_page(struct page *page) 121 - { 122 - flush_kernel_dcache_page_addr(page_address(page)); 123 99 } 124 100 125 101 #ifdef CONFIG_DEBUG_RODATA