Skip to content

Commit 2ded5fe

Browse files
Alexandre Ghitiakpm00
authored andcommitted
mm: add a call to flush_cache_vmap() in vmap_pfn()
flush_cache_vmap() must be called after new vmalloc mappings are installed in the page table in order to allow architectures to make sure the new mapping is visible. It could lead to a panic since on some architectures (like powerpc), the page table walker could see the wrong pte value and trigger a spurious page fault that can not be resolved (see commit f1cb8f9 ("powerpc/64s/radix: avoid ptesync after set_pte and ptep_set_access_flags")). But actually the patch is aiming at riscv: the riscv specification allows the caching of invalid entries in the TLB, and since we recently removed the vmalloc page fault handling, we now need to emit a tlb shootdown whenever a new vmalloc mapping is emitted (https://lore.kernel.org/linux-riscv/[email protected]/). That's a temporary solution, there are ways to avoid that :) Link: https://lkml.kernel.org/r/[email protected] Fixes: 3e9a9e2 ("mm: add a vmap_pfn function") Reported-by: Dylan Jhong <[email protected]> Closes: https://lore.kernel.org/linux-riscv/[email protected]/ Signed-off-by: Alexandre Ghiti <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Acked-by: Palmer Dabbelt <[email protected]> Reviewed-by: Dylan Jhong <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent e8662dd commit 2ded5fe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mm/vmalloc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2979,6 +2979,10 @@ void *vmap_pfn(unsigned long *pfns, unsigned int count, pgprot_t prot)
29792979
free_vm_area(area);
29802980
return NULL;
29812981
}
2982+
2983+
flush_cache_vmap((unsigned long)area->addr,
2984+
(unsigned long)area->addr + count * PAGE_SIZE);
2985+
29822986
return area->addr;
29832987
}
29842988
EXPORT_SYMBOL_GPL(vmap_pfn);

0 commit comments

Comments
 (0)