Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Matt Turner <mattst88@gmail.com>
To: linux-alpha@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Richard Henderson <richard.henderson@linaro.org>,
	Magnus Lindholm <linmag7@gmail.com>,
	Matt Turner <mattst88@gmail.com>,
	stable@vger.kernel.org
Subject: [PATCH] alpha: Fix SMP shutdown hang due to missing memory barriers
Date: Thu, 28 May 2026 19:10:43 -0400	[thread overview]
Message-ID: <20260528231043.1842326-1-mattst88@gmail.com> (raw)

Alpha has a very weak memory model. halt() makes no guarantee that
pending stores have drained from the store buffer. If set_cpu_present()
stores are still buffered when a secondary CPU halts, they are lost,
and the boot CPU spins forever in the cpu_present_mask wait loop.

Add mb() before halt() on secondary CPUs to flush the store buffer,
and use smp_mb() in the boot CPU's poll loop instead of the
compiler-only barrier() to ensure it observes secondary CPUs' stores.

This avoids a deadlock on shutdown on EV7/Marvel platforms.

Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Matt Turner <mattst88@gmail.com>
---
 arch/alpha/kernel/process.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git ./arch/alpha/kernel/process.c ./arch/alpha/kernel/process.c
index 06522451f018..d50f9cfd8333 100644
--- ./arch/alpha/kernel/process.c
+++ ./arch/alpha/kernel/process.c
@@ -99,6 +99,7 @@ common_shutdown_1(void *generic_ptr)
 		*pflags = flags;
 		set_cpu_present(cpuid, false);
 		set_cpu_possible(cpuid, false);
+		mb();
 		halt();
 	}
 #endif
@@ -127,7 +128,7 @@ common_shutdown_1(void *generic_ptr)
 	set_cpu_present(boot_cpuid, false);
 	set_cpu_possible(boot_cpuid, false);
 	while (!cpumask_empty(cpu_present_mask))
-		barrier();
+		smp_mb();
 #endif
 
 	/* If booted from SRM, reset some of the original environment. */
-- 
2.53.0


             reply	other threads:[~2026-05-28 23:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-28 23:10 Matt Turner [this message]
2026-05-29 13:50 ` [PATCH] alpha: Fix SMP shutdown hang due to missing memory barriers 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=20260528231043.1842326-1-mattst88@gmail.com \
    --to=mattst88@gmail.com \
    --cc=linmag7@gmail.com \
    --cc=linux-alpha@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=richard.henderson@linaro.org \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox