diff options
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/i8254.c | 11 | ||||
-rw-r--r-- | arch/x86/kvm/i8254.h | 1 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 6 |
3 files changed, 15 insertions, 3 deletions
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c index 11c6725fb798..8772dc946823 100644 --- a/arch/x86/kvm/i8254.c +++ b/arch/x86/kvm/i8254.c | |||
@@ -545,6 +545,12 @@ struct kvm_pit *kvm_create_pit(struct kvm *kvm) | |||
545 | if (!pit) | 545 | if (!pit) |
546 | return NULL; | 546 | return NULL; |
547 | 547 | ||
548 | mutex_lock(&kvm->lock); | ||
549 | pit->irq_source_id = kvm_request_irq_source_id(kvm); | ||
550 | mutex_unlock(&kvm->lock); | ||
551 | if (pit->irq_source_id < 0) | ||
552 | return NULL; | ||
553 | |||
548 | mutex_init(&pit->pit_state.lock); | 554 | mutex_init(&pit->pit_state.lock); |
549 | mutex_lock(&pit->pit_state.lock); | 555 | mutex_lock(&pit->pit_state.lock); |
550 | spin_lock_init(&pit->pit_state.inject_lock); | 556 | spin_lock_init(&pit->pit_state.inject_lock); |
@@ -587,6 +593,7 @@ void kvm_free_pit(struct kvm *kvm) | |||
587 | mutex_lock(&kvm->arch.vpit->pit_state.lock); | 593 | mutex_lock(&kvm->arch.vpit->pit_state.lock); |
588 | timer = &kvm->arch.vpit->pit_state.pit_timer.timer; | 594 | timer = &kvm->arch.vpit->pit_state.pit_timer.timer; |
589 | hrtimer_cancel(timer); | 595 | hrtimer_cancel(timer); |
596 | kvm_free_irq_source_id(kvm, kvm->arch.vpit->irq_source_id); | ||
590 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); | 597 | mutex_unlock(&kvm->arch.vpit->pit_state.lock); |
591 | kfree(kvm->arch.vpit); | 598 | kfree(kvm->arch.vpit); |
592 | } | 599 | } |
@@ -595,8 +602,8 @@ void kvm_free_pit(struct kvm *kvm) | |||
595 | static void __inject_pit_timer_intr(struct kvm *kvm) | 602 | static void __inject_pit_timer_intr(struct kvm *kvm) |
596 | { | 603 | { |
597 | mutex_lock(&kvm->lock); | 604 | mutex_lock(&kvm->lock); |
598 | kvm_set_irq(kvm, 0, 1); | 605 | kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 1); |
599 | kvm_set_irq(kvm, 0, 0); | 606 | kvm_set_irq(kvm, kvm->arch.vpit->irq_source_id, 0, 0); |
600 | mutex_unlock(&kvm->lock); | 607 | mutex_unlock(&kvm->lock); |
601 | } | 608 | } |
602 | 609 | ||
diff --git a/arch/x86/kvm/i8254.h b/arch/x86/kvm/i8254.h index e436d4983aa1..4178022b97aa 100644 --- a/arch/x86/kvm/i8254.h +++ b/arch/x86/kvm/i8254.h | |||
@@ -44,6 +44,7 @@ struct kvm_pit { | |||
44 | struct kvm_io_device speaker_dev; | 44 | struct kvm_io_device speaker_dev; |
45 | struct kvm *kvm; | 45 | struct kvm *kvm; |
46 | struct kvm_kpit_state pit_state; | 46 | struct kvm_kpit_state pit_state; |
47 | int irq_source_id; | ||
47 | }; | 48 | }; |
48 | 49 | ||
49 | #define KVM_PIT_BASE_ADDRESS 0x40 | 50 | #define KVM_PIT_BASE_ADDRESS 0x40 |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4f0677d1eae8..f1f8ff2f1fa2 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -1742,7 +1742,8 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
1742 | goto out; | 1742 | goto out; |
1743 | if (irqchip_in_kernel(kvm)) { | 1743 | if (irqchip_in_kernel(kvm)) { |
1744 | mutex_lock(&kvm->lock); | 1744 | mutex_lock(&kvm->lock); |
1745 | kvm_set_irq(kvm, irq_event.irq, irq_event.level); | 1745 | kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, |
1746 | irq_event.irq, irq_event.level); | ||
1746 | mutex_unlock(&kvm->lock); | 1747 | mutex_unlock(&kvm->lock); |
1747 | r = 0; | 1748 | r = 0; |
1748 | } | 1749 | } |
@@ -4013,6 +4014,9 @@ struct kvm *kvm_arch_create_vm(void) | |||
4013 | INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); | 4014 | INIT_LIST_HEAD(&kvm->arch.active_mmu_pages); |
4014 | INIT_LIST_HEAD(&kvm->arch.assigned_dev_head); | 4015 | INIT_LIST_HEAD(&kvm->arch.assigned_dev_head); |
4015 | 4016 | ||
4017 | /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */ | ||
4018 | set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap); | ||
4019 | |||
4016 | return kvm; | 4020 | return kvm; |
4017 | } | 4021 | } |
4018 | 4022 | ||