diff mbox

[3/6] KVM: X86: Make tsc_delta calculation a function of guest tsc

Message ID 20110418080324.GA2192@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Joerg Roedel April 18, 2011, 8:03 a.m. UTC
On Sat, Apr 16, 2011 at 12:09:17PM -0400, Jan Kiszka wrote:
> This patch appears to cause troubles to Linux guests on TSC clocksource
> and APIC highres timer. The first boot after qemu start is always fine,
> but after a reboot the guest timer appears to fire incorrectly or even
> not at all.

Hi Jan,

can you please test if this patch fixes the problem?

Comments

Jan Kiszka April 18, 2011, 9:12 a.m. UTC | #1
On 2011-04-18 10:03, Roedel, Joerg wrote:
> On Sat, Apr 16, 2011 at 12:09:17PM -0400, Jan Kiszka wrote:
>> This patch appears to cause troubles to Linux guests on TSC clocksource
>> and APIC highres timer. The first boot after qemu start is always fine,
>> but after a reboot the guest timer appears to fire incorrectly or even
>> not at all.
> 
> Hi Jan,
> 
> can you please test if this patch fixes the problem?
> 
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index bd57639..d7282ef 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -391,7 +391,6 @@ struct kvm_vcpu_arch {
>  	unsigned int hw_tsc_khz;
>  	unsigned int time_offset;
>  	struct page *time_page;
> -	u64 last_host_tsc;
>  	u64 last_guest_tsc;
>  	u64 last_kernel_ns;
>  	u64 last_tsc_nsec;
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 1d5a7f4..d8277aa 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2146,7 +2146,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
>  {
>  	kvm_x86_ops->vcpu_put(vcpu);
>  	kvm_put_guest_fpu(vcpu);
> -	vcpu->arch.last_host_tsc = native_read_tsc();
> +	kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
>  }
>  
>  static int is_efer_nx(void)
> 

Looks good, behaviour is now fine also after reboot.

Thanks,
Jan
Joerg Roedel April 18, 2011, 9:25 a.m. UTC | #2
On Mon, Apr 18, 2011 at 11:12:56AM +0200, Jan Kiszka wrote:

> Looks good, behaviour is now fine also after reboot.

Thanks for testing, I send it out together with another fix today.

	Joerg

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index bd57639..d7282ef 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -391,7 +391,6 @@  struct kvm_vcpu_arch {
 	unsigned int hw_tsc_khz;
 	unsigned int time_offset;
 	struct page *time_page;
-	u64 last_host_tsc;
 	u64 last_guest_tsc;
 	u64 last_kernel_ns;
 	u64 last_tsc_nsec;
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1d5a7f4..d8277aa 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2146,7 +2146,7 @@  void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
 {
 	kvm_x86_ops->vcpu_put(vcpu);
 	kvm_put_guest_fpu(vcpu);
-	vcpu->arch.last_host_tsc = native_read_tsc();
+	kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
 }
 
 static int is_efer_nx(void)