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.
30 #include <linux/kvm_host.h>
31 #include <linux/kvm.h>
33 #include <linux/highmem.h>
34 #include <linux/smp.h>
35 #include <linux/hrtimer.h>
37 #include <linux/slab.h>
38 #include <linux/export.h>
39 #include <linux/nospec.h>
40 #include <asm/processor.h>
42 #include <asm/current.h>
43 #include <trace/events/kvm.h>
49 static int ioapic_service(struct kvm_ioapic
*vioapic
, int irq
,
52 static unsigned long ioapic_read_indirect(struct kvm_ioapic
*ioapic
,
56 unsigned long result
= 0;
58 switch (ioapic
->ioregsel
) {
59 case IOAPIC_REG_VERSION
:
60 result
= ((((IOAPIC_NUM_PINS
- 1) & 0xff) << 16)
61 | (IOAPIC_VERSION_ID
& 0xff));
64 case IOAPIC_REG_APIC_ID
:
65 case IOAPIC_REG_ARB_ID
:
66 result
= ((ioapic
->id
& 0xf) << 24);
71 u32 redir_index
= (ioapic
->ioregsel
- 0x10) >> 1;
72 u64 redir_content
= ~0ULL;
74 if (redir_index
< IOAPIC_NUM_PINS
) {
75 u32 index
= array_index_nospec(
76 redir_index
, IOAPIC_NUM_PINS
);
78 redir_content
= ioapic
->redirtbl
[index
].bits
;
81 result
= (ioapic
->ioregsel
& 0x1) ?
82 (redir_content
>> 32) & 0xffffffff :
83 redir_content
& 0xffffffff;
91 static void rtc_irq_eoi_tracking_reset(struct kvm_ioapic
*ioapic
)
93 ioapic
->rtc_status
.pending_eoi
= 0;
94 bitmap_zero(ioapic
->rtc_status
.dest_map
.map
, KVM_MAX_VCPU_ID
);
97 static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic
*ioapic
);
99 static void rtc_status_pending_eoi_check_valid(struct kvm_ioapic
*ioapic
)
101 if (WARN_ON(ioapic
->rtc_status
.pending_eoi
< 0))
102 kvm_rtc_eoi_tracking_restore_all(ioapic
);
105 static void __rtc_irq_eoi_tracking_restore_one(struct kvm_vcpu
*vcpu
)
107 bool new_val
, old_val
;
108 struct kvm_ioapic
*ioapic
= vcpu
->kvm
->arch
.vioapic
;
109 struct dest_map
*dest_map
= &ioapic
->rtc_status
.dest_map
;
110 union kvm_ioapic_redirect_entry
*e
;
112 e
= &ioapic
->redirtbl
[RTC_GSI
];
113 if (!kvm_apic_match_dest(vcpu
, NULL
, APIC_DEST_NOSHORT
,
115 kvm_lapic_irq_dest_mode(!!e
->fields
.dest_mode
)))
118 new_val
= kvm_apic_pending_eoi(vcpu
, e
->fields
.vector
);
119 old_val
= test_bit(vcpu
->vcpu_id
, dest_map
->map
);
121 if (new_val
== old_val
)
125 __set_bit(vcpu
->vcpu_id
, dest_map
->map
);
126 dest_map
->vectors
[vcpu
->vcpu_id
] = e
->fields
.vector
;
127 ioapic
->rtc_status
.pending_eoi
++;
129 __clear_bit(vcpu
->vcpu_id
, dest_map
->map
);
130 ioapic
->rtc_status
.pending_eoi
--;
131 rtc_status_pending_eoi_check_valid(ioapic
);
135 void kvm_rtc_eoi_tracking_restore_one(struct kvm_vcpu
*vcpu
)
137 struct kvm_ioapic
*ioapic
= vcpu
->kvm
->arch
.vioapic
;
139 spin_lock(&ioapic
->lock
);
140 __rtc_irq_eoi_tracking_restore_one(vcpu
);
141 spin_unlock(&ioapic
->lock
);
144 static void kvm_rtc_eoi_tracking_restore_all(struct kvm_ioapic
*ioapic
)
146 struct kvm_vcpu
*vcpu
;
149 if (RTC_GSI
>= IOAPIC_NUM_PINS
)
152 rtc_irq_eoi_tracking_reset(ioapic
);
153 kvm_for_each_vcpu(i
, vcpu
, ioapic
->kvm
)
154 __rtc_irq_eoi_tracking_restore_one(vcpu
);
157 static void rtc_irq_eoi(struct kvm_ioapic
*ioapic
, struct kvm_vcpu
*vcpu
)
159 if (test_and_clear_bit(vcpu
->vcpu_id
,
160 ioapic
->rtc_status
.dest_map
.map
)) {
161 --ioapic
->rtc_status
.pending_eoi
;
162 rtc_status_pending_eoi_check_valid(ioapic
);
166 static bool rtc_irq_check_coalesced(struct kvm_ioapic
*ioapic
)
168 if (ioapic
->rtc_status
.pending_eoi
> 0)
169 return true; /* coalesced */
174 static int ioapic_set_irq(struct kvm_ioapic
*ioapic
, unsigned int irq
,
175 int irq_level
, bool line_status
)
177 union kvm_ioapic_redirect_entry entry
;
182 entry
= ioapic
->redirtbl
[irq
];
183 edge
= (entry
.fields
.trig_mode
== IOAPIC_EDGE_TRIG
);
186 ioapic
->irr
&= ~mask
;
192 * Return 0 for coalesced interrupts; for edge-triggered interrupts,
193 * this only happens if a previous edge has not been delivered due
194 * to masking. For level interrupts, the remote_irr field tells
195 * us if the interrupt is waiting for an EOI.
197 * RTC is special: it is edge-triggered, but userspace likes to know
198 * if it has been already ack-ed via EOI because coalesced RTC
199 * interrupts lead to time drift in Windows guests. So we track
200 * EOI manually for the RTC interrupt.
202 if (irq
== RTC_GSI
&& line_status
&&
203 rtc_irq_check_coalesced(ioapic
)) {
208 old_irr
= ioapic
->irr
;
211 ioapic
->irr_delivered
&= ~mask
;
212 if (old_irr
== ioapic
->irr
) {
218 ret
= ioapic_service(ioapic
, irq
, line_status
);
221 trace_kvm_ioapic_set_irq(entry
.bits
, irq
, ret
== 0);
225 static void kvm_ioapic_inject_all(struct kvm_ioapic
*ioapic
, unsigned long irr
)
229 rtc_irq_eoi_tracking_reset(ioapic
);
230 for_each_set_bit(idx
, &irr
, IOAPIC_NUM_PINS
)
231 ioapic_set_irq(ioapic
, idx
, 1, true);
233 kvm_rtc_eoi_tracking_restore_all(ioapic
);
237 void kvm_ioapic_scan_entry(struct kvm_vcpu
*vcpu
, ulong
*ioapic_handled_vectors
)
239 struct kvm_ioapic
*ioapic
= vcpu
->kvm
->arch
.vioapic
;
240 struct dest_map
*dest_map
= &ioapic
->rtc_status
.dest_map
;
241 union kvm_ioapic_redirect_entry
*e
;
244 spin_lock(&ioapic
->lock
);
246 /* Make sure we see any missing RTC EOI */
247 if (test_bit(vcpu
->vcpu_id
, dest_map
->map
))
248 __set_bit(dest_map
->vectors
[vcpu
->vcpu_id
],
249 ioapic_handled_vectors
);
251 for (index
= 0; index
< IOAPIC_NUM_PINS
; index
++) {
252 e
= &ioapic
->redirtbl
[index
];
253 if (e
->fields
.trig_mode
== IOAPIC_LEVEL_TRIG
||
254 kvm_irq_has_notifier(ioapic
->kvm
, KVM_IRQCHIP_IOAPIC
, index
) ||
256 u16 dm
= kvm_lapic_irq_dest_mode(!!e
->fields
.dest_mode
);
258 if (kvm_apic_match_dest(vcpu
, NULL
, APIC_DEST_NOSHORT
,
259 e
->fields
.dest_id
, dm
) ||
260 kvm_apic_pending_eoi(vcpu
, e
->fields
.vector
))
261 __set_bit(e
->fields
.vector
,
262 ioapic_handled_vectors
);
265 spin_unlock(&ioapic
->lock
);
268 void kvm_arch_post_irq_ack_notifier_list_update(struct kvm
*kvm
)
270 if (!ioapic_in_kernel(kvm
))
272 kvm_make_scan_ioapic_request(kvm
);
275 static void ioapic_write_indirect(struct kvm_ioapic
*ioapic
, u32 val
)
278 bool mask_before
, mask_after
;
279 union kvm_ioapic_redirect_entry
*e
;
280 unsigned long vcpu_bitmap
;
281 int old_remote_irr
, old_delivery_status
, old_dest_id
, old_dest_mode
;
283 switch (ioapic
->ioregsel
) {
284 case IOAPIC_REG_VERSION
:
285 /* Writes are ignored. */
288 case IOAPIC_REG_APIC_ID
:
289 ioapic
->id
= (val
>> 24) & 0xf;
292 case IOAPIC_REG_ARB_ID
:
296 index
= (ioapic
->ioregsel
- 0x10) >> 1;
298 if (index
>= IOAPIC_NUM_PINS
)
300 index
= array_index_nospec(index
, IOAPIC_NUM_PINS
);
301 e
= &ioapic
->redirtbl
[index
];
302 mask_before
= e
->fields
.mask
;
303 /* Preserve read-only fields */
304 old_remote_irr
= e
->fields
.remote_irr
;
305 old_delivery_status
= e
->fields
.delivery_status
;
306 old_dest_id
= e
->fields
.dest_id
;
307 old_dest_mode
= e
->fields
.dest_mode
;
308 if (ioapic
->ioregsel
& 1) {
309 e
->bits
&= 0xffffffff;
310 e
->bits
|= (u64
) val
<< 32;
312 e
->bits
&= ~0xffffffffULL
;
313 e
->bits
|= (u32
) val
;
315 e
->fields
.remote_irr
= old_remote_irr
;
316 e
->fields
.delivery_status
= old_delivery_status
;
319 * Some OSes (Linux, Xen) assume that Remote IRR bit will
320 * be cleared by IOAPIC hardware when the entry is configured
321 * as edge-triggered. This behavior is used to simulate an
322 * explicit EOI on IOAPICs that don't have the EOI register.
324 if (e
->fields
.trig_mode
== IOAPIC_EDGE_TRIG
)
325 e
->fields
.remote_irr
= 0;
327 mask_after
= e
->fields
.mask
;
328 if (mask_before
!= mask_after
)
329 kvm_fire_mask_notifiers(ioapic
->kvm
, KVM_IRQCHIP_IOAPIC
, index
, mask_after
);
330 if (e
->fields
.trig_mode
== IOAPIC_LEVEL_TRIG
331 && ioapic
->irr
& (1 << index
))
332 ioapic_service(ioapic
, index
, false);
333 if (e
->fields
.delivery_mode
== APIC_DM_FIXED
) {
334 struct kvm_lapic_irq irq
;
336 irq
.shorthand
= APIC_DEST_NOSHORT
;
337 irq
.vector
= e
->fields
.vector
;
338 irq
.delivery_mode
= e
->fields
.delivery_mode
<< 8;
339 irq
.dest_id
= e
->fields
.dest_id
;
341 kvm_lapic_irq_dest_mode(!!e
->fields
.dest_mode
);
342 bitmap_zero(&vcpu_bitmap
, 16);
343 kvm_bitmap_or_dest_vcpus(ioapic
->kvm
, &irq
,
345 if (old_dest_mode
!= e
->fields
.dest_mode
||
346 old_dest_id
!= e
->fields
.dest_id
) {
348 * Update vcpu_bitmap with vcpus specified in
349 * the previous request as well. This is done to
350 * keep ioapic_handled_vectors synchronized.
352 irq
.dest_id
= old_dest_id
;
354 kvm_lapic_irq_dest_mode(
355 !!e
->fields
.dest_mode
);
356 kvm_bitmap_or_dest_vcpus(ioapic
->kvm
, &irq
,
359 kvm_make_scan_ioapic_request_mask(ioapic
->kvm
,
362 kvm_make_scan_ioapic_request(ioapic
->kvm
);
368 static int ioapic_service(struct kvm_ioapic
*ioapic
, int irq
, bool line_status
)
370 union kvm_ioapic_redirect_entry
*entry
= &ioapic
->redirtbl
[irq
];
371 struct kvm_lapic_irq irqe
;
374 if (entry
->fields
.mask
||
375 (entry
->fields
.trig_mode
== IOAPIC_LEVEL_TRIG
&&
376 entry
->fields
.remote_irr
))
379 irqe
.dest_id
= entry
->fields
.dest_id
;
380 irqe
.vector
= entry
->fields
.vector
;
381 irqe
.dest_mode
= kvm_lapic_irq_dest_mode(!!entry
->fields
.dest_mode
);
382 irqe
.trig_mode
= entry
->fields
.trig_mode
;
383 irqe
.delivery_mode
= entry
->fields
.delivery_mode
<< 8;
385 irqe
.shorthand
= APIC_DEST_NOSHORT
;
386 irqe
.msi_redir_hint
= false;
388 if (irqe
.trig_mode
== IOAPIC_EDGE_TRIG
)
389 ioapic
->irr_delivered
|= 1 << irq
;
391 if (irq
== RTC_GSI
&& line_status
) {
393 * pending_eoi cannot ever become negative (see
394 * rtc_status_pending_eoi_check_valid) and the caller
395 * ensures that it is only called if it is >= zero, namely
396 * if rtc_irq_check_coalesced returns false).
398 BUG_ON(ioapic
->rtc_status
.pending_eoi
!= 0);
399 ret
= kvm_irq_delivery_to_apic(ioapic
->kvm
, NULL
, &irqe
,
400 &ioapic
->rtc_status
.dest_map
);
401 ioapic
->rtc_status
.pending_eoi
= (ret
< 0 ? 0 : ret
);
403 ret
= kvm_irq_delivery_to_apic(ioapic
->kvm
, NULL
, &irqe
, NULL
);
405 if (ret
&& irqe
.trig_mode
== IOAPIC_LEVEL_TRIG
)
406 entry
->fields
.remote_irr
= 1;
411 int kvm_ioapic_set_irq(struct kvm_ioapic
*ioapic
, int irq
, int irq_source_id
,
412 int level
, bool line_status
)
416 BUG_ON(irq
< 0 || irq
>= IOAPIC_NUM_PINS
);
418 spin_lock(&ioapic
->lock
);
419 irq_level
= __kvm_irq_line_state(&ioapic
->irq_states
[irq
],
420 irq_source_id
, level
);
421 ret
= ioapic_set_irq(ioapic
, irq
, irq_level
, line_status
);
423 spin_unlock(&ioapic
->lock
);
428 void kvm_ioapic_clear_all(struct kvm_ioapic
*ioapic
, int irq_source_id
)
432 spin_lock(&ioapic
->lock
);
433 for (i
= 0; i
< KVM_IOAPIC_NUM_PINS
; i
++)
434 __clear_bit(irq_source_id
, &ioapic
->irq_states
[i
]);
435 spin_unlock(&ioapic
->lock
);
438 static void kvm_ioapic_eoi_inject_work(struct work_struct
*work
)
441 struct kvm_ioapic
*ioapic
= container_of(work
, struct kvm_ioapic
,
443 spin_lock(&ioapic
->lock
);
444 for (i
= 0; i
< IOAPIC_NUM_PINS
; i
++) {
445 union kvm_ioapic_redirect_entry
*ent
= &ioapic
->redirtbl
[i
];
447 if (ent
->fields
.trig_mode
!= IOAPIC_LEVEL_TRIG
)
450 if (ioapic
->irr
& (1 << i
) && !ent
->fields
.remote_irr
)
451 ioapic_service(ioapic
, i
, false);
453 spin_unlock(&ioapic
->lock
);
456 #define IOAPIC_SUCCESSIVE_IRQ_MAX_COUNT 10000
458 static void __kvm_ioapic_update_eoi(struct kvm_vcpu
*vcpu
,
459 struct kvm_ioapic
*ioapic
, int vector
, int trigger_mode
)
461 struct dest_map
*dest_map
= &ioapic
->rtc_status
.dest_map
;
462 struct kvm_lapic
*apic
= vcpu
->arch
.apic
;
465 /* RTC special handling */
466 if (test_bit(vcpu
->vcpu_id
, dest_map
->map
) &&
467 vector
== dest_map
->vectors
[vcpu
->vcpu_id
])
468 rtc_irq_eoi(ioapic
, vcpu
);
470 for (i
= 0; i
< IOAPIC_NUM_PINS
; i
++) {
471 union kvm_ioapic_redirect_entry
*ent
= &ioapic
->redirtbl
[i
];
473 if (ent
->fields
.vector
!= vector
)
477 * We are dropping lock while calling ack notifiers because ack
478 * notifier callbacks for assigned devices call into IOAPIC
479 * recursively. Since remote_irr is cleared only after call
480 * to notifiers if the same vector will be delivered while lock
481 * is dropped it will be put into irr and will be delivered
482 * after ack notifier returns.
484 spin_unlock(&ioapic
->lock
);
485 kvm_notify_acked_irq(ioapic
->kvm
, KVM_IRQCHIP_IOAPIC
, i
);
486 spin_lock(&ioapic
->lock
);
488 if (trigger_mode
!= IOAPIC_LEVEL_TRIG
||
489 kvm_lapic_get_reg(apic
, APIC_SPIV
) & APIC_SPIV_DIRECTED_EOI
)
492 ASSERT(ent
->fields
.trig_mode
== IOAPIC_LEVEL_TRIG
);
493 ent
->fields
.remote_irr
= 0;
494 if (!ent
->fields
.mask
&& (ioapic
->irr
& (1 << i
))) {
495 ++ioapic
->irq_eoi
[i
];
496 if (ioapic
->irq_eoi
[i
] == IOAPIC_SUCCESSIVE_IRQ_MAX_COUNT
) {
498 * Real hardware does not deliver the interrupt
499 * immediately during eoi broadcast, and this
500 * lets a buggy guest make slow progress
501 * even if it does not correctly handle a
502 * level-triggered interrupt. Emulate this
503 * behavior if we detect an interrupt storm.
505 schedule_delayed_work(&ioapic
->eoi_inject
, HZ
/ 100);
506 ioapic
->irq_eoi
[i
] = 0;
507 trace_kvm_ioapic_delayed_eoi_inj(ent
->bits
);
509 ioapic_service(ioapic
, i
, false);
512 ioapic
->irq_eoi
[i
] = 0;
517 void kvm_ioapic_update_eoi(struct kvm_vcpu
*vcpu
, int vector
, int trigger_mode
)
519 struct kvm_ioapic
*ioapic
= vcpu
->kvm
->arch
.vioapic
;
521 spin_lock(&ioapic
->lock
);
522 __kvm_ioapic_update_eoi(vcpu
, ioapic
, vector
, trigger_mode
);
523 spin_unlock(&ioapic
->lock
);
526 static inline struct kvm_ioapic
*to_ioapic(struct kvm_io_device
*dev
)
528 return container_of(dev
, struct kvm_ioapic
, dev
);
531 static inline int ioapic_in_range(struct kvm_ioapic
*ioapic
, gpa_t addr
)
533 return ((addr
>= ioapic
->base_address
&&
534 (addr
< ioapic
->base_address
+ IOAPIC_MEM_LENGTH
)));
537 static int ioapic_mmio_read(struct kvm_vcpu
*vcpu
, struct kvm_io_device
*this,
538 gpa_t addr
, int len
, void *val
)
540 struct kvm_ioapic
*ioapic
= to_ioapic(this);
542 if (!ioapic_in_range(ioapic
, addr
))
545 ASSERT(!(addr
& 0xf)); /* check alignment */
548 spin_lock(&ioapic
->lock
);
550 case IOAPIC_REG_SELECT
:
551 result
= ioapic
->ioregsel
;
554 case IOAPIC_REG_WINDOW
:
555 result
= ioapic_read_indirect(ioapic
, addr
, len
);
562 spin_unlock(&ioapic
->lock
);
566 *(u64
*) val
= result
;
571 memcpy(val
, (char *)&result
, len
);
574 printk(KERN_WARNING
"ioapic: wrong length %d\n", len
);
579 static int ioapic_mmio_write(struct kvm_vcpu
*vcpu
, struct kvm_io_device
*this,
580 gpa_t addr
, int len
, const void *val
)
582 struct kvm_ioapic
*ioapic
= to_ioapic(this);
584 if (!ioapic_in_range(ioapic
, addr
))
587 ASSERT(!(addr
& 0xf)); /* check alignment */
601 printk(KERN_WARNING
"ioapic: Unsupported size %d\n", len
);
606 spin_lock(&ioapic
->lock
);
608 case IOAPIC_REG_SELECT
:
609 ioapic
->ioregsel
= data
& 0xFF; /* 8-bit register */
612 case IOAPIC_REG_WINDOW
:
613 ioapic_write_indirect(ioapic
, data
);
619 spin_unlock(&ioapic
->lock
);
623 static void kvm_ioapic_reset(struct kvm_ioapic
*ioapic
)
627 cancel_delayed_work_sync(&ioapic
->eoi_inject
);
628 for (i
= 0; i
< IOAPIC_NUM_PINS
; i
++)
629 ioapic
->redirtbl
[i
].fields
.mask
= 1;
630 ioapic
->base_address
= IOAPIC_DEFAULT_BASE_ADDRESS
;
631 ioapic
->ioregsel
= 0;
633 ioapic
->irr_delivered
= 0;
635 memset(ioapic
->irq_eoi
, 0x00, sizeof(ioapic
->irq_eoi
));
636 rtc_irq_eoi_tracking_reset(ioapic
);
639 static const struct kvm_io_device_ops ioapic_mmio_ops
= {
640 .read
= ioapic_mmio_read
,
641 .write
= ioapic_mmio_write
,
644 int kvm_ioapic_init(struct kvm
*kvm
)
646 struct kvm_ioapic
*ioapic
;
649 ioapic
= kzalloc(sizeof(struct kvm_ioapic
), GFP_KERNEL_ACCOUNT
);
652 spin_lock_init(&ioapic
->lock
);
653 INIT_DELAYED_WORK(&ioapic
->eoi_inject
, kvm_ioapic_eoi_inject_work
);
654 kvm
->arch
.vioapic
= ioapic
;
655 kvm_ioapic_reset(ioapic
);
656 kvm_iodevice_init(&ioapic
->dev
, &ioapic_mmio_ops
);
658 mutex_lock(&kvm
->slots_lock
);
659 ret
= kvm_io_bus_register_dev(kvm
, KVM_MMIO_BUS
, ioapic
->base_address
,
660 IOAPIC_MEM_LENGTH
, &ioapic
->dev
);
661 mutex_unlock(&kvm
->slots_lock
);
663 kvm
->arch
.vioapic
= NULL
;
670 void kvm_ioapic_destroy(struct kvm
*kvm
)
672 struct kvm_ioapic
*ioapic
= kvm
->arch
.vioapic
;
677 cancel_delayed_work_sync(&ioapic
->eoi_inject
);
678 mutex_lock(&kvm
->slots_lock
);
679 kvm_io_bus_unregister_dev(kvm
, KVM_MMIO_BUS
, &ioapic
->dev
);
680 mutex_unlock(&kvm
->slots_lock
);
681 kvm
->arch
.vioapic
= NULL
;
685 void kvm_get_ioapic(struct kvm
*kvm
, struct kvm_ioapic_state
*state
)
687 struct kvm_ioapic
*ioapic
= kvm
->arch
.vioapic
;
689 spin_lock(&ioapic
->lock
);
690 memcpy(state
, ioapic
, sizeof(struct kvm_ioapic_state
));
691 state
->irr
&= ~ioapic
->irr_delivered
;
692 spin_unlock(&ioapic
->lock
);
695 void kvm_set_ioapic(struct kvm
*kvm
, struct kvm_ioapic_state
*state
)
697 struct kvm_ioapic
*ioapic
= kvm
->arch
.vioapic
;
699 spin_lock(&ioapic
->lock
);
700 memcpy(ioapic
, state
, sizeof(struct kvm_ioapic_state
));
702 ioapic
->irr_delivered
= 0;
703 kvm_make_scan_ioapic_request(kvm
);
704 kvm_ioapic_inject_all(ioapic
, state
->irr
);
705 spin_unlock(&ioapic
->lock
);