[tip: timers/ptp] KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME

tip-bot2 for Thomas Gleixner posted 1 patch 5 days, 16 hours ago
There is a newer version of this series
arch/arm64/kvm/hyp_trace.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[tip: timers/ptp] KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME
Posted by tip-bot2 for Thomas Gleixner 5 days, 16 hours ago
The following commit has been merged into the timers/ptp branch of tip:

Commit-ID:     d09439210441efbadd8b0aa32c1ddb1eab2f3abd
Gitweb:        https://git.kernel.org/tip/d09439210441efbadd8b0aa32c1ddb1eab2f3abd
Author:        Thomas Gleixner <tglx@kernel.org>
AuthorDate:    Fri, 29 May 2026 22:00:08 +02:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Tue, 02 Jun 2026 11:39:58 +02:00

KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME

ktime_get_snapshot() is replaced by ktime_get_snapshot_id() which allows to
request a particular CLOCK ID to be captured along with the clocksource
counter.

Convert the tracing mechanism over and use the new
system_time_snapshot::systime field, which holds the system timestamp
selected by the CLOCK ID argument.

No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Arthur Kiyanovski <akiyano@amazon.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Acked-by: Vincent Donnefort <vdonnefort@google.com>
Link: https://patch.msgid.link/20260529195557.174373054@kernel.org
---
 arch/arm64/kvm/hyp_trace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c
index 8b7f2bf..b056c65 100644
--- a/arch/arm64/kvm/hyp_trace.c
+++ b/arch/arm64/kvm/hyp_trace.c
@@ -51,8 +51,8 @@ static void __hyp_clock_work(struct work_struct *work)
 
 	hyp_clock = container_of(dwork, struct hyp_trace_clock, work);
 
-	ktime_get_snapshot(&snap);
-	boot = ktime_to_ns(snap.boot);
+	ktime_get_snapshot_id(CLOCK_BOOTTIME, &snap);
+	boot = ktime_to_ns(snap.systime);
 
 	delta_boot = boot - hyp_clock->boot;
 	delta_cycles = snap.cycles - hyp_clock->cycles;
@@ -118,9 +118,9 @@ static void hyp_trace_clock_enable(struct hyp_trace_clock *hyp_clock, bool enabl
 		hyp_clock->running = false;
 	}
 
-	ktime_get_snapshot(&snap);
+	ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME);
 
-	hyp_clock->boot = ktime_to_ns(snap.boot);
+	hyp_clock->boot = ktime_to_ns(snap.systime);
 	hyp_clock->cycles = snap.cycles;
 	hyp_clock->mult = 0;
 
Re: [tip: timers/ptp] KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME
Posted by Nathan Chancellor 4 days ago
Hi Thomas,

On Tue, Jun 02, 2026 at 09:46:13AM -0000, tip-bot2 for Thomas Gleixner wrote:
> The following commit has been merged into the timers/ptp branch of tip:
> 
> Commit-ID:     d09439210441efbadd8b0aa32c1ddb1eab2f3abd
> Gitweb:        https://git.kernel.org/tip/d09439210441efbadd8b0aa32c1ddb1eab2f3abd
> Author:        Thomas Gleixner <tglx@kernel.org>
> AuthorDate:    Fri, 29 May 2026 22:00:08 +02:00
> Committer:     Thomas Gleixner <tglx@kernel.org>
> CommitterDate: Tue, 02 Jun 2026 11:39:58 +02:00
> 
> KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME
...
>  arch/arm64/kvm/hyp_trace.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/kvm/hyp_trace.c b/arch/arm64/kvm/hyp_trace.c
> index 8b7f2bf..b056c65 100644
> --- a/arch/arm64/kvm/hyp_trace.c
> +++ b/arch/arm64/kvm/hyp_trace.c
> @@ -51,8 +51,8 @@ static void __hyp_clock_work(struct work_struct *work)
>  
>  	hyp_clock = container_of(dwork, struct hyp_trace_clock, work);
>  
> -	ktime_get_snapshot(&snap);
> -	boot = ktime_to_ns(snap.boot);
> +	ktime_get_snapshot_id(CLOCK_BOOTTIME, &snap);
> +	boot = ktime_to_ns(snap.systime);
>  
>  	delta_boot = boot - hyp_clock->boot;
>  	delta_cycles = snap.cycles - hyp_clock->cycles;
> @@ -118,9 +118,9 @@ static void hyp_trace_clock_enable(struct hyp_trace_clock *hyp_clock, bool enabl
>  		hyp_clock->running = false;
>  	}
>  
> -	ktime_get_snapshot(&snap);
> +	ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME);

It looks like this instance of ktime_get_snapshot_id() did not get its
arguments swapped when applied, which breaks the build in -next:

  arch/arm64/kvm/hyp_trace.c:121:24: error: incompatible pointer to integer conversion passing 'struct system_time_snapshot *' to parameter of type 'clockid_t' (aka 'int') [-Wint-conversion]
    121 |         ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME);
        |                               ^~~~~
  include/linux/timekeeping.h:357:45: note: passing argument to parameter 'clock_id' here
    357 | extern void ktime_get_snapshot_id(clockid_t clock_id, struct system_time_snapshot *systime_snapshot);
        |                                             ^
  arch/arm64/kvm/hyp_trace.c:121:31: error: incompatible integer to pointer conversion passing 'int' to parameter of type 'struct system_time_snapshot *' [-Wint-conversion]
    121 |         ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME);
        |                                      ^~~~~~~~~~~~~~
  include/uapi/linux/time.h:56:26: note: expanded from macro 'CLOCK_BOOTTIME'
     56 | #define CLOCK_BOOTTIME                  7
        |                                         ^
  include/linux/timekeeping.h:357:84: note: passing argument to parameter 'systime_snapshot' here
    357 | extern void ktime_get_snapshot_id(clockid_t clock_id, struct system_time_snapshot *systime_snapshot);
        |                                                                                    ^
  2 errors generated.

Do you want a fix up patch or do you want to just squash in the fix?

> -	hyp_clock->boot = ktime_to_ns(snap.boot);
> +	hyp_clock->boot = ktime_to_ns(snap.systime);
>  	hyp_clock->cycles = snap.cycles;
>  	hyp_clock->mult = 0;
>  

-- 
Cheers,
Nathan
Re: [tip: timers/ptp] KVM: arm64: Use ktime_get_snapshot_id() to retrieve CLOCK_BOOTTIME
Posted by Thomas Gleixner 3 days, 17 hours ago
On Wed, Jun 03 2026 at 18:55, Nathan Chancellor wrote:
>>  
>> -	ktime_get_snapshot(&snap);
>> +	ktime_get_snapshot_id(&snap, CLOCK_BOOTTIME);
>
> It looks like this instance of ktime_get_snapshot_id() did not get its
> arguments swapped when applied, which breaks the build in -next:

Yes. I'm an idiot. I had it on my checklist for merging and then ....

> Do you want a fix up patch or do you want to just squash in the fix?

I squashed it.