[PATCH v3 0/8] arm64: arch_timer: Improve errata handling
From: Marc Zyngier
Date: Sun Aug 02 2026 - 12:54:23 EST
This is the third version of this series addressing a couple of
embarrassing bugs in the prolific arm64 timer errata handling
department. See below for the changes since v2.
Time is hard. Timers are harder. As a consequence, we have plenty of
broken counter/timer implementations in the wild, and an
infrastructure to deal with them.
However, what we have today suffers from a number of issues:
- if, on an heterogeneous system, affected CPUs are secondaries, we do
record their broken state but don't correct anything
- we always play games with preemption in order to access per-CPU
state, irrespective of the presence of broken CPUs
I hear someone saying "just use a static key to enable the errata and
be done with it". Good call, except that we need to do that from a
CPUHP callback, and that's deadlock central. We can't do it later,
because this could affect the CPU before the workaround is enabled.
However, not everything is lost if we turn the logic on its head:
- always start with the mitigations enabled, even if we don't know of
any affected CPU
- once all CPUs have been seen once, and that we still haven't
enabled any workaround, disable the mitigations globally.
With that, a normal kernel boot with all CPUs will quickly switch to
no mitigation on decent HW. If you're booting with CPUs disabled, this
will only kick in once you have booted them all.
Patches on top of 7.2-rc4.
* From v2 [1]:
- Added a fix for the PMUv3 driver that really wants to know whether
it is operating with the architected timer. This has been broken
for some time (since 24ee7607b286b ("arm64/arch_timer: Provide
noinstr sched_clock_read() functions"))
- Make arch_timer_read_counter a function, and not just a function pointer
- Added a command-line option to allow the user to promise that no
erratum is required (Will)
- Dropped the internal CPU mask and iterate over the existing
per-cpu variable (Will)
- Picked Catalin's Ack, with thanks
[1] https://lore.kernel.org/all/20260508094203.2913880-1-maz@xxxxxxxxxx/
Marc Zyngier (8):
clocksource/drivers/arm_arch_timer: Add
read_sched_clock_is_arch_counter() predicate
clocksource/drivers/arm_arch_timer: Add a static key indicating the
need for a runtime workaround
clocksource/drivers/arm_arch_timer: Convert counter accessors to a
static key alternative
clocksource/drivers/arm_arch_timer: Drop the
arch_counter_get_cnt{p,v}ct_stable() accessors
clocksource/drivers/arm_arch_timer: Turn arch_timer_read_counter into
a function
clocksource/drivers/arm_arch_timer: Add command-line control over the
counter errata management
clocksource/drivers/arm_arch_timer: Expose a direct accessor for the
virtual counter
arm64: Convert __delay_cycles() to arch_timer_read_vcounter()
.../admin-guide/kernel-parameters.txt | 13 ++
arch/arm64/lib/delay.c | 5 +-
drivers/clocksource/arm_arch_timer.c | 156 ++++++++++++------
drivers/perf/arm_pmuv3.c | 2 +-
include/clocksource/arm_arch_timer.h | 11 +-
5 files changed, 131 insertions(+), 56 deletions(-)
--
2.47.3