[PATCH 1/2] x86/timer: Don't skip PIT setup on UP when the local APIC timer is disabled

From: Jiaming Fan

Date: Sun Nov 22 2026 - 05:30:20 EST


apic_needs_pit() returns false on CPUs with the TSC deadline timer before
it checks disable_apic_timer. With "noapictimer" and only one possible
CPU, setup_boot_APIC_clock() registers no local APIC clockevent either,
so without an HPET no clockevent device is left and the boot hangs.

Ask for the PIT in that case. Leave SMP alone: there the option is
currently ignored and the local APIC timer is used, and setting up the
PIT would make check_timer() panic on machines without an HPET whose PIT
doesn't tick.

Fixes: c8c4076723da ("x86/timer: Skip PIT initialization on modern chipsets")
Signed-off-by: Jiaming Fan <fan.jiaming@xxxxxxxxxxx>
---

Notes:
I first tried simply moving the disable_apic_timer check above the TSC
deadline check. That breaks SMP as described above; I reproduced the
check_timer() panic with QEMU -smp 2 -machine q35,hpet=off,pit=off
-cpu host,kvm=off and tsc_early_khz=3193914 (the guest's TSC frequency
on my host; use your own, or tsc_khz stays unknown early and the PIT is
required before the changed check is reached).

arch/x86/kernel/apic/apic.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 90025451ace2f..6b2e61ae7e240 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -782,6 +782,9 @@ bool __init apic_needs_pit(void)
if (!boot_cpu_has(X86_FEATURE_ARAT))
return true;

+ if (disable_apic_timer && num_possible_cpus() == 1)
+ return true;
+
/* Deadline timer is based on TSC so no further PIT action required */
if (boot_cpu_has(X86_FEATURE_TSC_DEADLINE_TIMER))
return false;
--
2.56.1