[RFC PATCH 2/4] x86/kvm: Add clocksource id for kvm-clock

From: Peter Hilber
Date: Thu Aug 17 2023 - 21:14:21 EST


Add a clocksource id for kvm-clock, so that it can be identified through
enum clocksource_ids.

This will keep ptp_kvm working on x86 in the future, when
get_device_system_crosststamp() would be changed to compare enum
clocksource_ids, rather than struct clocksource *. It also makes
identifying kvm-clock easier for outside code in general.

Signed-off-by: Peter Hilber <peter.hilber@xxxxxxxxxxxxxxx>
---
arch/x86/kernel/kvmclock.c | 2 ++
include/linux/clocksource_ids.h | 1 +
2 files changed, 3 insertions(+)

diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c
index fb8f52149be9..a686733a2d20 100644
--- a/arch/x86/kernel/kvmclock.c
+++ b/arch/x86/kernel/kvmclock.c
@@ -4,6 +4,7 @@
*/

#include <linux/clocksource.h>
+#include <linux/clocksource_ids.h>
#include <linux/kvm_para.h>
#include <asm/pvclock.h>
#include <asm/msr.h>
@@ -160,6 +161,7 @@ struct clocksource kvm_clock = {
.rating = 400,
.mask = CLOCKSOURCE_MASK(64),
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
+ .id = CSID_KVM_CLOCK,
.enable = kvm_cs_enable,
};
EXPORT_SYMBOL_GPL(kvm_clock);
diff --git a/include/linux/clocksource_ids.h b/include/linux/clocksource_ids.h
index 86d23abfde2a..11d3cc318dc1 100644
--- a/include/linux/clocksource_ids.h
+++ b/include/linux/clocksource_ids.h
@@ -8,6 +8,7 @@ enum clocksource_ids {
CSID_ARM_ARCH_COUNTER,
CSID_TSC_EARLY,
CSID_TSC,
+ CSID_KVM_CLOCK,
CSID_MAX,
};

--
2.39.2