Re: [PATCH 6/6] alpha: invalidate the local context in flush_icache_user_page()
Matt Turner <[email protected]>
| Newsgroups | org.kernel.vger.linux-alpha,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAEdQ38FEmxBu4xyf9FO9qqOO3OJewSCA-qoQ+M+X9JE+vGwa7g@mail.gmail.com> |
On Sun, Aug 9, 2026 at 4:55 AM Magnus Lindholm <[email protected]> wrote: > > flush_icache_user_page() has the same caller-CPU omission that the > previous patch fixed in flush_tlb_mm(): > > if (mm == current->active_mm) { > __load_new_mm_context(mm); > ... > } > > smp_call_function(ipi_flush_icache_page, mm, 1); > > When the target mm is not the calling CPU's active_mm nothing happens > locally, and smp_call_function() handles only the other CPUs, so this CPU > may later reuse the old ASN together with the translations it still holds. > > This matters here in particular because the function exists for operating > on another process's mappings: the comment above it describes setting > breakpoints through ptrace, and access_remote_vm() reaches it through > copy_to_user_page(). The calling CPU is therefore often running something > other than the target mm. > > As in flush_tlb_mm(), the UP implementation in asm/cacheflush.h already > has the missing case: > > if (current->active_mm == mm) > __load_new_mm_context(mm); > else > mm->context[smp_processor_id()] = 0; > > Signed-off-by: Magnus Lindholm <[email protected]> > --- > arch/alpha/kernel/smp.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/alpha/kernel/smp.c b/arch/alpha/kernel/smp.c > index f501a91001cc..13b86f7224de 100644 > --- a/arch/alpha/kernel/smp.c > +++ b/arch/alpha/kernel/smp.c > @@ -780,6 +780,13 @@ flush_icache_user_page(struct vm_area_struct *vma, struct page *page, > preempt_enable(); > return; > } > + } else { > + /* > + * As in flush_tlb_mm(): smp_call_function() does not call > + * back into this CPU, and this function is used precisely > + * when operating on another process's mappings. > + */ > + flush_tlb_other(mm); > } ipi_flush_icache_page() also doesn't issue an imb() here, so I'm guessing it's not actually needed... but I could see why it might be. Any theories?