Skip to content

Commit e5e57e7

Browse files
committed
kvm: x86: only channel 0 of the i8254 is linked to the HPET
While setting the KVM PIT counters in 'kvm_pit_load_count', if 'hpet_legacy_start' is set, the function disables the timer on channel[0], instead of the respective index 'channel'. This is because channels 1-3 are not linked to the HPET. Fix the caller to only activate the special HPET processing for channel 0. Reported-by: P J P <[email protected]> Fixes: 0185604 Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 1683098 commit e5e57e7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

arch/x86/kvm/i8254.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val, int hpet_legacy_s
420420
u8 saved_mode;
421421
if (hpet_legacy_start) {
422422
/* save existing mode for later reenablement */
423+
WARN_ON(channel != 0);
423424
saved_mode = kvm->arch.vpit->pit_state.channels[0].mode;
424425
kvm->arch.vpit->pit_state.channels[0].mode = 0xff; /* disable timer */
425426
pit_load_count(kvm, channel, val);

arch/x86/kvm/x86.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3606,7 +3606,8 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
36063606
sizeof(kvm->arch.vpit->pit_state.channels));
36073607
kvm->arch.vpit->pit_state.flags = ps->flags;
36083608
for (i = 0; i < 3; i++)
3609-
kvm_pit_load_count(kvm, i, kvm->arch.vpit->pit_state.channels[i].count, start);
3609+
kvm_pit_load_count(kvm, i, kvm->arch.vpit->pit_state.channels[i].count,
3610+
start && i == 0);
36103611
mutex_unlock(&kvm->arch.vpit->pit_state.lock);
36113612
return 0;
36123613
}

0 commit comments

Comments
 (0)