Re: [PATCH v5 05/11] mm/vmalloc: only flush the cache after the vmap succeeded
From: Suren Baghdasaryan
Date: Fri Nov 20 2026 - 17:24:52 EST
On Wed, Nov 18, 2026 at 7:31 PM Uladzislau Rezki <urezki@xxxxxxxxx> wrote:
>
> On Mon, Nov 16, 2026 at 03:13:19PM +0800, Hao Ge wrote:
> > vmap_page_range(), __vmap_pages_range() and vmap_pages_range_batched()
> > call flush_cache_vmap() before they even look at the error code. A
> > failed mapping is never used, so the flush is pointless at best.
> >
> > According to the Sashiko review it is worse than pointless on UML:
> > flush_cache_vmap() there is flush_tlb_kernel_range(), which syncs the
> > PTEs into the host OS. Flushing a half-installed mapping therefore
> > leaves host mappings behind for a range that was just freed again.
> >
> > Only flush when the mapping, and for vmap_page_range() also the KMSAN
> > metadata, is fully set up.
> >
> > Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/all/sashiko-outbox-178439@xxxxxxxxxx/
> > Signed-off-by: Hao Ge <hao.ge@xxxxxxxxx>
> > ---
> > mm/vmalloc.c | 11 ++++++++---
> > 1 file changed, 8 insertions(+), 3 deletions(-)
> >
> > diff --git a/mm/vmalloc.c b/mm/vmalloc.c
> > index e2b63cb1592b..d99d7710e1ba 100644
> > --- a/mm/vmalloc.c
> > +++ b/mm/vmalloc.c
> > @@ -371,10 +371,12 @@ int vmap_page_range(unsigned long addr, unsigned long end,
> >
> > err = vmap_range_noflush(addr, end, phys_addr, pgprot_nx(prot),
> > ioremap_max_page_shift);
> > - flush_cache_vmap(addr, end);
> > if (!err)
> > err = kmsan_ioremap_page_range(addr, end, phys_addr, prot,
> > ioremap_max_page_shift);
> > + if (!err)
> > + flush_cache_vmap(addr, end);
> > +
> > return err;
> > }
> >
> This is incomplete. Maybe merge with 6.
Yeah, by itself this would still keep failed partial mappings, so it
doesn't really fix much, right? Merging with 6 makes more sense to me
too.
>
> --
> Uladzislau Rezki