|
@@ -1146,10 +1146,9 @@ static u64 guest_read_tsc(void)
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * writes 'guest_tsc' into guest's timestamp counter "register"
|
|
|
|
- * guest_tsc = host_tsc + tsc_offset ==> tsc_offset = guest_tsc - host_tsc
|
|
|
|
|
|
+ * writes 'offset' into guest's timestamp counter offset register
|
|
*/
|
|
*/
|
|
-static void vmx_write_tsc_offset(u64 offset)
|
|
|
|
|
|
+static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
|
|
{
|
|
{
|
|
vmcs_write64(TSC_OFFSET, offset);
|
|
vmcs_write64(TSC_OFFSET, offset);
|
|
}
|
|
}
|
|
@@ -1224,7 +1223,6 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
|
|
{
|
|
{
|
|
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
|
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
|
struct shared_msr_entry *msr;
|
|
struct shared_msr_entry *msr;
|
|
- u64 host_tsc;
|
|
|
|
int ret = 0;
|
|
int ret = 0;
|
|
|
|
|
|
switch (msr_index) {
|
|
switch (msr_index) {
|
|
@@ -1254,8 +1252,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
|
|
vmcs_writel(GUEST_SYSENTER_ESP, data);
|
|
vmcs_writel(GUEST_SYSENTER_ESP, data);
|
|
break;
|
|
break;
|
|
case MSR_IA32_TSC:
|
|
case MSR_IA32_TSC:
|
|
- rdtscll(host_tsc);
|
|
|
|
- vmx_write_tsc_offset(data - host_tsc);
|
|
|
|
|
|
+ kvm_write_tsc(vcpu, data);
|
|
break;
|
|
break;
|
|
case MSR_IA32_CR_PAT:
|
|
case MSR_IA32_CR_PAT:
|
|
if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
|
|
if (vmcs_config.vmentry_ctrl & VM_ENTRY_LOAD_IA32_PAT) {
|
|
@@ -2653,7 +2650,7 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx)
|
|
vmx->vcpu.arch.cr4_guest_owned_bits |= X86_CR4_PGE;
|
|
vmx->vcpu.arch.cr4_guest_owned_bits |= X86_CR4_PGE;
|
|
vmcs_writel(CR4_GUEST_HOST_MASK, ~vmx->vcpu.arch.cr4_guest_owned_bits);
|
|
vmcs_writel(CR4_GUEST_HOST_MASK, ~vmx->vcpu.arch.cr4_guest_owned_bits);
|
|
|
|
|
|
- vmx_write_tsc_offset(0-native_read_tsc());
|
|
|
|
|
|
+ kvm_write_tsc(&vmx->vcpu, 0);
|
|
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -4348,6 +4345,8 @@ static struct kvm_x86_ops vmx_x86_ops = {
|
|
.set_supported_cpuid = vmx_set_supported_cpuid,
|
|
.set_supported_cpuid = vmx_set_supported_cpuid,
|
|
|
|
|
|
.has_wbinvd_exit = cpu_has_vmx_wbinvd_exit,
|
|
.has_wbinvd_exit = cpu_has_vmx_wbinvd_exit,
|
|
|
|
+
|
|
|
|
+ .write_tsc_offset = vmx_write_tsc_offset,
|
|
};
|
|
};
|
|
|
|
|
|
static int __init vmx_init(void)
|
|
static int __init vmx_init(void)
|