2 * Copyright (C) 2001 MandrakeSoft S.A.
3 * Copyright 2010 Red Hat, Inc. and/or its affiliates.
8 * http://www.linux-mandrake.com/
9 * http://www.mandrakesoft.com/
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Yunhong Jiang <yunhong.jiang@intel.com>
26 * Yaozu (Eddie) Dong <eddie.dong@intel.com>
27 * Based on Xen 3.1 code.
29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
31 #include <linux/kvm_host.h>
32 #include <linux/kvm.h>
34 #include <linux/highmem.h>
35 #include <linux/smp.h>
36 #include <linux/hrtimer.h>
38 #include <linux/slab.h>
39 #include <linux/export.h>
40 #include <linux/nospec.h>
41 #include <asm/processor.h>
43 #include <asm/current.h>
44 #include <trace/events/kvm.h>
50 static int ioapic_service(struct kvm_ioapic *vioapic, int irq,
53 static void kvm_ioapic_update_eoi_one(struct kvm_vcpu *vcpu,
54 struct kvm_ioapic *ioapic,
58 static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic)
60 unsigned long result = 0;
62 switch (ioapic->ioregsel) {
63 case IOAPIC_REG_VERSION:
64 result = ((((IOAPIC_NUM_PINS - 1) & 0xff) << 16)
65 | (IOAPIC_VERSION_ID & 0xff));
68 case IOAPIC_REG_APIC_ID:
69 case IOAPIC_REG_ARB_ID:
70 result = ((ioapic->id & 0xf) << 24);
75 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
76 u64 redir_content = ~0ULL;
78 if (redir_index < IOAPIC_NUM_PINS) {
79 u32 index = array_index_nospec(
80 redir_index, IOAPIC_NUM_PINS);
82 redir_content = ioapic->redirtbl[index].bits;
85 result = (ioapic->ioregsel & 0x1) ?
86 (redir_content >> 32) & 0xffffffff :
87 redir_content & 0xffffffff;
95 static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic *ioapic)
97 ioapic->rtc_status.pending_eoi = 0;
98 bitmap_zero(ioapic->rtc_status.dest_map.map, KVM_MAX_VCPU_IDS);
101 static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic);
103 static void rtc_status_pending_eoi_check_valid(struct kvm_ioapic *ioapic)
105 if (WARN_ON(ioapic->rtc_status.pending_eoi < 0))
106 kvm_rtc_eoi_tracking_restore_all(ioapic);
109 static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
111 bool new_val, old_val;
112 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
113 struct dest_map *dest_map = &ioapic->rtc_status.dest_map;
114 union kvm_ioapic_redirect_entry *e;
116 e = &ioapic->redirtbl[RTC_GSI];
117 if (!kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
119 kvm_lapic_irq_dest_mode(!!e->fields.dest_mode)))
122 new_val = kvm_apic_pending_eoi(vcpu, e->fields.vector);
123 old_val = test_bit(vcpu->vcpu_id, dest_map->map);
125 if (new_val == old_val)
129 __set_bit(vcpu->vcpu_id, dest_map->map);
130 dest_map->vectors[vcpu->vcpu_id] = e->fields.vector;
131 ioapic->rtc_status.pending_eoi++;
133 __clear_bit(vcpu->vcpu_id, dest_map->map);
134 ioapic->rtc_status.pending_eoi--;
135 rtc_status_pending_eoi_check_valid(ioapic);
139 void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu *vcpu)
141 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
143 spin_lock(&ioapic->lock);
144 __rtc_irq_eoi_tracking_restore_one(vcpu);
145 spin_unlock(&ioapic->lock);
148 static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic *ioapic)
150 struct kvm_vcpu *vcpu;
153 if (RTC_GSI >= IOAPIC_NUM_PINS)
156 rtc_irq_eoi_tracking_reset(ioapic);
157 kvm_for_each_vcpu(i, vcpu, ioapic->kvm)
158 __rtc_irq_eoi_tracking_restore_one(vcpu);
161 static void rtc_irq_eoi(struct kvm_ioapic *ioapic, struct kvm_vcpu *vcpu,
164 struct dest_map *dest_map = &ioapic->rtc_status.dest_map;
166 /* RTC special handling */
167 if (test_bit(vcpu->vcpu_id, dest_map->map) &&
168 (vector == dest_map->vectors[vcpu->vcpu_id]) &&
169 (test_and_clear_bit(vcpu->vcpu_id,
170 ioapic->rtc_status.dest_map.map))) {
171 --ioapic->rtc_status.pending_eoi;
172 rtc_status_pending_eoi_check_valid(ioapic);
176 static bool rtc_irq_check_coalesced(struct kvm_ioapic *ioapic)
178 if (ioapic->rtc_status.pending_eoi > 0)
179 return true; /* coalesced */
184 static void ioapic_lazy_update_eoi(struct kvm_ioapic *ioapic, int irq)
187 struct kvm_vcpu *vcpu;
188 union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq];
190 kvm_for_each_vcpu(i, vcpu, ioapic->kvm) {
191 if (!kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
192 entry->fields.dest_id,
193 entry->fields.dest_mode) ||
194 kvm_apic_pending_eoi(vcpu, entry->fields.vector))
198 * If no longer has pending EOI in LAPICs, update
199 * EOI for this vector.
201 rtc_irq_eoi(ioapic, vcpu, entry->fields.vector);
206 static int ioapic_set_irq(struct kvm_ioapic *ioapic, unsigned int irq,
207 int irq_level, bool line_status)
209 union kvm_ioapic_redirect_entry entry;
214 entry = ioapic->redirtbl[irq];
215 edge = (entry.fields.trig_mode == IOAPIC_EDGE_TRIG);
218 ioapic->irr &= ~mask;
224 * AMD SVM AVIC accelerate EOI write iff the interrupt is edge
225 * triggered, in which case the in-kernel IOAPIC will not be able
226 * to receive the EOI. In this case, we do a lazy update of the
227 * pending EOI when trying to set IOAPIC irq.
229 if (edge && kvm_apicv_activated(ioapic->kvm))
230 ioapic_lazy_update_eoi(ioapic, irq);
233 * Return 0 for coalesced interrupts; for edge-triggered interrupts,
234 * this only happens if a previous edge has not been delivered due
235 * to masking. For level interrupts, the remote_irr field tells
236 * us if the interrupt is waiting for an EOI.
238 * RTC is special: it is edge-triggered, but userspace likes to know
239 * if it has been already ack-ed via EOI because coalesced RTC
240 * interrupts lead to time drift in Windows guests. So we track
241 * EOI manually for the RTC interrupt.
243 if (irq == RTC_GSI && line_status &&
244 rtc_irq_check_coalesced(ioapic)) {
249 old_irr = ioapic->irr;
252 ioapic->irr_delivered &= ~mask;
253 if (old_irr == ioapic->irr) {
259 ret = ioapic_service(ioapic, irq, line_status);
262 trace_kvm_ioapic_set_irq(entry.bits, irq, ret == 0);
266 static void kvm_ioapic_inject_all(struct kvm_ioapic *ioapic, unsigned long irr)
270 rtc_irq_eoi_tracking_reset(ioapic);
271 for_each_set_bit(idx, &irr, IOAPIC_NUM_PINS)
272 ioapic_set_irq(ioapic, idx, 1, true);
274 kvm_rtc_eoi_tracking_restore_all(ioapic);
278 void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, ulong *ioapic_handled_vectors)
280 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
281 struct dest_map *dest_map = &ioapic->rtc_status.dest_map;
282 union kvm_ioapic_redirect_entry *e;
285 spin_lock(&ioapic->lock);
287 /* Make sure we see any missing RTC EOI */
288 if (test_bit(vcpu->vcpu_id, dest_map->map))
289 __set_bit(dest_map->vectors[vcpu->vcpu_id],
290 ioapic_handled_vectors);
292 for (index = 0; index < IOAPIC_NUM_PINS; index++) {
293 e = &ioapic->redirtbl[index];
294 if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG ||
295 kvm_irq_has_notifier(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index) ||
297 u16 dm = kvm_lapic_irq_dest_mode(!!e->fields.dest_mode);
299 if (kvm_apic_match_dest(vcpu, NULL, APIC_DEST_NOSHORT,
300 e->fields.dest_id, dm) ||
301 kvm_apic_pending_eoi(vcpu, e->fields.vector))
302 __set_bit(e->fields.vector,
303 ioapic_handled_vectors);
306 spin_unlock(&ioapic->lock);
309 void kvm_arch_post_irq_ack_notifier_list_update(struct kvm *kvm)
311 if (!ioapic_in_kernel(kvm))
313 kvm_make_scan_ioapic_request(kvm);
316 static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
319 bool mask_before, mask_after;
320 union kvm_ioapic_redirect_entry *e;
321 int old_remote_irr, old_delivery_status, old_dest_id, old_dest_mode;
322 DECLARE_BITMAP(vcpu_bitmap, KVM_MAX_VCPUS);
324 switch (ioapic->ioregsel) {
325 case IOAPIC_REG_VERSION:
326 /* Writes are ignored. */
329 case IOAPIC_REG_APIC_ID:
330 ioapic->id = (val >> 24) & 0xf;
333 case IOAPIC_REG_ARB_ID:
337 index = (ioapic->ioregsel - 0x10) >> 1;
339 if (index >= IOAPIC_NUM_PINS)
341 index = array_index_nospec(index, IOAPIC_NUM_PINS);
342 e = &ioapic->redirtbl[index];
343 mask_before = e->fields.mask;
344 /* Preserve read-only fields */
345 old_remote_irr = e->fields.remote_irr;
346 old_delivery_status = e->fields.delivery_status;
347 old_dest_id = e->fields.dest_id;
348 old_dest_mode = e->fields.dest_mode;
349 if (ioapic->ioregsel & 1) {
350 e->bits &= 0xffffffff;
351 e->bits |= (u64) val << 32;
353 e->bits &= ~0xffffffffULL;
354 e->bits |= (u32) val;
356 e->fields.remote_irr = old_remote_irr;
357 e->fields.delivery_status = old_delivery_status;
360 * Some OSes (Linux, Xen) assume that Remote IRR bit will
361 * be cleared by IOAPIC hardware when the entry is configured
362 * as edge-triggered. This behavior is used to simulate an
363 * explicit EOI on IOAPICs that don't have the EOI register.
365 if (e->fields.trig_mode == IOAPIC_EDGE_TRIG)
366 e->fields.remote_irr = 0;
368 mask_after = e->fields.mask;
369 if (mask_before != mask_after)
370 kvm_fire_mask_notifiers(ioapic->kvm, KVM_IRQCHIP_IOAPIC, index, mask_after);
371 if (e->fields.trig_mode == IOAPIC_LEVEL_TRIG
372 && ioapic->irr & (1 << index))
373 ioapic_service(ioapic, index, false);
374 if (e->fields.delivery_mode == APIC_DM_FIXED) {
375 struct kvm_lapic_irq irq;
377 irq.vector = e->fields.vector;
378 irq.delivery_mode = e->fields.delivery_mode << 8;
380 kvm_lapic_irq_dest_mode(!!e->fields.dest_mode);
382 irq.trig_mode = e->fields.trig_mode;
383 irq.shorthand = APIC_DEST_NOSHORT;
384 irq.dest_id = e->fields.dest_id;
385 irq.msi_redir_hint = false;
386 bitmap_zero(vcpu_bitmap, KVM_MAX_VCPUS);
387 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
389 if (old_dest_mode != e->fields.dest_mode ||
390 old_dest_id != e->fields.dest_id) {
392 * Update vcpu_bitmap with vcpus specified in
393 * the previous request as well. This is done to
394 * keep ioapic_handled_vectors synchronized.
396 irq.dest_id = old_dest_id;
398 kvm_lapic_irq_dest_mode(
399 !!e->fields.dest_mode);
400 kvm_bitmap_or_dest_vcpus(ioapic->kvm, &irq,
403 kvm_make_scan_ioapic_request_mask(ioapic->kvm,
406 kvm_make_scan_ioapic_request(ioapic->kvm);
412 static int ioapic_service(struct kvm_ioapic *ioapic, int irq, bool line_status)
414 union kvm_ioapic_redirect_entry *entry = &ioapic->redirtbl[irq];
415 struct kvm_lapic_irq irqe;
418 if (entry->fields.mask ||
419 (entry->fields.trig_mode == IOAPIC_LEVEL_TRIG &&
420 entry->fields.remote_irr))
423 irqe.dest_id = entry->fields.dest_id;
424 irqe.vector = entry->fields.vector;
425 irqe.dest_mode = kvm_lapic_irq_dest_mode(!!entry->fields.dest_mode);
426 irqe.trig_mode = entry->fields.trig_mode;
427 irqe.delivery_mode = entry->fields.delivery_mode << 8;
429 irqe.shorthand = APIC_DEST_NOSHORT;
430 irqe.msi_redir_hint = false;
432 if (irqe.trig_mode == IOAPIC_EDGE_TRIG)
433 ioapic->irr_delivered |= 1 << irq;
435 if (irq == RTC_GSI && line_status) {
437 * pending_eoi cannot ever become negative (see
438 * rtc_status_pending_eoi_check_valid) and the caller
439 * ensures that it is only called if it is >= zero, namely
440 * if rtc_irq_check_coalesced returns false).
442 BUG_ON(ioapic->rtc_status.pending_eoi != 0);
443 ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe,
444 &ioapic->rtc_status.dest_map);
445 ioapic->rtc_status.pending_eoi = (ret < 0 ? 0 : ret);
447 ret = kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe, NULL);
449 if (ret && irqe.trig_mode == IOAPIC_LEVEL_TRIG)
450 entry->fields.remote_irr = 1;
455 int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int irq_source_id,
456 int level, bool line_status)
460 BUG_ON(irq < 0 || irq >= IOAPIC_NUM_PINS);
462 spin_lock(&ioapic->lock);
463 irq_level = __kvm_irq_line_state(&ioapic->irq_states[irq],
464 irq_source_id, level);
465 ret = ioapic_set_irq(ioapic, irq, irq_level, line_status);
467 spin_unlock(&ioapic->lock);
472 void kvm_ioapic_clear_all(struct kvm_ioapic *ioapic, int irq_source_id)
476 spin_lock(&ioapic->lock);
477 for (i = 0; i < KVM_IOAPIC_NUM_PINS; i++)
478 __clear_bit(irq_source_id, &ioapic->irq_states[i]);
479 spin_unlock(&ioapic->lock);
482 static void kvm_ioapic_eoi_inject_work(struct work_struct *work)
485 struct kvm_ioapic *ioapic = container_of(work, struct kvm_ioapic,
487 spin_lock(&ioapic->lock);
488 for (i = 0; i < IOAPIC_NUM_PINS; i++) {
489 union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[i];
491 if (ent->fields.trig_mode != IOAPIC_LEVEL_TRIG)
494 if (ioapic->irr & (1 << i) && !ent->fields.remote_irr)
495 ioapic_service(ioapic, i, false);
497 spin_unlock(&ioapic->lock);
500 #define IOAPIC_SUCCESSIVE_IRQ_MAX_COUNT 10000
501 static void kvm_ioapic_update_eoi_one(struct kvm_vcpu *vcpu,
502 struct kvm_ioapic *ioapic,
506 struct kvm_lapic *apic = vcpu->arch.apic;
507 union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[pin];
510 * We are dropping lock while calling ack notifiers because ack
511 * notifier callbacks for assigned devices call into IOAPIC
512 * recursively. Since remote_irr is cleared only after call
513 * to notifiers if the same vector will be delivered while lock
514 * is dropped it will be put into irr and will be delivered
515 * after ack notifier returns.
517 spin_unlock(&ioapic->lock);
518 kvm_notify_acked_irq(ioapic->kvm, KVM_IRQCHIP_IOAPIC, pin);
519 spin_lock(&ioapic->lock);
521 if (trigger_mode != IOAPIC_LEVEL_TRIG ||
522 kvm_lapic_get_reg(apic, APIC_SPIV) & APIC_SPIV_DIRECTED_EOI)
525 ASSERT(ent->fields.trig_mode == IOAPIC_LEVEL_TRIG);
526 ent->fields.remote_irr = 0;
527 if (!ent->fields.mask && (ioapic->irr & (1 << pin))) {
528 ++ioapic->irq_eoi[pin];
529 if (ioapic->irq_eoi[pin] == IOAPIC_SUCCESSIVE_IRQ_MAX_COUNT) {
531 * Real hardware does not deliver the interrupt
532 * immediately during eoi broadcast, and this
533 * lets a buggy guest make slow progress
534 * even if it does not correctly handle a
535 * level-triggered interrupt. Emulate this
536 * behavior if we detect an interrupt storm.
538 schedule_delayed_work(&ioapic->eoi_inject, HZ / 100);
539 ioapic->irq_eoi[pin] = 0;
540 trace_kvm_ioapic_delayed_eoi_inj(ent->bits);
542 ioapic_service(ioapic, pin, false);
545 ioapic->irq_eoi[pin] = 0;
549 void kvm_ioapic_update_eoi(struct kvm_vcpu *vcpu, int vector, int trigger_mode)
552 struct kvm_ioapic *ioapic = vcpu->kvm->arch.vioapic;
554 spin_lock(&ioapic->lock);
555 rtc_irq_eoi(ioapic, vcpu, vector);
556 for (i = 0; i < IOAPIC_NUM_PINS; i++) {
557 union kvm_ioapic_redirect_entry *ent = &ioapic->redirtbl[i];
559 if (ent->fields.vector != vector)
561 kvm_ioapic_update_eoi_one(vcpu, ioapic, trigger_mode, i);
563 spin_unlock(&ioapic->lock);
566 static inline struct kvm_ioapic *to_ioapic(struct kvm_io_device *dev)
568 return container_of(dev, struct kvm_ioapic, dev);
571 static inline int ioapic_in_range(struct kvm_ioapic *ioapic, gpa_t addr)
573 return ((addr >= ioapic->base_address &&
574 (addr < ioapic->base_address + IOAPIC_MEM_LENGTH)));
577 static int ioapic_mmio_read(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
578 gpa_t addr, int len, void *val)
580 struct kvm_ioapic *ioapic = to_ioapic(this);
582 if (!ioapic_in_range(ioapic, addr))
585 ASSERT(!(addr & 0xf)); /* check alignment */
588 spin_lock(&ioapic->lock);
590 case IOAPIC_REG_SELECT:
591 result = ioapic->ioregsel;
594 case IOAPIC_REG_WINDOW:
595 result = ioapic_read_indirect(ioapic);
602 spin_unlock(&ioapic->lock);
606 *(u64 *) val = result;
611 memcpy(val, (char *)&result, len);
614 printk(KERN_WARNING "ioapic: wrong length %d\n", len);
619 static int ioapic_mmio_write(struct kvm_vcpu *vcpu, struct kvm_io_device *this,
620 gpa_t addr, int len, const void *val)
622 struct kvm_ioapic *ioapic = to_ioapic(this);
624 if (!ioapic_in_range(ioapic, addr))
627 ASSERT(!(addr & 0xf)); /* check alignment */
641 printk(KERN_WARNING "ioapic: Unsupported size %d\n", len);
646 spin_lock(&ioapic->lock);
648 case IOAPIC_REG_SELECT:
649 ioapic->ioregsel = data & 0xFF; /* 8-bit register */
652 case IOAPIC_REG_WINDOW:
653 ioapic_write_indirect(ioapic, data);
659 spin_unlock(&ioapic->lock);
663 static void kvm_ioapic_reset(struct kvm_ioapic *ioapic)
667 cancel_delayed_work_sync(&ioapic->eoi_inject);
668 for (i = 0; i < IOAPIC_NUM_PINS; i++)
669 ioapic->redirtbl[i].fields.mask = 1;
670 ioapic->base_address = IOAPIC_DEFAULT_BASE_ADDRESS;
671 ioapic->ioregsel = 0;
673 ioapic->irr_delivered = 0;
675 memset(ioapic->irq_eoi, 0x00, sizeof(ioapic->irq_eoi));
676 rtc_irq_eoi_tracking_reset(ioapic);
679 static const struct kvm_io_device_ops ioapic_mmio_ops = {
680 .read = ioapic_mmio_read,
681 .write = ioapic_mmio_write,
684 int kvm_ioapic_init(struct kvm *kvm)
686 struct kvm_ioapic *ioapic;
689 ioapic = kzalloc(sizeof(struct kvm_ioapic), GFP_KERNEL_ACCOUNT);
692 spin_lock_init(&ioapic->lock);
693 INIT_DELAYED_WORK(&ioapic->eoi_inject, kvm_ioapic_eoi_inject_work);
694 kvm->arch.vioapic = ioapic;
695 kvm_ioapic_reset(ioapic);
696 kvm_iodevice_init(&ioapic->dev, &ioapic_mmio_ops);
698 mutex_lock(&kvm->slots_lock);
699 ret = kvm_io_bus_register_dev(kvm, KVM_MMIO_BUS, ioapic->base_address,
700 IOAPIC_MEM_LENGTH, &ioapic->dev);
701 mutex_unlock(&kvm->slots_lock);
703 kvm->arch.vioapic = NULL;
710 void kvm_ioapic_destroy(struct kvm *kvm)
712 struct kvm_ioapic *ioapic = kvm->arch.vioapic;
717 cancel_delayed_work_sync(&ioapic->eoi_inject);
718 mutex_lock(&kvm->slots_lock);
719 kvm_io_bus_unregister_dev(kvm, KVM_MMIO_BUS, &ioapic->dev);
720 mutex_unlock(&kvm->slots_lock);
721 kvm->arch.vioapic = NULL;
725 void kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)
727 struct kvm_ioapic *ioapic = kvm->arch.vioapic;
729 spin_lock(&ioapic->lock);
730 memcpy(state, ioapic, sizeof(struct kvm_ioapic_state));
731 state->irr &= ~ioapic->irr_delivered;
732 spin_unlock(&ioapic->lock);
735 void kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)
737 struct kvm_ioapic *ioapic = kvm->arch.vioapic;
739 spin_lock(&ioapic->lock);
740 memcpy(ioapic, state, sizeof(struct kvm_ioapic_state));
742 ioapic->irr_delivered = 0;
743 kvm_make_scan_ioapic_request(kvm);
744 kvm_ioapic_inject_all(ioapic, state->irr);
745 spin_unlock(&ioapic->lock);