Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread Wanpeng Li
2016-06-29 6:55 GMT+08:00 Wanpeng Li : > 2016-06-29 4:07 GMT+08:00 Paolo Bonzini : >> >> >> On 28/06/2016 20:34, yunhong jiang wrote: >>> Paolo, thanks for reply. >>> >>> Which race window you are talking about? Is it the >>> kvm_lapic_switch_to_hv_timer()? If yes, hope we will not forgot it once t

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread Wanpeng Li
2016-06-29 4:07 GMT+08:00 Paolo Bonzini : > > > On 28/06/2016 20:34, yunhong jiang wrote: >> Paolo, thanks for reply. >> >> Which race window you are talking about? Is it the >> kvm_lapic_switch_to_hv_timer()? If yes, hope we will not forgot it once the >> lapic timer is not pinned anymore in futur

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread Paolo Bonzini
On 28/06/2016 20:34, yunhong jiang wrote: > Paolo, thanks for reply. > > Which race window you are talking about? Is it the > kvm_lapic_switch_to_hv_timer()? If yes, hope we will not forgot it once the > lapic timer is not pinned anymore in future. Yes, it's that one. This is a good point agai

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread yunhong jiang
On Tue, 28 Jun 2016 13:56:38 -0400 (EDT) Paolo Bonzini wrote: > > > > > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > > > index fdc05ae..b15e32a 100644 > > > --- a/arch/x86/kvm/lapic.c > > > +++ b/arch/x86/kvm/lapic.c > > > @@ -1454,11 +1454,18 @@ static void start_apic_timer(struc

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread Paolo Bonzini
> > diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c > > index fdc05ae..b15e32a 100644 > > --- a/arch/x86/kvm/lapic.c > > +++ b/arch/x86/kvm/lapic.c > > @@ -1454,11 +1454,18 @@ static void start_apic_timer(struct kvm_lapic > > *apic) /* lapic timer in tsc deadline mode */ > >

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread yunhong jiang
On Tue, 28 Jun 2016 14:54:19 +0800 Wanpeng Li wrote: > INFO: rcu_sched detected stalls on CPUs/tasks: > 1-...: (11800 GPs behind) idle=45d/140/0 softirq=0/0 > fqs=21663 (detected by 0, t=65016 jiffies, g=11500, c=11499, q=719) > Task dump for CPU 1: > qemu-system-x86 R running task

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread Wanpeng Li
2016-06-28 16:43 GMT+08:00 Paolo Bonzini : > > > On 28/06/2016 08:15, Wanpeng Li wrote: >> 2016-06-27 21:11 GMT+08:00 Paolo Bonzini : >>> If the TSC deadline timer is programmed really close to the deadline or >>> even in the past, the computation in vmx_set_hv_timer can underflow and >>> cause del

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-28 Thread Paolo Bonzini
On 28/06/2016 08:15, Wanpeng Li wrote: > 2016-06-27 21:11 GMT+08:00 Paolo Bonzini : >> If the TSC deadline timer is programmed really close to the deadline or >> even in the past, the computation in vmx_set_hv_timer can underflow and >> cause delta_tsc to be set to a huge value. This generally r

[PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-27 Thread Wanpeng Li
INFO: rcu_sched detected stalls on CPUs/tasks: 1-...: (11800 GPs behind) idle=45d/140/0 softirq=0/0 fqs=21663 (detected by 0, t=65016 jiffies, g=11500, c=11499, q=719) Task dump for CPU 1: qemu-system-x86 R running task0 3529 3525 0x00080808 8802021791a0 88021289

Re: [PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-27 Thread Wanpeng Li
2016-06-27 21:11 GMT+08:00 Paolo Bonzini : > If the TSC deadline timer is programmed really close to the deadline or > even in the past, the computation in vmx_set_hv_timer can underflow and > cause delta_tsc to be set to a huge value. This generally results > in vmx_set_hv_timer returning -ERANGE

[PATCH] KVM: vmx: fix underflow in TSC deadline calculation

2016-06-27 Thread Paolo Bonzini
If the TSC deadline timer is programmed really close to the deadline or even in the past, the computation in vmx_set_hv_timer can underflow and cause delta_tsc to be set to a huge value. This generally results in vmx_set_hv_timer returning -ERANGE, but we can fix it by limiting delta_tsc to be pos