diff options
Diffstat (limited to 'virt/kvm/irq_comm.c')
-rw-r--r-- | virt/kvm/irq_comm.c | 32 |
1 files changed, 3 insertions, 29 deletions
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c index 325c6685f206..35397a569b24 100644 --- a/virt/kvm/irq_comm.c +++ b/virt/kvm/irq_comm.c | |||
@@ -43,12 +43,11 @@ static int kvm_set_ioapic_irq(struct kvm_kernel_irq_routing_entry *e, | |||
43 | return kvm_ioapic_set_irq(kvm->arch.vioapic, e->irqchip.pin, level); | 43 | return kvm_ioapic_set_irq(kvm->arch.vioapic, e->irqchip.pin, level); |
44 | } | 44 | } |
45 | 45 | ||
46 | void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, | 46 | void kvm_get_intr_delivery_bitmask(struct kvm *kvm, |
47 | union kvm_ioapic_redirect_entry *entry, | 47 | union kvm_ioapic_redirect_entry *entry, |
48 | unsigned long *deliver_bitmask) | 48 | unsigned long *deliver_bitmask) |
49 | { | 49 | { |
50 | int i; | 50 | int i; |
51 | struct kvm *kvm = ioapic->kvm; | ||
52 | struct kvm_vcpu *vcpu; | 51 | struct kvm_vcpu *vcpu; |
53 | 52 | ||
54 | bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); | 53 | bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); |
@@ -90,7 +89,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, | |||
90 | switch (entry->fields.delivery_mode) { | 89 | switch (entry->fields.delivery_mode) { |
91 | case IOAPIC_LOWEST_PRIORITY: | 90 | case IOAPIC_LOWEST_PRIORITY: |
92 | /* Select one in deliver_bitmask */ | 91 | /* Select one in deliver_bitmask */ |
93 | vcpu = kvm_get_lowest_prio_vcpu(ioapic->kvm, | 92 | vcpu = kvm_get_lowest_prio_vcpu(kvm, |
94 | entry->fields.vector, deliver_bitmask); | 93 | entry->fields.vector, deliver_bitmask); |
95 | bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); | 94 | bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS); |
96 | if (!vcpu) | 95 | if (!vcpu) |
@@ -111,13 +110,7 @@ void kvm_get_intr_delivery_bitmask(struct kvm_ioapic *ioapic, | |||
111 | static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, | 110 | static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, |
112 | struct kvm *kvm, int level) | 111 | struct kvm *kvm, int level) |
113 | { | 112 | { |
114 | int vcpu_id, r = -1; | ||
115 | struct kvm_vcpu *vcpu; | ||
116 | struct kvm_ioapic *ioapic = ioapic_irqchip(kvm); | ||
117 | union kvm_ioapic_redirect_entry entry; | 113 | union kvm_ioapic_redirect_entry entry; |
118 | DECLARE_BITMAP(deliver_bitmask, KVM_MAX_VCPUS); | ||
119 | |||
120 | BUG_ON(!ioapic); | ||
121 | 114 | ||
122 | entry.bits = 0; | 115 | entry.bits = 0; |
123 | entry.fields.dest_id = (e->msi.address_lo & | 116 | entry.fields.dest_id = (e->msi.address_lo & |
@@ -133,26 +126,7 @@ static int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, | |||
133 | (unsigned long *)&e->msi.data); | 126 | (unsigned long *)&e->msi.data); |
134 | 127 | ||
135 | /* TODO Deal with RH bit of MSI message address */ | 128 | /* TODO Deal with RH bit of MSI message address */ |
136 | 129 | return ioapic_deliver_entry(kvm, &entry); | |
137 | kvm_get_intr_delivery_bitmask(ioapic, &entry, deliver_bitmask); | ||
138 | |||
139 | if (find_first_bit(deliver_bitmask, KVM_MAX_VCPUS) >= KVM_MAX_VCPUS) { | ||
140 | printk(KERN_WARNING "kvm: no destination for MSI delivery!"); | ||
141 | return -1; | ||
142 | } | ||
143 | while ((vcpu_id = find_first_bit(deliver_bitmask, | ||
144 | KVM_MAX_VCPUS)) < KVM_MAX_VCPUS) { | ||
145 | __clear_bit(vcpu_id, deliver_bitmask); | ||
146 | vcpu = ioapic->kvm->vcpus[vcpu_id]; | ||
147 | if (vcpu) { | ||
148 | if (r < 0) | ||
149 | r = 0; | ||
150 | r += kvm_apic_set_irq(vcpu, entry.fields.vector, | ||
151 | entry.fields.dest_mode, | ||
152 | entry.fields.trig_mode); | ||
153 | } | ||
154 | } | ||
155 | return r; | ||
156 | } | 130 | } |
157 | 131 | ||
158 | /* This should be called with the kvm->lock mutex held | 132 | /* This should be called with the kvm->lock mutex held |