|
@@ -27,12 +27,14 @@
|
|
|
#include <linux/sched/clock.h>
|
|
|
#include <linux/mm.h>
|
|
|
|
|
|
+#include <asm/hypervisor.h>
|
|
|
#include <asm/mem_encrypt.h>
|
|
|
#include <asm/x86_init.h>
|
|
|
#include <asm/reboot.h>
|
|
|
#include <asm/kvmclock.h>
|
|
|
|
|
|
static int kvmclock __initdata = 1;
|
|
|
+static int kvmclock_vsyscall __initdata = 1;
|
|
|
static int msr_kvm_system_time __ro_after_init = MSR_KVM_SYSTEM_TIME;
|
|
|
static int msr_kvm_wall_clock __ro_after_init = MSR_KVM_WALL_CLOCK;
|
|
|
static u64 kvm_sched_clock_offset __ro_after_init;
|
|
@@ -44,6 +46,13 @@ static int __init parse_no_kvmclock(char *arg)
|
|
|
}
|
|
|
early_param("no-kvmclock", parse_no_kvmclock);
|
|
|
|
|
|
+static int __init parse_no_kvmclock_vsyscall(char *arg)
|
|
|
+{
|
|
|
+ kvmclock_vsyscall = 0;
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+early_param("no-kvmclock-vsyscall", parse_no_kvmclock_vsyscall);
|
|
|
+
|
|
|
/* Aligned to page sizes to match whats mapped via vsyscalls to userspace */
|
|
|
#define HV_CLOCK_SIZE (sizeof(struct pvclock_vsyscall_time_info) * NR_CPUS)
|
|
|
|
|
@@ -228,6 +237,24 @@ static void kvm_shutdown(void)
|
|
|
native_machine_shutdown();
|
|
|
}
|
|
|
|
|
|
+static int __init kvm_setup_vsyscall_timeinfo(void)
|
|
|
+{
|
|
|
+#ifdef CONFIG_X86_64
|
|
|
+ u8 flags;
|
|
|
+
|
|
|
+ if (!hv_clock || !kvmclock_vsyscall)
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ flags = pvclock_read_flags(&hv_clock[0].pvti);
|
|
|
+ if (!(flags & PVCLOCK_TSC_STABLE_BIT))
|
|
|
+ return 1;
|
|
|
+
|
|
|
+ kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK;
|
|
|
+#endif
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+early_initcall(kvm_setup_vsyscall_timeinfo);
|
|
|
+
|
|
|
void __init kvmclock_init(void)
|
|
|
{
|
|
|
u8 flags;
|
|
@@ -272,20 +299,3 @@ void __init kvmclock_init(void)
|
|
|
clocksource_register_hz(&kvm_clock, NSEC_PER_SEC);
|
|
|
pv_info.name = "KVM";
|
|
|
}
|
|
|
-
|
|
|
-int __init kvm_setup_vsyscall_timeinfo(void)
|
|
|
-{
|
|
|
-#ifdef CONFIG_X86_64
|
|
|
- u8 flags;
|
|
|
-
|
|
|
- if (!hv_clock)
|
|
|
- return 0;
|
|
|
-
|
|
|
- flags = pvclock_read_flags(&hv_clock[0].pvti);
|
|
|
- if (!(flags & PVCLOCK_TSC_STABLE_BIT))
|
|
|
- return 1;
|
|
|
-
|
|
|
- kvm_clock.archdata.vclock_mode = VCLOCK_PVCLOCK;
|
|
|
-#endif
|
|
|
- return 0;
|
|
|
-}
|