All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Magnus Lindholm" <linmag7@gmail.com>
Cc: sparclinux@vger.kernel.org
Subject: Re: [PATCH 02/18] sparc32,leon: retain SMP TLB shootdowns
Date: Thu, 26 Nov 2026 09:41:26 +0000	[thread overview]
Message-ID: <sashiko-outbox-235154@kernel.org> (raw)
In-Reply-To: <20261126093106.1345825-3-linmag7@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] sparc32: missing preemption disable in smp_flush_tlb_mm() [1]
--

commit 20d5675eb7a3d5e5a3910745d8ae9ac1da8711f2
Author: Magnus Lindholm <linmag7@gmail.com>

sparc32,leon: retain SMP TLB shootdowns

This commit retains the SMP TLB flush wrappers on LEON instead of replacing
them with local operations, and updates leon_switch_mm() to invoke
leon_flush_tlb_all() directly for local context switches.

> diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
> index 145a63a5fda91..fb95865d7ddd5 100644
> --- a/arch/sparc/mm/srmmu.c
> +++ b/arch/sparc/mm/srmmu.c
> @@ -1746,7 +1746,8 @@ void __init load_mmu(void)
>  	/* El switcheroo... */
>  	local_ops = sparc32_cachetlb_ops;
>  
> -	if (sparc_cpu_model == sun4d || sparc_cpu_model == sparc_leon) {
> +	/* sun4d supplies its own SMP TLB operations. */
> +	if (sparc_cpu_model == sun4d) {
>  		smp_cachetlb_ops.tlb_all = local_ops->tlb_all;
>  		smp_cachetlb_ops.tlb_mm = local_ops->tlb_mm;
>  		smp_cachetlb_ops.tlb_range = local_ops->tlb_range;

[Severity: High]
This problem wasn't introduced by this patch, but can smp_flush_tlb_mm()
leave stale TLB entries on the original CPU if the caller is preempted and
migrated mid-flush [1]?

With LEON now using smp_cachetlb_ops.tlb_mm, flush_tlb_mm() calls
smp_flush_tlb_mm(), which runs without disabling preemption when invoked
from preemptible context (such as fork() -> dup_mmap() -> flush_tlb_mm()):

arch/sparc/mm/srmmu.c:any_other_mm_cpus() {
	return cpumask_any_but(mm_cpumask(mm), smp_processor_id()) < nr_cpu_ids;
}
...
arch/sparc/mm/srmmu.c:smp_flush_tlb_mm() {
	if (mm->context != NO_CONTEXT) {
		if (any_other_mm_cpus(mm))
			xc1(local_ops->tlb_mm, (unsigned long)mm);
		local_ops->tlb_mm(mm);
	}
}

Aside from calling smp_processor_id() in preemptible context (which warns
under CONFIG_DEBUG_PREEMPT), the cross-call excludes the initiating CPU and
re-enables preemption before local_ops->tlb_mm() runs:

CPU0                                  CPU1
smp_flush_tlb_mm(mm)
  xc1(local_ops->tlb_mm, ...)
    sun4m_cross_call(...)
      cpumask_clear_cpu(0, &mask)
      ...
      spin_unlock_irqrestore(...)
  [migrated to CPU1]
                                      local_ops->tlb_mm(mm)  <-- CPU0 missed

CPU1 is flushed twice while CPU0's TLB is never flushed, which can cause
memory corruption after page table updates.

[1] https://sashiko.dev/#/bug/linux-faa0e34b-f932-4bee-ba78-e5a71fbc6fe8

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126093106.1345825-1-linmag7@gmail.com?part=2

  reply	other threads:[~2026-11-26  9:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  9:30 [PATCH 00/18] sparc32: LEON SMP, timer accounting and legacy board support Magnus Lindholm
2026-11-26  9:30 ` [PATCH 01/18] sparc32,leon: give the cross-call IRQ highest priority Magnus Lindholm
2026-11-26  9:30 ` [PATCH 02/18] sparc32,leon: retain SMP TLB shootdowns Magnus Lindholm
2026-11-26  9:41   ` sashiko-bot [this message]
2026-11-27 11:37     ` Magnus Lindholm
2026-11-26  9:30 ` [PATCH 03/18] sparc32,leon: publish instruction updates across CPUs Magnus Lindholm
2026-11-26  9:30 ` [PATCH 04/18] sparc32,leon: avoid nested IRQ accounting in the timer handler Magnus Lindholm
2026-11-26  9:30 ` [PATCH 05/18] sparc32: preserve both LEON PROM character-output conventions Magnus Lindholm
2026-11-26  9:30 ` [PATCH 06/18] sparc32: tolerate firmware nodes without a name property Magnus Lindholm
2026-11-26  9:42   ` sashiko-bot
2026-11-26  9:30 ` [PATCH 07/18] sparc32: skip unavailable PROM V0 console metadata Magnus Lindholm
2026-11-26  9:30 ` [PATCH 08/18] sparc32,leon: identify LEON before the firmware model lookup Magnus Lindholm
2026-11-26  9:30 ` [PATCH 09/18] sparc32,leon: preserve the Linux IRQ14 vector during startup Magnus Lindholm
2026-11-26  9:30 ` [PATCH 10/18] sparc32,leon: use ASI 1 for locks on the GR-LEON4-ITX Magnus Lindholm
2026-11-26  9:30 ` [PATCH 11/18] sparc32,leon: restore the kernel header offsets used by U-Boot Magnus Lindholm
2026-11-26  9:30 ` [PATCH 12/18] sparc32: recognize the legacy LEON firmware machine ID Magnus Lindholm
2026-11-26  9:30 ` [PATCH 13/18] sparc32,leon: discover AMBA devices for legacy U-Boot PROMs Magnus Lindholm
2026-11-26  9:30 ` [PATCH 14/18] sparc32,leon: describe legacy AMBA I2C controllers Magnus Lindholm
2026-11-26  9:30 ` [PATCH 15/18] sparc32,leon: skip the GR-LEON4-ITX PROM mapping import Magnus Lindholm
2026-11-26  9:30 ` [PATCH 16/18] sparc32,leon: use the upper SDRAM on the GR-LEON4-ITX Magnus Lindholm
2026-11-26  9:30 ` [PATCH 17/18] sparc32,leon: combine legacy GRPCI1 plug-and-play resources Magnus Lindholm
2026-11-26  9:30 ` [PATCH 18/18] sparc32,leon: describe the DS1672 on the GR-LEON4-ITX Magnus Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-235154@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linmag7@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sparclinux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.