Skip to content

Commit ff5bc79

Browse files
npigginmpe
authored andcommitted
powerpc/64s/radix: Fix missing ptesync in flush_cache_vmap
There is a typo in f1cb8f9 ("powerpc/64s/radix: avoid ptesync after set_pte and ptep_set_access_flags") config ifdef, which results in the necessary ptesync not being issued after vmalloc. This causes random kernel faults in module load, bpf load, anywhere that vmalloc mappings are used. After correcting the code, this survives a guest kernel booting hundreds of times where previously there would be a crash every few boots (I haven't noticed the crash on host, perhaps due to different TLB and page table walking behaviour in hardware). A memory clobber is also added to the flush, just to be sure it won't be reordered with the pte set or the subsequent mapping access. Fixes: f1cb8f9 ("powerpc/64s/radix: avoid ptesync after set_pte and ptep_set_access_flags") Signed-off-by: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 0a4ec6a commit ff5bc79

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/powerpc/include/asm/cacheflush.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,17 @@
2323
#define flush_cache_range(vma, start, end) do { } while (0)
2424
#define flush_cache_page(vma, vmaddr, pfn) do { } while (0)
2525
#define flush_icache_page(vma, page) do { } while (0)
26-
#define flush_cache_vmap(start, end) do { } while (0)
2726
#define flush_cache_vunmap(start, end) do { } while (0)
2827

29-
#ifdef CONFIG_BOOK3S_64
28+
#ifdef CONFIG_PPC_BOOK3S_64
3029
/*
3130
* Book3s has no ptesync after setting a pte, so without this ptesync it's
3231
* possible for a kernel virtual mapping access to return a spurious fault
3332
* if it's accessed right after the pte is set. The page fault handler does
3433
* not expect this type of fault. flush_cache_vmap is not exactly the right
3534
* place to put this, but it seems to work well enough.
3635
*/
37-
#define flush_cache_vmap(start, end) do { asm volatile("ptesync"); } while (0)
36+
#define flush_cache_vmap(start, end) do { asm volatile("ptesync" ::: "memory"); } while (0)
3837
#else
3938
#define flush_cache_vmap(start, end) do { } while (0)
4039
#endif

0 commit comments

Comments
 (0)