powerpc: put the isync inside the TD_LOCK() checking loop

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

(cherry picked from commit 8df2e54214)
This commit is contained in:
Adrian Chadd 2026-01-03 14:52:14 -08:00
parent e5861dc2ea
commit a50789d8b8
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 */