Skip to content

Commit 94be4b8

Browse files
Wanpeng Libonzini
authored andcommitted
KVM: LAPIC: Also cancel preemption timer when disarm LAPIC timer
The timer is disarmed when switching between TSC deadline and other modes, we should set everything to disarmed state, however, LAPIC timer can be emulated by preemption timer, it still works if vmx->hv_deadline_timer is not -1. This patch also cancels preemption timer when disarm LAPIC timer. Signed-off-by: Wanpeng Li <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 428b8f1 commit 94be4b8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/x86/kvm/lapic.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,8 @@ static void limit_periodic_timer_frequency(struct kvm_lapic *apic)
14451445
}
14461446
}
14471447

1448+
static void cancel_hv_timer(struct kvm_lapic *apic);
1449+
14481450
static void apic_update_lvtt(struct kvm_lapic *apic)
14491451
{
14501452
u32 timer_mode = kvm_lapic_get_reg(apic, APIC_LVTT) &
@@ -1454,6 +1456,10 @@ static void apic_update_lvtt(struct kvm_lapic *apic)
14541456
if (apic_lvtt_tscdeadline(apic) != (timer_mode ==
14551457
APIC_LVT_TIMER_TSCDEADLINE)) {
14561458
hrtimer_cancel(&apic->lapic_timer.timer);
1459+
preempt_disable();
1460+
if (apic->lapic_timer.hv_timer_in_use)
1461+
cancel_hv_timer(apic);
1462+
preempt_enable();
14571463
kvm_lapic_set_reg(apic, APIC_TMICT, 0);
14581464
apic->lapic_timer.period = 0;
14591465
apic->lapic_timer.tscdeadline = 0;

0 commit comments

Comments
 (0)