KVM: x86: No wrap around for lapic timer
PATCH 1/1 KVM: x86: No wrap around for lapic timer
Or would we meet 585 years later? :)
Seriously, this wrap around hide implicit error...
Reminder by Alexander Graf.
Signed-off-by Sheng Yang <[email protected]>
--- arch/x86/kvm/lapic.c | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-)
arch/x86/kvm/lapic.c +2 -11
@@ -524,18 +524,9 @@ static u32 apic_get_tmcct(struct kvm_lapic *apic)if (tmcct ==0 )return 0 ; -if (unlikely (ktime_to_ns (now) <= -ktime_to_ns (apic->timer.last_update))) { -/* Wrap around */ - passed =ktime_add (( { - (ktime_t ) { - .tv64 =KTIME_MAX - - (apic->timer.last_update).tv64}; } - ), now); -apic_debug ("time elapsed\n" ); - }else - passed =ktime_sub (now, apic->timer.last_update); +BUG_ON (ktime_to_ns (now) <=ktime_to_ns (apic->timer.last_update)); + passed =ktime_sub (now, apic->timer.last_update); counter_passed =div64_u64 (ktime_to_ns (passed), (APIC_BUS_CYCLE_NS * apic->timer.divide_count));
Signature · 1 line
1.5.4.5