Re: [PATCH 6/6] alpha: invalidate the local context in flush_icache_user_page()

From: Matt Turner

Date: Sun Aug 09 2026 - 23:03:40 EST


On Sun, Aug 9, 2026 at 4:55 AM Magnus Lindholm <linmag7@xxxxxxxxx> 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 <linmag7@xxxxxxxxx>
> ---
> 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?