aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/ioapic.c
diff options
context:
space:
mode:
authorSheng Yang <sheng@linux.intel.com>2009-02-11 03:03:40 -0500
committerAvi Kivity <avi@redhat.com>2009-06-10 04:48:22 -0400
commitbfd349d073b2838a6a031f057d25e266619b7093 (patch)
treeb2b2f2f3f99a7e860fb7bb7c54ce322700055ebd /virt/kvm/ioapic.c
parent110c2faeba1f1994bcb1de55b9c31f4147dbfdb6 (diff)
KVM: bit ops for deliver_bitmap
It's also convenient when we extend KVM supported vcpu number in the future. Signed-off-by: Sheng Yang <sheng@linux.intel.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/ioapic.c')
-rw-r--r--virt/kvm/ioapic.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 3b5371299dd1..7c2cb2bd1199 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -203,7 +203,7 @@ void kvm_ioapic_get_delivery_bitmask(struct kvm_ioapic *ioapic, u8 dest,
203static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq) 203static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
204{ 204{
205 union kvm_ioapic_redirect_entry entry = ioapic->redirtbl[irq]; 205 union kvm_ioapic_redirect_entry entry = ioapic->redirtbl[irq];
206 unsigned long deliver_bitmask; 206 DECLARE_BITMAP(deliver_bitmask, KVM_MAX_VCPUS);
207 struct kvm_vcpu *vcpu; 207 struct kvm_vcpu *vcpu;
208 int vcpu_id, r = -1; 208 int vcpu_id, r = -1;
209 209
@@ -213,22 +213,24 @@ static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq)
213 entry.fields.delivery_mode, entry.fields.vector, 213 entry.fields.delivery_mode, entry.fields.vector,
214 entry.fields.trig_mode); 214 entry.fields.trig_mode);
215 215
216 kvm_get_intr_delivery_bitmask(ioapic, &entry, &deliver_bitmask); 216 bitmap_zero(deliver_bitmask, KVM_MAX_VCPUS);
217 if (!deliver_bitmask) {
218 ioapic_debug("no target on destination\n");
219 return 0;
220 }
221 217
222 /* Always delivery PIT interrupt to vcpu 0 */ 218 /* Always delivery PIT interrupt to vcpu 0 */
223#ifdef CONFIG_X86 219#ifdef CONFIG_X86
224 if (irq == 0) 220 if (irq == 0)
225 deliver_bitmask = 1; 221 __set_bit(0, deliver_bitmask);
222 else
226#endif 223#endif
224 kvm_get_intr_delivery_bitmask(ioapic, &entry, deliver_bitmask);
225
226 if (find_first_bit(deliver_bitmask, KVM_MAX_VCPUS) >= KVM_MAX_VCPUS) {
227 ioapic_debug("no target on destination\n");
228 return 0;
229 }
227 230
228 for (vcpu_id = 0; deliver_bitmask != 0; vcpu_id++) { 231 while ((vcpu_id = find_first_bit(deliver_bitmask, KVM_MAX_VCPUS))
229 if (!(deliver_bitmask & (1 << vcpu_id))) 232 < KVM_MAX_VCPUS) {
230 continue; 233 __clear_bit(vcpu_id, deliver_bitmask);
231 deliver_bitmask &= ~(1 << vcpu_id);
232 vcpu = ioapic->kvm->vcpus[vcpu_id]; 234 vcpu = ioapic->kvm->vcpus[vcpu_id];
233 if (vcpu) { 235 if (vcpu) {
234 if (entry.fields.delivery_mode == 236 if (entry.fields.delivery_mode ==