diff options
author | Glauber de Oliveira Costa <gcosta@redhat.com> | 2008-02-15 14:52:47 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-04-27 04:53:22 -0400 |
commit | 18068523d3a0b41fcee5b53cdb437a0ab4d65e4b (patch) | |
tree | cbedbd4371cb57c34728137988a7433ae736d79a /include | |
parent | 24e09cbf480a72f9c952af4ca77b159503dca44b (diff) |
KVM: paravirtualized clocksource: host part
This is the host part of kvm clocksource implementation. As it does
not include clockevents, it is a fairly simple implementation. We
only have to register a per-vcpu area, and start writing to it periodically.
The area is binary compatible with xen, as we use the same shadow_info
structure.
[marcelo: fix bad_page on MSR_KVM_SYSTEM_TIME]
[avi: save full value of the msr, even if enable bit is clear]
[avi: clear previous value of time_page]
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-x86/kvm_host.h | 7 | ||||
-rw-r--r-- | include/asm-x86/kvm_para.h | 25 | ||||
-rw-r--r-- | include/linux/kvm.h | 1 |
3 files changed, 33 insertions, 0 deletions
diff --git a/include/asm-x86/kvm_host.h b/include/asm-x86/kvm_host.h index 623249890a0b..90c80fd830fc 100644 --- a/include/asm-x86/kvm_host.h +++ b/include/asm-x86/kvm_host.h | |||
@@ -262,6 +262,11 @@ struct kvm_vcpu_arch { | |||
262 | /* emulate context */ | 262 | /* emulate context */ |
263 | 263 | ||
264 | struct x86_emulate_ctxt emulate_ctxt; | 264 | struct x86_emulate_ctxt emulate_ctxt; |
265 | |||
266 | gpa_t time; | ||
267 | struct kvm_vcpu_time_info hv_clock; | ||
268 | unsigned int time_offset; | ||
269 | struct page *time_page; | ||
265 | }; | 270 | }; |
266 | 271 | ||
267 | struct kvm_mem_alias { | 272 | struct kvm_mem_alias { |
@@ -288,6 +293,8 @@ struct kvm_arch{ | |||
288 | int round_robin_prev_vcpu; | 293 | int round_robin_prev_vcpu; |
289 | unsigned int tss_addr; | 294 | unsigned int tss_addr; |
290 | struct page *apic_access_page; | 295 | struct page *apic_access_page; |
296 | |||
297 | gpa_t wall_clock; | ||
291 | }; | 298 | }; |
292 | 299 | ||
293 | struct kvm_vm_stat { | 300 | struct kvm_vm_stat { |
diff --git a/include/asm-x86/kvm_para.h b/include/asm-x86/kvm_para.h index c6f3fd8d8c53..5ab7d3dbd357 100644 --- a/include/asm-x86/kvm_para.h +++ b/include/asm-x86/kvm_para.h | |||
@@ -10,10 +10,35 @@ | |||
10 | * paravirtualization, the appropriate feature bit should be checked. | 10 | * paravirtualization, the appropriate feature bit should be checked. |
11 | */ | 11 | */ |
12 | #define KVM_CPUID_FEATURES 0x40000001 | 12 | #define KVM_CPUID_FEATURES 0x40000001 |
13 | #define KVM_FEATURE_CLOCKSOURCE 0 | ||
14 | |||
15 | #define MSR_KVM_WALL_CLOCK 0x11 | ||
16 | #define MSR_KVM_SYSTEM_TIME 0x12 | ||
13 | 17 | ||
14 | #ifdef __KERNEL__ | 18 | #ifdef __KERNEL__ |
15 | #include <asm/processor.h> | 19 | #include <asm/processor.h> |
16 | 20 | ||
21 | /* xen binary-compatible interface. See xen headers for details */ | ||
22 | struct kvm_vcpu_time_info { | ||
23 | uint32_t version; | ||
24 | uint32_t pad0; | ||
25 | uint64_t tsc_timestamp; | ||
26 | uint64_t system_time; | ||
27 | uint32_t tsc_to_system_mul; | ||
28 | int8_t tsc_shift; | ||
29 | int8_t pad[3]; | ||
30 | } __attribute__((__packed__)); /* 32 bytes */ | ||
31 | |||
32 | struct kvm_wall_clock { | ||
33 | uint32_t wc_version; | ||
34 | uint32_t wc_sec; | ||
35 | uint32_t wc_nsec; | ||
36 | } __attribute__((__packed__)); | ||
37 | |||
38 | |||
39 | extern void kvmclock_init(void); | ||
40 | |||
41 | |||
17 | /* This instruction is vmcall. On non-VT architectures, it will generate a | 42 | /* This instruction is vmcall. On non-VT architectures, it will generate a |
18 | * trap that we will then rewrite to the appropriate instruction. | 43 | * trap that we will then rewrite to the appropriate instruction. |
19 | */ | 44 | */ |
diff --git a/include/linux/kvm.h b/include/linux/kvm.h index c1ec04fd000d..94540b3c6872 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h | |||
@@ -233,6 +233,7 @@ struct kvm_vapic_addr { | |||
233 | #define KVM_CAP_SET_TSS_ADDR 4 | 233 | #define KVM_CAP_SET_TSS_ADDR 4 |
234 | #define KVM_CAP_VAPIC 6 | 234 | #define KVM_CAP_VAPIC 6 |
235 | #define KVM_CAP_EXT_CPUID 7 | 235 | #define KVM_CAP_EXT_CPUID 7 |
236 | #define KVM_CAP_CLOCKSOURCE 8 | ||
236 | 237 | ||
237 | /* | 238 | /* |
238 | * ioctls for VM fds | 239 | * ioctls for VM fds |