[v6 PATCH] riscv: mm: execute local TLB flush after populating vmemmap

Lad, Prabhakar prabhakar.csengg at gmail.com
Tue Jan 30 13:38:53 PST 2024


Hi Alexandre,

On Tue, Jan 30, 2024 at 10:59 AM Alexandre Ghiti <alexghiti at rivosinc.com> wrote:
>
> Hi Prabhakar,
>
> On Tue, Jan 30, 2024 at 10:59 AM Lad, Prabhakar
> <prabhakar.csengg at gmail.com> wrote:
> >
> > Hi Vincent,
> >
> > Thank you for the patch.
> >
> > On Wed, Jan 17, 2024 at 2:07 PM Vincent Chen <vincent.chen at sifive.com> wrote:
> > >
> > > The spare_init() calls memmap_populate() many times to create VA to PA
> > > mapping for the VMEMMAP area, where all "struct page" are located once
> > > CONFIG_SPARSEMEM_VMEMMAP is defined. These "struct page" are later
> > > initialized in the zone_sizes_init() function. However, during this
> > > process, no sfence.vma instruction is executed for this VMEMMAP area.
> > > This omission may cause the hart to fail to perform page table walk
> > > because some data related to the address translation is invisible to the
> > > hart. To solve this issue, the local_flush_tlb_kernel_range() is called
> > > right after the sparse_init() to execute a sfence.vma instruction for this
> > > VMEMMAP area, ensuring that all data related to the address translation
> > > is visible to the hart.
> > >
> > > Fixes: d95f1a542c3d ("RISC-V: Implement sparsemem")
> > > Signed-off-by: Vincent Chen <vincent.chen at sifive.com>
> > > Reviewed-by: Alexandre Ghiti <alexghiti at rivosinc.com>
> > > ---
> > >  arch/riscv/include/asm/tlbflush.h | 2 ++
> > >  arch/riscv/mm/init.c              | 5 +++++
> > >  arch/riscv/mm/tlbflush.c          | 6 ++++++
> > >  3 files changed, 13 insertions(+)
> > >
> > I get below build issue with this patch applied:
> >
> > arch/riscv/mm/tlbflush.c:207:6: error: redefinition of
> > 'local_flush_tlb_kernel_range'
> >   207 | void local_flush_tlb_kernel_range(unsigned long start,
> > unsigned long end)
> >       |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > arch/riscv/mm/tlbflush.c:69:6: note: previous definition of
> > 'local_flush_tlb_kernel_range' with type 'void(long unsigned int,
> > long unsigned int)'
> >    69 | void local_flush_tlb_kernel_range(unsigned long start,
> > unsigned long end)
> >       |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > make[4]: *** [scripts/Makefile.build:243: arch/riscv/mm/tlbflush.o] Error 1
> > make[4]: *** Waiting for unfinished jobs....
> >   CC      kernel/resource.o
> > make[3]: *** [scripts/Makefile.build:481: arch/riscv/mm] Error 2
> > make[3]: *** Waiting for unfinished jobs....
> >
> > I have attached the defconfig file.
> >
>
> Indeed, we recently added the same function, you can find a rebased
> version of this patch on top of 6.8 here:
> https://github.com/AlexGhiti/linux-riscv/commit/756d1871f58edac455773db0bb996f8d064a6b06
>
Thanks for the pointer.

Cheers,
Prabhakar



More information about the linux-riscv mailing list