diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2019-10-10 06:49:22 -0400 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2019-10-22 07:31:22 -0400 |
commit | 49dedf0dd0da073b3a0146a62c768887aea13508 (patch) | |
tree | 83ac79249db79a9f58568c709ca94af6f8fe4b43 | |
parent | b4fdcf6056d9057fe762bd6d8060e3ab9949efea (diff) |
kvm: clear kvmclock MSR on reset
After resetting the vCPU, the kvmclock MSR keeps the previous value but it is
not enabled. This can be confusing, so fix it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/x86.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 41aecc4c52d9..5863c38108d9 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -2536,6 +2536,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data) | |||
2536 | static void kvmclock_reset(struct kvm_vcpu *vcpu) | 2536 | static void kvmclock_reset(struct kvm_vcpu *vcpu) |
2537 | { | 2537 | { |
2538 | vcpu->arch.pv_time_enabled = false; | 2538 | vcpu->arch.pv_time_enabled = false; |
2539 | vcpu->arch.time = 0; | ||
2539 | } | 2540 | } |
2540 | 2541 | ||
2541 | static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa) | 2542 | static void kvm_vcpu_flush_tlb(struct kvm_vcpu *vcpu, bool invalidate_gpa) |
@@ -2701,8 +2702,6 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) | |||
2701 | case MSR_KVM_SYSTEM_TIME: { | 2702 | case MSR_KVM_SYSTEM_TIME: { |
2702 | struct kvm_arch *ka = &vcpu->kvm->arch; | 2703 | struct kvm_arch *ka = &vcpu->kvm->arch; |
2703 | 2704 | ||
2704 | kvmclock_reset(vcpu); | ||
2705 | |||
2706 | if (vcpu->vcpu_id == 0 && !msr_info->host_initiated) { | 2705 | if (vcpu->vcpu_id == 0 && !msr_info->host_initiated) { |
2707 | bool tmp = (msr == MSR_KVM_SYSTEM_TIME); | 2706 | bool tmp = (msr == MSR_KVM_SYSTEM_TIME); |
2708 | 2707 | ||
@@ -2716,14 +2715,13 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info) | |||
2716 | kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu); | 2715 | kvm_make_request(KVM_REQ_GLOBAL_CLOCK_UPDATE, vcpu); |
2717 | 2716 | ||
2718 | /* we verify if the enable bit is set... */ | 2717 | /* we verify if the enable bit is set... */ |
2718 | vcpu->arch.pv_time_enabled = false; | ||
2719 | if (!(data & 1)) | 2719 | if (!(data & 1)) |
2720 | break; | 2720 | break; |
2721 | 2721 | ||
2722 | if (kvm_gfn_to_hva_cache_init(vcpu->kvm, | 2722 | if (!kvm_gfn_to_hva_cache_init(vcpu->kvm, |
2723 | &vcpu->arch.pv_time, data & ~1ULL, | 2723 | &vcpu->arch.pv_time, data & ~1ULL, |
2724 | sizeof(struct pvclock_vcpu_time_info))) | 2724 | sizeof(struct pvclock_vcpu_time_info))) |
2725 | vcpu->arch.pv_time_enabled = false; | ||
2726 | else | ||
2727 | vcpu->arch.pv_time_enabled = true; | 2725 | vcpu->arch.pv_time_enabled = true; |
2728 | 2726 | ||
2729 | break; | 2727 | break; |