kvmclock.c (c38f62b08d800104fa9b0e9d6e9141459986c06d) kvmclock.c (3b5d56b9317fa7b5407dff1aa7b115bf6cdbd494)
1/* KVM paravirtual clock driver. A clocksource implementation
2 Copyright (C) 2008 Glauber de Oliveira Costa, Red Hat Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8

--- 8 unchanged lines hidden (view full) ---

17*/
18
19#include <linux/clocksource.h>
20#include <linux/kvm_para.h>
21#include <asm/pvclock.h>
22#include <asm/msr.h>
23#include <asm/apic.h>
24#include <linux/percpu.h>
1/* KVM paravirtual clock driver. A clocksource implementation
2 Copyright (C) 2008 Glauber de Oliveira Costa, Red Hat Inc.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8

--- 8 unchanged lines hidden (view full) ---

17*/
18
19#include <linux/clocksource.h>
20#include <linux/kvm_para.h>
21#include <asm/pvclock.h>
22#include <asm/msr.h>
23#include <asm/apic.h>
24#include <linux/percpu.h>
25#include <linux/hardirq.h>
25
26#include <asm/x86_init.h>
27#include <asm/reboot.h>
28
29static int kvmclock = 1;
30static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
31static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
32

--- 76 unchanged lines hidden (view full) ---

109
110 khz = kvm_get_tsc_khz();
111
112 lpj = ((u64)khz * 1000);
113 do_div(lpj, HZ);
114 preset_lpj = lpj;
115}
116
26
27#include <asm/x86_init.h>
28#include <asm/reboot.h>
29
30static int kvmclock = 1;
31static int msr_kvm_system_time = MSR_KVM_SYSTEM_TIME;
32static int msr_kvm_wall_clock = MSR_KVM_WALL_CLOCK;
33

--- 76 unchanged lines hidden (view full) ---

110
111 khz = kvm_get_tsc_khz();
112
113 lpj = ((u64)khz * 1000);
114 do_div(lpj, HZ);
115 preset_lpj = lpj;
116}
117
118bool kvm_check_and_clear_guest_paused(void)
119{
120 bool ret = false;
121 struct pvclock_vcpu_time_info *src;
122
123 /*
124 * per_cpu() is safe here because this function is only called from
125 * timer functions where preemption is already disabled.
126 */
127 WARN_ON(!in_atomic());
128 src = &__get_cpu_var(hv_clock);
129 if ((src->flags & PVCLOCK_GUEST_STOPPED) != 0) {
130 __this_cpu_and(hv_clock.flags, ~PVCLOCK_GUEST_STOPPED);
131 ret = true;
132 }
133
134 return ret;
135}
136EXPORT_SYMBOL_GPL(kvm_check_and_clear_guest_paused);
137
117static struct clocksource kvm_clock = {
118 .name = "kvm-clock",
119 .read = kvm_clock_get_cycles,
120 .rating = 400,
121 .mask = CLOCKSOURCE_MASK(64),
122 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
123};
124

--- 96 unchanged lines hidden ---
138static struct clocksource kvm_clock = {
139 .name = "kvm-clock",
140 .read = kvm_clock_get_cycles,
141 .rating = 400,
142 .mask = CLOCKSOURCE_MASK(64),
143 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
144};
145

--- 96 unchanged lines hidden ---