diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-01-07 07:50:38 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-01-07 07:50:38 -0500 |
commit | e5e57e7a03b1cdcb98e4aed135def2a08cbf3257 (patch) | |
tree | 7e294ba757bc94d07bddeafb4eafdb4aa562bd31 | |
parent | 168309855a7d1e16db751e9c647119fe2d2dc878 (diff) |
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 <pjp@fedoraproject.org>
Fixes: 0185604c2d82c560dab2f2933a18f797e74ab5a8
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/i8254.c | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 08116ff227cc..b0ea42b78ccd 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -420,6 +420,7 @@ void kvm_pit_load_count(struct kvm *kvm, int channel, u32 val, int hpet_legacy_s | |||
420 | u8 saved_mode; | 420 | u8 saved_mode; |
421 | if (hpet_legacy_start) { | 421 | if (hpet_legacy_start) { |
422 | /* save existing mode for later reenablement */ | 422 | /* save existing mode for later reenablement */ |
423 | WARN_ON(channel != 0); | ||
423 | saved_mode = kvm->arch.vpit->pit_state.channels[0].mode; | 424 | saved_mode = kvm->arch.vpit->pit_state.channels[0].mode; |
424 | kvm->arch.vpit->pit_state.channels[0].mode = 0xff; /* disable timer */ | 425 | kvm->arch.vpit->pit_state.channels[0].mode = 0xff; /* disable timer */ |
425 | pit_load_count(kvm, channel, val); | 426 | pit_load_count(kvm, channel, val); |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 7ffc224bbe41..97592e190413 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3606,7 +3606,8 @@ static int kvm_vm_ioctl_set_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps) | |||
3606 | sizeof(kvm->arch.vpit->pit_state.channels)); | 3606 | sizeof(kvm->arch.vpit->pit_state.channels)); |
3607 | kvm->arch.vpit->pit_state.flags = ps->flags; | 3607 | kvm->arch.vpit->pit_state.flags = ps->flags; |
3608 | for (i = 0; i < 3; i++) | 3608 | 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); | ||
3610 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); | 3611 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); |
3611 | return 0; | 3612 | return 0; |
3612 | } | 3613 | } |