[lkml]   [2011]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[PATCH 06/16] KVM-HDR: Implement wallclock over KVM - KVM Virtual Memory
As a proof of concept to KVM - Kernel Virtual Memory, this patch
implements wallclock grabbing on top of it. At first, it may seem
as a waste of work to just redo it, since it is working well. But over the
time, other MSRs were added - think ASYNC_PF - and more will probably come.
After this patch, we won't need to ever add another virtual MSR to KVM.

If the hypervisor fails to register the memory area, we switch back to legacy
behavior on things that were already present - like kvm clock.

This patch contains the hypervisor implementation for it. I am keeping it
separate from the headers to facilitate backports to people who wants to backport
the kernel part but not the hypervisor, or the other way around.

Signed-off-by: Glauber Costa <>
CC: Avi Kivity <>
arch/x86/kvm/x86.c | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 4ee9c87..a232a36 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1540,16 +1540,26 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 data)
struct kvm_memory_area area_desc;
+ u64 wall_data;

kvm_read_guest(vcpu->kvm, data, &area_desc, sizeof(area_desc));
area_desc.result = 0xF;

+ if (area_desc.type == KVM_AREA_WALLCLOCK) {
+ kvm_read_guest(vcpu->kvm, area_desc.base,
+ &wall_data, area_desc.size);
+ vcpu->kvm->arch.wall_clock = wall_data;
+ kvm_write_wall_clock(vcpu->kvm, wall_data);
+ goto rma_out;
+ }
if (vcpu->kvm->register_mem_area_uspace) {
vcpu->run->exit_reason = KVM_EXIT_X86_MSR_OP;
vcpu->run->msr.msr_data = data;
return 1;
+ area_desc.result = 0;
kvm_write_guest(vcpu->kvm, data, &area_desc, sizeof(area_desc));

 \ /
  Last update: 2011-01-24 19:11    [W:0.177 / U:1.284 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site