Re: [PATCH -fixes] mm: Add a call to flush_cache_vmap() in vmap_pfn()

From: Alexandre Ghiti
Date: Thu Aug 10 2023 - 03:15:23 EST


Hi Andrew,

On Wed, Aug 9, 2023 at 8:46 PM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, 9 Aug 2023 18:46:33 +0200 Alexandre Ghiti <alexghiti@xxxxxxxxxxxx> wrote:
>
> > 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.
>
> Thanks. What are the user-visible effects of this bug?

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 f1cb8f9beba8
("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/20230725132246.817726-1-alexghiti@xxxxxxxxxxxx/).
That's a temporary solution, there are ways to avoid that :)

Thanks,

Alex