diff options
| -rw-r--r-- | arch/ia64/include/asm/kvm_host.h | 3 | ||||
| -rw-r--r-- | arch/ia64/kvm/kvm-ia64.c | 8 | ||||
| -rw-r--r-- | arch/x86/include/asm/kvm_host.h | 3 | ||||
| -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 | ||||
| -rw-r--r-- | include/linux/kvm_host.h | 7 | ||||
| -rw-r--r-- | virt/kvm/irq_comm.c | 42 | ||||
| -rw-r--r-- | virt/kvm/kvm_main.c | 12 |
9 files changed, 79 insertions, 14 deletions
diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h index 85db124d37f6..04c0b88f7b3a 100644 --- a/arch/ia64/include/asm/kvm_host.h +++ b/arch/ia64/include/asm/kvm_host.h | |||
| @@ -417,6 +417,9 @@ struct kvm_arch { | |||
| 417 | struct list_head assigned_dev_head; | 417 | struct list_head assigned_dev_head; |
| 418 | struct dmar_domain *intel_iommu_domain; | 418 | struct dmar_domain *intel_iommu_domain; |
| 419 | struct hlist_head irq_ack_notifier_list; | 419 | struct hlist_head irq_ack_notifier_list; |
| 420 | |||
| 421 | unsigned long irq_sources_bitmap; | ||
| 422 | unsigned long irq_states[KVM_IOAPIC_NUM_PINS]; | ||
| 420 | }; | 423 | }; |
| 421 | 424 | ||
| 422 | union cpuid3_t { | 425 | union cpuid3_t { |
diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c index a312c9e9b9ef..8a2b13ff0aff 100644 --- a/arch/ia64/kvm/kvm-ia64.c +++ b/arch/ia64/kvm/kvm-ia64.c | |||
| @@ -778,6 +778,9 @@ static void kvm_init_vm(struct kvm *kvm) | |||
| 778 | kvm_build_io_pmt(kvm); | 778 | kvm_build_io_pmt(kvm); |
| 779 | 779 | ||
| 780 | INIT_LIST_HEAD(&kvm->arch.assigned_dev_head); | 780 | INIT_LIST_HEAD(&kvm->arch.assigned_dev_head); |
| 781 | |||
| 782 | /* Reserve bit 0 of irq_sources_bitmap for userspace irq source */ | ||
| 783 | set_bit(KVM_USERSPACE_IRQ_SOURCE_ID, &kvm->arch.irq_sources_bitmap); | ||
| 781 | } | 784 | } |
| 782 | 785 | ||
| 783 | struct kvm *kvm_arch_create_vm(void) | 786 | struct kvm *kvm_arch_create_vm(void) |
| @@ -941,9 +944,8 @@ long kvm_arch_vm_ioctl(struct file *filp, | |||
| 941 | goto out; | 944 | goto out; |
| 942 | if (irqchip_in_kernel(kvm)) { | 945 | if (irqchip_in_kernel(kvm)) { |
| 943 | mutex_lock(&kvm->lock); | 946 | mutex_lock(&kvm->lock); |
| 944 | kvm_ioapic_set_irq(kvm->arch.vioapic, | 947 | kvm_set_irq(kvm, KVM_USERSPACE_IRQ_SOURCE_ID, |
| 945 | irq_event.irq, | 948 | irq_event.irq, irq_event.level); |
| 946 | irq_event.level); | ||
| 947 | mutex_unlock(&kvm->lock); | 949 | mutex_unlock(&kvm->lock); |
| 948 | r = 0; | 950 | r = 0; |
| 949 | } | 951 | } |
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 65679d006337..8346be87cfa1 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
| @@ -364,6 +364,9 @@ struct kvm_arch{ | |||
| 364 | 364 | ||
| 365 | struct page *ept_identity_pagetable; | 365 | struct page *ept_identity_pagetable; |
| 366 | bool ept_identity_pagetable_done; | 366 | bool ept_identity_pagetable_done; |
| 367 | |||
| 368 | unsigned long irq_sources_bitmap; | ||
| 369 | unsigned long irq_states[KVM_IOAPIC_NUM_PINS]; | ||
| 367 | }; | 370 | }; |
| 368 | 371 | ||
| 369 | struct kvm_vm_stat { | 372 | struct kvm_vm_stat { |
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 | ||
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 3833c48fae3a..bb92be2153bc 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
| @@ -37,6 +37,8 @@ | |||
| 37 | #define KVM_REQ_UNHALT 6 | 37 | #define KVM_REQ_UNHALT 6 |
| 38 | #define KVM_REQ_MMU_SYNC 7 | 38 | #define KVM_REQ_MMU_SYNC 7 |
| 39 | 39 | ||
| 40 | #define KVM_USERSPACE_IRQ_SOURCE_ID 0 | ||
| 41 | |||
| 40 | struct kvm_vcpu; | 42 | struct kvm_vcpu; |
| 41 | extern struct kmem_cache *kvm_vcpu_cache; | 43 | extern struct kmem_cache *kvm_vcpu_cache; |
| 42 | 44 | ||
| @@ -306,15 +308,18 @@ struct kvm_assigned_dev_kernel { | |||
| 306 | int host_irq; | 308 | int host_irq; |
| 307 | int guest_irq; | 309 | int guest_irq; |
| 308 | int irq_requested; | 310 | int irq_requested; |
| 311 | int irq_source_id; | ||
| 309 | struct pci_dev *dev; | 312 | struct pci_dev *dev; |
| 310 | struct kvm *kvm; | 313 | struct kvm *kvm; |
| 311 | }; | 314 | }; |
| 312 | void kvm_set_irq(struct kvm *kvm, int irq, int level); | 315 | void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level); |
| 313 | void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); | 316 | void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi); |
| 314 | void kvm_register_irq_ack_notifier(struct kvm *kvm, | 317 | void kvm_register_irq_ack_notifier(struct kvm *kvm, |
| 315 | struct kvm_irq_ack_notifier *kian); | 318 | struct kvm_irq_ack_notifier *kian); |
| 316 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, | 319 | void kvm_unregister_irq_ack_notifier(struct kvm *kvm, |
| 317 | struct kvm_irq_ack_notifier *kian); | 320 | struct kvm_irq_ack_notifier *kian); |
| 321 | int kvm_request_irq_source_id(struct kvm *kvm); | ||
| 322 | void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id); | ||
| 318 | 323 | ||
| 319 | #ifdef CONFIG_DMAR | 324 | #ifdef CONFIG_DMAR |
| 320 | int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, | 325 | int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn, |
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index d0169f5e6047..55ad76ee2d09 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c | |||
| @@ -25,15 +25,23 @@ | |||
| 25 | #include "ioapic.h" | 25 | #include "ioapic.h" |
| 26 | 26 | ||
| 27 | /* This should be called with the kvm->lock mutex held */ | 27 | /* This should be called with the kvm->lock mutex held */ |
| 28 | void kvm_set_irq(struct kvm *kvm, int irq, int level) | 28 | void kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level) |
| 29 | { | 29 | { |
| 30 | unsigned long *irq_state = (unsigned long *)&kvm->arch.irq_states[irq]; | ||
