Fix race when initializing TSC.
authorbluhm <bluhm@openbsd.org>
Wed, 22 Nov 2023 18:50:10 +0000 (18:50 +0000)
committerbluhm <bluhm@openbsd.org>
Wed, 22 Nov 2023 18:50:10 +0000 (18:50 +0000)
commit9fa027f16fcb815ac6d45f93c5c75deb8f911231
tree21442f7205d5f81019e65b7315d6df8c3ba8f476
parentf3e820cf7fdb0a316961a07d7fd66d361b23b954
Fix race when initializing TSC.

During boot TSC initialization could fail with panic: tsc_test_sync_ap:
cpu2: tsc_ap_name is not NULL: cpu1.
The root cause is a race between the moment the application processor
sets CPUF_IDENTIFIED in cpu_hatch() and the moment the boot processor
checks CPUF_IDENTIFIED in cpu_start_secondary() before the TSC sync
test.
The fix is to set CPUF_IDENTIFIED before clearing CPUF_IDENTIFY in
cpu_hatch().

from hshoexer@ cheloha@; OK deraadt@ mlarkin@
sys/arch/amd64/amd64/cpu.c