[RFC PATCH 2/6] x86/kvm: Add a struct and constants for virtual suspend time injection

From: Hikaru Nishida
Date: Mon Apr 26 2021 - 05:09:20 EST


This patch adds definitions that are needed by both host and guest
to implement virtual suspend time injection.
This patch also adds #include <linux/kvm_host.h> in
kernel/time/timekeeping.c to make necesarily functions which will be
introduced in later patches available.

Signed-off-by: Hikaru Nishida <hikalium@xxxxxxxxxxxx>
---

arch/x86/include/uapi/asm/kvm_para.h | 6 ++++++
kernel/time/timekeeping.c | 1 +
2 files changed, 7 insertions(+)

diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h
index 950afebfba88..13788b01094f 100644
--- a/arch/x86/include/uapi/asm/kvm_para.h
+++ b/arch/x86/include/uapi/asm/kvm_para.h
@@ -33,6 +33,7 @@
#define KVM_FEATURE_PV_SCHED_YIELD 13
#define KVM_FEATURE_ASYNC_PF_INT 14
#define KVM_FEATURE_MSI_EXT_DEST_ID 15
+#define KVM_FEATURE_HOST_SUSPEND_TIME 16

#define KVM_HINTS_REALTIME 0

@@ -54,6 +55,7 @@
#define MSR_KVM_POLL_CONTROL 0x4b564d05
#define MSR_KVM_ASYNC_PF_INT 0x4b564d06
#define MSR_KVM_ASYNC_PF_ACK 0x4b564d07
+#define MSR_KVM_HOST_SUSPEND_TIME 0x4b564d08

struct kvm_steal_time {
__u64 steal;
@@ -64,6 +66,10 @@ struct kvm_steal_time {
__u32 pad[11];
};

+struct kvm_host_suspend_time {
+ __u64 suspend_time_ns;
+};
+
#define KVM_VCPU_PREEMPTED (1 << 0)
#define KVM_VCPU_FLUSH_TLB (1 << 1)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 6aee5768c86f..ff0304de7de9 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -22,6 +22,7 @@
#include <linux/pvclock_gtod.h>
#include <linux/compiler.h>
#include <linux/audit.h>
+#include <linux/kvm_host.h>

#include "tick-internal.h"
#include "ntp_internal.h"
--
2.31.1.498.g6c1eba8ee3d-goog