]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
arm64: arch_timer: reuse arch_timer_read_cnt{p,v}ct_el0() helpers
authorBreno Leitao <leitao@debian.org>
Sat, 23 May 2026 16:59:26 +0000 (12:59 -0400)
committerWill Deacon <will@kernel.org>
Fri, 5 Jun 2026 11:04:40 +0000 (12:04 +0100)
commit11c33ffb3a4e65e775e9bd814eb71df06ea7c847
tree5198f0c388e9eb69d34c65b1886ec1fbca624f9d
parent6c2ccb4979b2c8aa83cbea827a714a74db7d2398
arm64: arch_timer: reuse arch_timer_read_cnt{p,v}ct_el0() helpers

__arch_counter_get_cntpct() and __arch_counter_get_cntvct() open-code
the same ECV-aware ALTERNATIVE block that arch_timer_read_cntpct_el0()
and arch_timer_read_cntvct_el0() already provide in the same header.
The two pairs are byte-for-byte identical except for the trailing
arch_counter_enforce_ordering() the __arch_counter_get_* variants add.

Replace the duplicated inline assembly in __arch_counter_get_cntpct()
and __arch_counter_get_cntvct() with calls to the corresponding helpers.
This mirrors commit 00b39d150986 ("arm64: vdso: Use
__arch_counter_get_cntvct()"), which removed similar duplication from
the vDSO, and keeps the system-counter read sequence in a single place,
reducing assembly code in the kernell

No functional change: the resulting inline assembly, alternatives, and
clobbers are unchanged; only the source-level expression of the read
moves into the existing helper.

Verified by rebuilding the consumers of these helpers before and after
the change and comparing the resulting disassembly:

  - arch/arm64/kernel/vdso/vdso.so (final linked vDSO):
      bit-identical (same sha256 across rebuilds)
  - arch/arm64/kernel/vdso/vgettimeofday.o:    identical disassembly
  - arch/arm64/lib/delay.o:                    identical disassembly
  - drivers/clocksource/arm_arch_timer.o:      same 50 functions with
      byte-identical instruction streams; only difference is function
      ordering inside .text and NOP padding, with no opcodes added or
      removed.

Signed-off-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/arch_timer.h