From nobody Sun May 24 18:42:57 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2148B285060 for ; Sat, 23 May 2026 16:59:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779555581; cv=none; b=fyLGIJS9ZcN7nb8FLZ09e5fDUcXl5/GG1XyGohrjYxJBqZ4Yg69ABBqzDO9zycvATE1V3RFgeVR17Pa9/popJt/45Y7IjtuD1W14izDeYyyEwQxIc7U3Cs4/5Zeq//qX7CDUELy2ZBnp6Dv4e2TKy/GEz+L1tx+TmM9doYy3W/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779555581; c=relaxed/simple; bh=FpVvWXXT+S08a+oGxhddN0b61XMhJtmpPVbqFqjHluY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=trtyVybUW6oVc01g6vSocs3d9+6cWDg915fPnemKqWBB1pZPgxSLsaJeGUTU8Jfi2lg6/m+TRBcwCI0CX9/hPlGNlrVMOpWh99F7kMl0Y01wnALUmcxQ3CbdRsto0Wz4D57u+xBnsnmcj/tjd1rjBtoWHuAbvDfAgMSjQi1wbe4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=sHetnfG/; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="sHetnfG/" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From: Reply-To:Content-ID:Content-Description:In-Reply-To:References; bh=pHoejXCQr1jc5SyppxOGDWNZ9/MW7Y7foH30qobTVFI=; b=sHetnfG/J+5bKnmxv9oVviUBtp Z70PpAgSpaxoBwuOW2N1OFPHgSmm7OFrnW3iV0GA4oVAo/8dj926PqsVxgJZ5UosL3aw3JkrWAk5c dOUsyKB3N3eeRMmXzSMeD4ndhG3qcvrzAKn+cLDnGB1A3+6JKWQ7iidl566aVyGiEVmK4xo1+mxQs v3x4cyU/f5l1bUN80wIrBSZMnShjJDty2lxq9Tr/1znj6P1VmbbseGuFBGNMWftvnLSKmvSMhoaa2 49xKpM17ZU77uwXPMduqf7niKwsKBawVGvzMVxfUB39Mai2+587MP6x9Eb7lpUGJDzvEMlmQjOgdn udrCoScA==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1wQphA-000AtY-2I; Sat, 23 May 2026 16:59:28 +0000 From: Breno Leitao Date: Sat, 23 May 2026 12:59:26 -0400 Subject: [PATCH] arm64: arch_timer: reuse arch_timer_read_cnt{p,v}ct_el0() helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260523-arch64_fix-v1-1-283bd4b73d49@debian.org> X-B4-Tracking: v=1; b=H4sIAO3cEWoC/yXMyw5AMBCF4VeRWWuiF214FRHRGowF0iIS8e6K5 XeS818Q0BMGKJMLPB4UaJkjeJqAG9t5QEZdNIhM6CwXkrXejVo1PZ1MK665KazhRkI8rB7j/MW q+nfY7YRuewtw3w/nfA/DbgAAAA== X-Change-ID: 20260523-arch64_fix-6416179b7173 To: Mark Rutland , Marc Zyngier , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Breno Leitao X-Mailer: b4 0.16-dev-d5d98 X-Developer-Signature: v=1; a=openpgp-sha256; l=2906; i=leitao@debian.org; h=from:subject:message-id; bh=FpVvWXXT+S08a+oGxhddN0b61XMhJtmpPVbqFqjHluY=; b=owEBbQKS/ZANAwAKATWjk5/8eHdtAcsmYgBqEdzvU+sjRQT1fn7VIl7NSCmeZl4AjAmh6JfsZ 2ULhfsm982JAjMEAAEKAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCahHc7wAKCRA1o5Of/Hh3 bV5fD/9U69LA7SGp1Z+Zp4GhN4Gtz4LHBOhd5NXQ9JSAukj/mGHFg0GK6hKJFdskB2397vMwvdC tmDN2cPrwJxsvGL+UOtCEgtqIS+cO6fO4Iiu142zujf5BOBykRY7J91eDWJB4A1SWs6HO2E6oKz dfg3N03wpDOq8l3MGz1QHrcVAIwmIgR1Qb37lKNgLUebHrNiF4cx9ePUhXh2L6bDcnyWyAt4wLq qFMniEzDVGkQ/s+Ju5W8hAKMxvyyskBKNPpLbWX54DgWGA9Won/knVlbhbJQacZAuqYBdRRqDrD tSDQr+akkAfzm/dKSpYG8tO8+3FrLjzCTNNc9xvKF0ZWyKh92Sz/bAQPZ/eIsYd1iHJPTivkP+Q 6rDo5cPo8+EfiZnj1af70JG5StzibGU5m47AOabgWAASCpV0PbhkplP6Da30eFQFpb97nDtFoWa px7LbCF3hmJsxRYNiqBX3PKSiUlxk2kkxW3h3AUnq+qdEn6DC0GU417c2cRweDgbZTnGe+SbiSD zOggA9mYnYAuOU0OEgJ1gGld4rJL1L+Rs11JuUcZg2UuG1wLfgngXd21o5In+z14fJwqwQwaj/B MHCf0zpryfaQ3MCKIZtUeNAdMuUOEdB0F+XnI0TkCN3AM0DqIOKUtrcKRDJ/Qm2beWHsgqWtunc pXuFHg+ZiWm7Y/w== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao __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 --- arch/arm64/include/asm/arch_timer.h | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/arm64/include/asm/arch_timer.h b/arch/arm64/include/asm/a= rch_timer.h index f5794d50f51d..6717209df05b 100644 --- a/arch/arm64/include/asm/arch_timer.h +++ b/arch/arm64/include/asm/arch_timer.h @@ -178,12 +178,8 @@ static __always_inline u64 __arch_counter_get_cntpct_s= table(void) =20 static __always_inline u64 __arch_counter_get_cntpct(void) { - u64 cnt; + u64 cnt =3D arch_timer_read_cntpct_el0(); =20 - asm volatile(ALTERNATIVE("isb\n mrs %0, cntpct_el0", - "nop\n" __mrs_s("%0", SYS_CNTPCTSS_EL0), - ARM64_HAS_ECV) - : "=3Dr" (cnt)); arch_counter_enforce_ordering(cnt); return cnt; } @@ -199,12 +195,8 @@ static __always_inline u64 __arch_counter_get_cntvct_s= table(void) =20 static __always_inline u64 __arch_counter_get_cntvct(void) { - u64 cnt; + u64 cnt =3D arch_timer_read_cntvct_el0(); =20 - asm volatile(ALTERNATIVE("isb\n mrs %0, cntvct_el0", - "nop\n" __mrs_s("%0", SYS_CNTVCTSS_EL0), - ARM64_HAS_ECV) - : "=3Dr" (cnt)); arch_counter_enforce_ordering(cnt); return cnt; } --- base-commit: 9f84f9898cf191aa251268547ceef03abb8d1edd change-id: 20260523-arch64_fix-6416179b7173 Best regards, -- =20 Breno Leitao