]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
arm64: Fix sampling the "stable" virtual counter in preemptible section
authorMarc Zyngier <maz@kernel.org>
Thu, 26 Feb 2026 08:22:32 +0000 (08:22 +0000)
committerWill Deacon <will@kernel.org>
Thu, 26 Feb 2026 18:12:48 +0000 (18:12 +0000)
commite5cb94ba5f96d691d8885175d4696d6ae6bc5ec9
tree4af83ed0bac1772ffcaacfa967674bf77e5c34d0
parenta8f78680ee6bf795086384e8aea159a52814f827
arm64: Fix sampling the "stable" virtual counter in preemptible section

Ben reports that when running with CONFIG_DEBUG_PREEMPT, using
__arch_counter_get_cntvct_stable() results in well deserves warnings,
as we access a per-CPU variable without preemption disabled.

Fix the issue by disabling preemption on reading the counter. We can
probably do a lot better by not disabling preemption on systems that
do not require horrible workarounds to return a valid counter value,
but this plugs the issue for the time being.

Fixes: 29cc0f3aa7c6 ("arm64: Force the use of CNTVCT_EL0 in __delay()")
Reported-by: Ben Horgan <ben.horgan@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/aZw3EGs4rbQvbAzV@e134344.arm.com
Tested-by: Ben Horgan <ben.horgan@arm.com>
Tested-by: André Draszik <andre.draszik@linaro.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/lib/delay.c