powerpc: put the isync inside the TD_LOCK() checking loop
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run

Fix a narrow window where the lock is unlocked but the checking CPU
hasn't flushed things appropriately.

Inside this window the CPU inside cpu_switch() will loop forever thinking
the destination thread is still blocked/locked even though it is not.

This manifests as the system hanging after starting all APs.

I've seen this reliably trigger in qemu-system-ppc64 running power9 pseries
guests; the more CPUs the more likely it triggers at boot.

PR: kern/292167
Differential Revision:	https://reviews.freebsd.org/D54478
Reviewed by:	jhibbits
MFC after:	1 week
Relnotes:	yes
This commit is contained in:
Adrian Chadd 2026-01-03 14:52:14 -08:00
parent 17355cf50f
commit 8df2e54214
2 changed files with 2 additions and 2 deletions

View file

@ -141,8 +141,8 @@ cpu_switchin:
blocked_loop:
lwz %r7,TD_LOCK(%r2)
cmpw %r6,%r7
beq- blocked_loop
isync
beq- blocked_loop
#endif
lwz %r17,TD_PCB(%r2) /* Get new current PCB */

View file

@ -194,8 +194,8 @@ cpu_switchin:
blocked_loop:
ld %r7,TD_LOCK(%r13)
cmpd %r6,%r7
beq- blocked_loop
isync
beq- blocked_loop
#endif
ld %r17,TD_PCB(%r13) /* Get new PCB */