Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 54085
b: refs/heads/master
c: 0cc5064
h: refs/heads/master
i:
  54083: c8bfa68
v: v3
  • Loading branch information
Avi Kivity committed May 3, 2007
1 parent 1e60afa commit 48b9fac
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d28c6cfbbc5e2d4fccfe6d733995ed5971ca87f6
refs/heads/master: 0cc5064d335543a72c5ef904a3f528966fa3f2d2
1 change: 1 addition & 0 deletions trunk/drivers/kvm/kvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ struct kvm_vcpu {
struct mutex mutex;
int cpu;
int launched;
u64 host_tsc;
struct kvm_run *run;
int interrupt_window_open;
unsigned long irq_summary; /* bit vector: 1 per word in irq_pending */
Expand Down
21 changes: 17 additions & 4 deletions trunk/drivers/kvm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ static void init_vmcb(struct vmcb *vmcb)
{
struct vmcb_control_area *control = &vmcb->control;
struct vmcb_save_area *save = &vmcb->save;
u64 tsc;

control->intercept_cr_read = INTERCEPT_CR0_MASK |
INTERCEPT_CR3_MASK |
Expand Down Expand Up @@ -517,8 +516,7 @@ static void init_vmcb(struct vmcb *vmcb)

control->iopm_base_pa = iopm_base;
control->msrpm_base_pa = msrpm_base;
rdtscll(tsc);
control->tsc_offset = -tsc;
control->tsc_offset = 0;
control->int_ctl = V_INTR_MASKING_MASK;

init_seg(&save->es);
Expand Down Expand Up @@ -606,11 +604,26 @@ static void svm_free_vcpu(struct kvm_vcpu *vcpu)

static void svm_vcpu_load(struct kvm_vcpu *vcpu)
{
get_cpu();
int cpu;

cpu = get_cpu();
if (unlikely(cpu != vcpu->cpu)) {
u64 tsc_this, delta;

/*
* Make sure that the guest sees a monotonically
* increasing TSC.
*/
rdtscll(tsc_this);
delta = vcpu->host_tsc - tsc_this;
vcpu->svm->vmcb->control.tsc_offset += delta;
vcpu->cpu = cpu;
}
}

static void svm_vcpu_put(struct kvm_vcpu *vcpu)
{
rdtscll(vcpu->host_tsc);
put_cpu();
}

Expand Down

0 comments on commit 48b9fac

Please sign in to comment.