From nobody Mon Jun 8 05:26:57 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 7FEA1380FEC; Fri, 5 Jun 2026 12:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780662620; cv=none; b=Sy+ezu1YvnbAtGqqV1+nWQiq02aFptFIlwHVDSyt7+RFIxhtijXn+AsQyyqOWjSL1LFMRTyvKZgMTKXtlgElv/Z7uM0ylY14mVkkpKD7iPfYGl6CHwOLpMzrORex/C069bZFwJAKh2U5uzCDeyg60vnMrLHeysa0G3txituLMow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780662620; c=relaxed/simple; bh=sMgIpcEgFlyAk8eBECp8cC4RKAvpvzsl0wGE7ak6zvA=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=l/muD+sS9FMckrgfbE/MYBfGCrJTp9XPHOaOylG2u/PcGjvlGaBs5ZJcWAKBYtTG1VLxIyK/UkPJw3clZ55DQvb3cERnvj7nOFG4OpNPO7QAZRiNgbC+vosWrdwP1J9EqQ57x0+kFKoHLMMNIZOjRIYHcWaiS8lkgECen7Noy1U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=EHscZ8bT; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=u1JxBN3T; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EHscZ8bT"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="u1JxBN3T" Date: Fri, 05 Jun 2026 12:30:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780662618; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w4Fuyuq7Hveor9K/5taIdFeJp3pvIPMoHxmKIOB04AQ=; b=EHscZ8bTu16AZ074w6dDYgDPoD7JYDrGxHJfFqFRXLWzLkBe77eEQvtvU2roYm8hIk2CZy r+x1gzp77Kpo54uuwk7KTFWI/e+URSXSWTRBe5ZzWNAER68IIFkB3wWU3uDmCHiwMfOxaP XfcwA5eOsChGQPVoVcel8Y/r1TeJd01ih0ObaMmkX/91Aw+Z+aJAoR8O0IOycJTrmWHEke FkDikU65jakP8DW09dl1xMELithrYEXJNXm0dbvb2wYXlRXBac9gdPwJrulDqiOUtShx8a 8LrgQTg+qnQ5L+q+Mc6wBVLt2KNWoNOk+0uCrtJ62tUCSuZGQisuGoX5FzS01A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780662618; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=w4Fuyuq7Hveor9K/5taIdFeJp3pvIPMoHxmKIOB04AQ=; b=u1JxBN3TkiaMuaRiOrMeMORQGt/4UPlQd76UYmXBgG4KFSmFjrQYmzE3JT7x3Em1E4A+ae rUq1FWlEcHVDoSDw== From: "tip-bot2 for David Woodhouse" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/ptp] clocksource/hyperv: Implement read_snapshot() for TSC page clocksource Cc: David Woodhouse , Thomas Gleixner , Michael Kelley , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260604095755.64849-2-dwmw2@infradead.org> References: <20260604095755.64849-2-dwmw2@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178066261631.710.13032581932741239024.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the timers/ptp branch of tip: Commit-ID: c51100f9e26857f2b2376d5cd657a15f52b9e05c Gitweb: https://git.kernel.org/tip/c51100f9e26857f2b2376d5cd657a15f5= 2b9e05c Author: David Woodhouse AuthorDate: Thu, 04 Jun 2026 10:35:16 +01:00 Committer: Thomas Gleixner CommitterDate: Fri, 05 Jun 2026 14:25:03 +02:00 clocksource/hyperv: Implement read_snapshot() for TSC page clocksource Implement the read_snapshot() callback for the Hyper-V TSC page clock- source. This returns the derived 10MHz reference time (for timekeeping) while also providing the raw TSC value that was used to compute it. When the TSC page is valid, hv_read_tsc_page_tsc() atomically captures both values from a single RDTSC inside the sequence-counter protected read. When the TSC page is invalid (sequence =3D=3D 0), the hw_csid and hw_cycles are = set to zero indicating no value is available. This enables ktime_get_snapshot_id() to provide the raw TSC to consumers like KVM's master clock when running nested guests under Hyper-V. Signed-off-by: David Woodhouse Signed-off-by: Thomas Gleixner Assisted-by: Kiro:claude-opus-4.6-1m Reviewed-by: Michael Kelley Link: https://patch.msgid.link/20260604095755.64849-2-dwmw2@infradead.org --- drivers/clocksource/hyperv_timer.c | 37 +++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyper= v_timer.c index e9f5034..df56779 100644 --- a/drivers/clocksource/hyperv_timer.c +++ b/drivers/clocksource/hyperv_timer.c @@ -444,6 +444,22 @@ static u64 notrace read_hv_clock_tsc_cs(struct clockso= urce *arg) return read_hv_clock_tsc(); } =20 +static u64 notrace read_hv_clock_tsc_cs_snapshot(struct clocksource *arg, + struct clocksource_hw_snapshot *chs) +{ + u64 time; + + if (hv_read_tsc_page_tsc(tsc_page, &chs->hw_cycles, &time)) { + chs->hw_csid =3D CSID_X86_TSC; + } else { + chs->hw_cycles =3D 0; + chs->hw_csid =3D CSID_GENERIC; + time =3D read_hv_clock_msr(); + } + + return time; +} + static u64 noinstr read_hv_sched_clock_tsc(void) { return (read_hv_clock_tsc() - hv_sched_clock_offset) * @@ -492,18 +508,19 @@ static int hv_cs_enable(struct clocksource *cs) #endif =20 static struct clocksource hyperv_cs_tsc =3D { - .name =3D "hyperv_clocksource_tsc_page", - .rating =3D 500, - .read =3D read_hv_clock_tsc_cs, - .mask =3D CLOCKSOURCE_MASK(64), - .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, - .suspend=3D suspend_hv_clock_tsc, - .resume =3D resume_hv_clock_tsc, + .name =3D "hyperv_clocksource_tsc_page", + .rating =3D 500, + .read =3D read_hv_clock_tsc_cs, + .read_snapshot =3D read_hv_clock_tsc_cs_snapshot, + .mask =3D CLOCKSOURCE_MASK(64), + .flags =3D CLOCK_SOURCE_IS_CONTINUOUS, + .suspend =3D suspend_hv_clock_tsc, + .resume =3D resume_hv_clock_tsc, #ifdef HAVE_VDSO_CLOCKMODE_HVCLOCK - .enable =3D hv_cs_enable, - .vdso_clock_mode =3D VDSO_CLOCKMODE_HVCLOCK, + .enable =3D hv_cs_enable, + .vdso_clock_mode =3D VDSO_CLOCKMODE_HVCLOCK, #else - .vdso_clock_mode =3D VDSO_CLOCKMODE_NONE, + .vdso_clock_mode =3D VDSO_CLOCKMODE_NONE, #endif }; =20