2 * Copyright (C) 2015, 2016 ARM Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include <linux/kvm.h>
18 #include <linux/kvm_host.h>
19 #include <linux/list_sort.h>
23 #define CREATE_TRACE_POINTS
26 #ifdef CONFIG_DEBUG_SPINLOCK
27 #define DEBUG_SPINLOCK_BUG_ON(p) BUG_ON(p)
29 #define DEBUG_SPINLOCK_BUG_ON(p)
32 struct vgic_global kvm_vgic_global_state __ro_after_init
= {
33 .gicv3_cpuif
= STATIC_KEY_FALSE_INIT
,
37 * Locking order is always:
39 * its->cmd_lock (mutex)
40 * its->its_lock (mutex)
41 * vgic_cpu->ap_list_lock
45 * If you need to take multiple locks, always take the upper lock first,
46 * then the lower ones, e.g. first take the its_lock, then the irq_lock.
47 * If you are already holding a lock and need to take a higher one, you
48 * have to drop the lower ranking lock first and re-aquire it after having
49 * taken the upper one.
51 * When taking more than one ap_list_lock at the same time, always take the
52 * lowest numbered VCPU's ap_list_lock first, so:
53 * vcpuX->vcpu_id < vcpuY->vcpu_id:
54 * spin_lock(vcpuX->arch.vgic_cpu.ap_list_lock);
55 * spin_lock(vcpuY->arch.vgic_cpu.ap_list_lock);
57 * Since the VGIC must support injecting virtual interrupts from ISRs, we have
58 * to use the spin_lock_irqsave/spin_unlock_irqrestore versions of outer
59 * spinlocks for any lock that may be taken while injecting an interrupt.
63 * Iterate over the VM's list of mapped LPIs to find the one with a
64 * matching interrupt ID and return a reference to the IRQ structure.
66 static struct vgic_irq
*vgic_get_lpi(struct kvm
*kvm
, u32 intid
)
68 struct vgic_dist
*dist
= &kvm
->arch
.vgic
;
69 struct vgic_irq
*irq
= NULL
;
71 spin_lock(&dist
->lpi_list_lock
);
73 list_for_each_entry(irq
, &dist
->lpi_list_head
, lpi_list
) {
74 if (irq
->intid
!= intid
)
78 * This increases the refcount, the caller is expected to
79 * call vgic_put_irq() later once it's finished with the IRQ.
81 vgic_get_irq_kref(irq
);
87 spin_unlock(&dist
->lpi_list_lock
);
93 * This looks up the virtual interrupt ID to get the corresponding
94 * struct vgic_irq. It also increases the refcount, so any caller is expected
95 * to call vgic_put_irq() once it's finished with this IRQ.
97 struct vgic_irq
*vgic_get_irq(struct kvm
*kvm
, struct kvm_vcpu
*vcpu
,
101 if (intid
<= VGIC_MAX_PRIVATE
)
102 return &vcpu
->arch
.vgic_cpu
.private_irqs
[intid
];
105 if (intid
<= VGIC_MAX_SPI
)
106 return &kvm
->arch
.vgic
.spis
[intid
- VGIC_NR_PRIVATE_IRQS
];
109 if (intid
>= VGIC_MIN_LPI
)
110 return vgic_get_lpi(kvm
, intid
);
112 WARN(1, "Looking up struct vgic_irq for reserved INTID");
117 * We can't do anything in here, because we lack the kvm pointer to
118 * lock and remove the item from the lpi_list. So we keep this function
119 * empty and use the return value of kref_put() to trigger the freeing.
121 static void vgic_irq_release(struct kref
*ref
)
125 void vgic_put_irq(struct kvm
*kvm
, struct vgic_irq
*irq
)
127 struct vgic_dist
*dist
= &kvm
->arch
.vgic
;
129 if (irq
->intid
< VGIC_MIN_LPI
)
132 spin_lock(&dist
->lpi_list_lock
);
133 if (!kref_put(&irq
->refcount
, vgic_irq_release
)) {
134 spin_unlock(&dist
->lpi_list_lock
);
138 list_del(&irq
->lpi_list
);
139 dist
->lpi_list_count
--;
140 spin_unlock(&dist
->lpi_list_lock
);
146 * kvm_vgic_target_oracle - compute the target vcpu for an irq
148 * @irq: The irq to route. Must be already locked.
150 * Based on the current state of the interrupt (enabled, pending,
151 * active, vcpu and target_vcpu), compute the next vcpu this should be
152 * given to. Return NULL if this shouldn't be injected at all.
154 * Requires the IRQ lock to be held.
156 static struct kvm_vcpu
*vgic_target_oracle(struct vgic_irq
*irq
)
158 DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&irq
->irq_lock
));
160 /* If the interrupt is active, it must stay on the current vcpu */
162 return irq
->vcpu
? : irq
->target_vcpu
;
165 * If the IRQ is not active but enabled and pending, we should direct
166 * it to its configured target VCPU.
167 * If the distributor is disabled, pending interrupts shouldn't be
170 if (irq
->enabled
&& irq_is_pending(irq
)) {
171 if (unlikely(irq
->target_vcpu
&&
172 !irq
->target_vcpu
->kvm
->arch
.vgic
.enabled
))
175 return irq
->target_vcpu
;
178 /* If neither active nor pending and enabled, then this IRQ should not
179 * be queued to any VCPU.
185 * The order of items in the ap_lists defines how we'll pack things in LRs as
186 * well, the first items in the list being the first things populated in the
189 * A hard rule is that active interrupts can never be pushed out of the LRs
190 * (and therefore take priority) since we cannot reliably trap on deactivation
191 * of IRQs and therefore they have to be present in the LRs.
193 * Otherwise things should be sorted by the priority field and the GIC
194 * hardware support will take care of preemption of priority groups etc.
196 * Return negative if "a" sorts before "b", 0 to preserve order, and positive
197 * to sort "b" before "a".
199 static int vgic_irq_cmp(void *priv
, struct list_head
*a
, struct list_head
*b
)
201 struct vgic_irq
*irqa
= container_of(a
, struct vgic_irq
, ap_list
);
202 struct vgic_irq
*irqb
= container_of(b
, struct vgic_irq
, ap_list
);
206 spin_lock(&irqa
->irq_lock
);
207 spin_lock_nested(&irqb
->irq_lock
, SINGLE_DEPTH_NESTING
);
209 if (irqa
->active
|| irqb
->active
) {
210 ret
= (int)irqb
->active
- (int)irqa
->active
;
214 penda
= irqa
->enabled
&& irq_is_pending(irqa
);
215 pendb
= irqb
->enabled
&& irq_is_pending(irqb
);
217 if (!penda
|| !pendb
) {
218 ret
= (int)pendb
- (int)penda
;
222 /* Both pending and enabled, sort by priority */
223 ret
= irqa
->priority
- irqb
->priority
;
225 spin_unlock(&irqb
->irq_lock
);
226 spin_unlock(&irqa
->irq_lock
);
230 /* Must be called with the ap_list_lock held */
231 static void vgic_sort_ap_list(struct kvm_vcpu
*vcpu
)
233 struct vgic_cpu
*vgic_cpu
= &vcpu
->arch
.vgic_cpu
;
235 DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu
->ap_list_lock
));
237 list_sort(NULL
, &vgic_cpu
->ap_list_head
, vgic_irq_cmp
);
241 * Only valid injection if changing level for level-triggered IRQs or for a
242 * rising edge, and in-kernel connected IRQ lines can only be controlled by
245 static bool vgic_validate_injection(struct vgic_irq
*irq
, bool level
, void *owner
)
247 if (irq
->owner
!= owner
)
250 switch (irq
->config
) {
251 case VGIC_CONFIG_LEVEL
:
252 return irq
->line_level
!= level
;
253 case VGIC_CONFIG_EDGE
:
261 * Check whether an IRQ needs to (and can) be queued to a VCPU's ap list.
262 * Do the queuing if necessary, taking the right locks in the right order.
263 * Returns true when the IRQ was queued, false otherwise.
265 * Needs to be entered with the IRQ lock already held, but will return
266 * with all locks dropped.
268 bool vgic_queue_irq_unlock(struct kvm
*kvm
, struct vgic_irq
*irq
,
271 struct kvm_vcpu
*vcpu
;
273 DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&irq
->irq_lock
));
276 vcpu
= vgic_target_oracle(irq
);
277 if (irq
->vcpu
|| !vcpu
) {
279 * If this IRQ is already on a VCPU's ap_list, then it
280 * cannot be moved or modified and there is no more work for
283 * Otherwise, if the irq is not pending and enabled, it does
284 * not need to be inserted into an ap_list and there is also
285 * no more work for us to do.
287 spin_unlock_irqrestore(&irq
->irq_lock
, flags
);
290 * We have to kick the VCPU here, because we could be
291 * queueing an edge-triggered interrupt for which we
292 * get no EOI maintenance interrupt. In that case,
293 * while the IRQ is already on the VCPU's AP list, the
294 * VCPU could have EOI'ed the original interrupt and
295 * won't see this one until it exits for some other
299 kvm_make_request(KVM_REQ_IRQ_PENDING
, vcpu
);
306 * We must unlock the irq lock to take the ap_list_lock where
307 * we are going to insert this new pending interrupt.
309 spin_unlock_irqrestore(&irq
->irq_lock
, flags
);
311 /* someone can do stuff here, which we re-check below */
313 spin_lock_irqsave(&vcpu
->arch
.vgic_cpu
.ap_list_lock
, flags
);
314 spin_lock(&irq
->irq_lock
);
317 * Did something change behind our backs?
319 * There are two cases:
320 * 1) The irq lost its pending state or was disabled behind our
321 * backs and/or it was queued to another VCPU's ap_list.
322 * 2) Someone changed the affinity on this irq behind our
323 * backs and we are now holding the wrong ap_list_lock.
325 * In both cases, drop the locks and retry.
328 if (unlikely(irq
->vcpu
|| vcpu
!= vgic_target_oracle(irq
))) {
329 spin_unlock(&irq
->irq_lock
);
330 spin_unlock_irqrestore(&vcpu
->arch
.vgic_cpu
.ap_list_lock
, flags
);
332 spin_lock_irqsave(&irq
->irq_lock
, flags
);
337 * Grab a reference to the irq to reflect the fact that it is
338 * now in the ap_list.
340 vgic_get_irq_kref(irq
);
341 list_add_tail(&irq
->ap_list
, &vcpu
->arch
.vgic_cpu
.ap_list_head
);
344 spin_unlock(&irq
->irq_lock
);
345 spin_unlock_irqrestore(&vcpu
->arch
.vgic_cpu
.ap_list_lock
, flags
);
347 kvm_make_request(KVM_REQ_IRQ_PENDING
, vcpu
);
354 * kvm_vgic_inject_irq - Inject an IRQ from a device to the vgic
355 * @kvm: The VM structure pointer
356 * @cpuid: The CPU for PPIs
357 * @intid: The INTID to inject a new state to.
358 * @level: Edge-triggered: true: to trigger the interrupt
359 * false: to ignore the call
360 * Level-sensitive true: raise the input signal
361 * false: lower the input signal
362 * @owner: The opaque pointer to the owner of the IRQ being raised to verify
363 * that the caller is allowed to inject this IRQ. Userspace
364 * injections will have owner == NULL.
366 * The VGIC is not concerned with devices being active-LOW or active-HIGH for
367 * level-sensitive interrupts. You can think of the level parameter as 1
368 * being HIGH and 0 being LOW and all devices being active-HIGH.
370 int kvm_vgic_inject_irq(struct kvm
*kvm
, int cpuid
, unsigned int intid
,
371 bool level
, void *owner
)
373 struct kvm_vcpu
*vcpu
;
374 struct vgic_irq
*irq
;
378 trace_vgic_update_irq_pending(cpuid
, intid
, level
);
380 ret
= vgic_lazy_init(kvm
);
384 vcpu
= kvm_get_vcpu(kvm
, cpuid
);
385 if (!vcpu
&& intid
< VGIC_NR_PRIVATE_IRQS
)
388 irq
= vgic_get_irq(kvm
, vcpu
, intid
);
392 spin_lock_irqsave(&irq
->irq_lock
, flags
);
394 if (!vgic_validate_injection(irq
, level
, owner
)) {
395 /* Nothing to see here, move along... */
396 spin_unlock_irqrestore(&irq
->irq_lock
, flags
);
397 vgic_put_irq(kvm
, irq
);
401 if (irq
->config
== VGIC_CONFIG_LEVEL
)
402 irq
->line_level
= level
;
404 irq
->pending_latch
= true;
406 vgic_queue_irq_unlock(kvm
, irq
, flags
);
407 vgic_put_irq(kvm
, irq
);
412 int kvm_vgic_map_phys_irq(struct kvm_vcpu
*vcpu
, u32 virt_irq
, u32 phys_irq
)
414 struct vgic_irq
*irq
= vgic_get_irq(vcpu
->kvm
, vcpu
, virt_irq
);
419 spin_lock_irqsave(&irq
->irq_lock
, flags
);
422 irq
->hwintid
= phys_irq
;
424 spin_unlock_irqrestore(&irq
->irq_lock
, flags
);
425 vgic_put_irq(vcpu
->kvm
, irq
);
430 int kvm_vgic_unmap_phys_irq(struct kvm_vcpu
*vcpu
, unsigned int virt_irq
)
432 struct vgic_irq
*irq
;
435 if (!vgic_initialized(vcpu
->kvm
))
438 irq
= vgic_get_irq(vcpu
->kvm
, vcpu
, virt_irq
);
441 spin_lock_irqsave(&irq
->irq_lock
, flags
);
446 spin_unlock_irqrestore(&irq
->irq_lock
, flags
);
447 vgic_put_irq(vcpu
->kvm
, irq
);
453 * kvm_vgic_set_owner - Set the owner of an interrupt for a VM
455 * @vcpu: Pointer to the VCPU (used for PPIs)
456 * @intid: The virtual INTID identifying the interrupt (PPI or SPI)
457 * @owner: Opaque pointer to the owner
459 * Returns 0 if intid is not already used by another in-kernel device and the
460 * owner is set, otherwise returns an error code.
462 int kvm_vgic_set_owner(struct kvm_vcpu
*vcpu
, unsigned int intid
, void *owner
)
464 struct vgic_irq
*irq
;
467 if (!vgic_initialized(vcpu
->kvm
))
470 /* SGIs and LPIs cannot be wired up to any device */
471 if (!irq_is_ppi(intid
) && !vgic_valid_spi(vcpu
->kvm
, intid
))
474 irq
= vgic_get_irq(vcpu
->kvm
, vcpu
, intid
);
475 spin_lock(&irq
->irq_lock
);
476 if (irq
->owner
&& irq
->owner
!= owner
)
480 spin_unlock(&irq
->irq_lock
);
486 * vgic_prune_ap_list - Remove non-relevant interrupts from the list
488 * @vcpu: The VCPU pointer
490 * Go over the list of "interesting" interrupts, and prune those that we
491 * won't have to consider in the near future.
493 static void vgic_prune_ap_list(struct kvm_vcpu
*vcpu
)
495 struct vgic_cpu
*vgic_cpu
= &vcpu
->arch
.vgic_cpu
;
496 struct vgic_irq
*irq
, *tmp
;
500 spin_lock_irqsave(&vgic_cpu
->ap_list_lock
, flags
);
502 list_for_each_entry_safe(irq
, tmp
, &vgic_cpu
->ap_list_head
, ap_list
) {
503 struct kvm_vcpu
*target_vcpu
, *vcpuA
, *vcpuB
;
505 spin_lock(&irq
->irq_lock
);
507 BUG_ON(vcpu
!= irq
->vcpu
);
509 target_vcpu
= vgic_target_oracle(irq
);
513 * We don't need to process this interrupt any
514 * further, move it off the list.
516 list_del(&irq
->ap_list
);
518 spin_unlock(&irq
->irq_lock
);
521 * This vgic_put_irq call matches the
522 * vgic_get_irq_kref in vgic_queue_irq_unlock,
523 * where we added the LPI to the ap_list. As
524 * we remove the irq from the list, we drop
525 * also drop the refcount.
527 vgic_put_irq(vcpu
->kvm
, irq
);
531 if (target_vcpu
== vcpu
) {
532 /* We're on the right CPU */
533 spin_unlock(&irq
->irq_lock
);
537 /* This interrupt looks like it has to be migrated. */
539 spin_unlock(&irq
->irq_lock
);
540 spin_unlock_irqrestore(&vgic_cpu
->ap_list_lock
, flags
);
543 * Ensure locking order by always locking the smallest
546 if (vcpu
->vcpu_id
< target_vcpu
->vcpu_id
) {
554 spin_lock_irqsave(&vcpuA
->arch
.vgic_cpu
.ap_list_lock
, flags
);
555 spin_lock_nested(&vcpuB
->arch
.vgic_cpu
.ap_list_lock
,
556 SINGLE_DEPTH_NESTING
);
557 spin_lock(&irq
->irq_lock
);
560 * If the affinity has been preserved, move the
561 * interrupt around. Otherwise, it means things have
562 * changed while the interrupt was unlocked, and we
563 * need to replay this.
565 * In all cases, we cannot trust the list not to have
566 * changed, so we restart from the beginning.
568 if (target_vcpu
== vgic_target_oracle(irq
)) {
569 struct vgic_cpu
*new_cpu
= &target_vcpu
->arch
.vgic_cpu
;
571 list_del(&irq
->ap_list
);
572 irq
->vcpu
= target_vcpu
;
573 list_add_tail(&irq
->ap_list
, &new_cpu
->ap_list_head
);
576 spin_unlock(&irq
->irq_lock
);
577 spin_unlock(&vcpuB
->arch
.vgic_cpu
.ap_list_lock
);
578 spin_unlock_irqrestore(&vcpuA
->arch
.vgic_cpu
.ap_list_lock
, flags
);
582 spin_unlock_irqrestore(&vgic_cpu
->ap_list_lock
, flags
);
585 static inline void vgic_fold_lr_state(struct kvm_vcpu
*vcpu
)
587 if (kvm_vgic_global_state
.type
== VGIC_V2
)
588 vgic_v2_fold_lr_state(vcpu
);
590 vgic_v3_fold_lr_state(vcpu
);
593 /* Requires the irq_lock to be held. */
594 static inline void vgic_populate_lr(struct kvm_vcpu
*vcpu
,
595 struct vgic_irq
*irq
, int lr
)
597 DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&irq
->irq_lock
));
599 if (kvm_vgic_global_state
.type
== VGIC_V2
)
600 vgic_v2_populate_lr(vcpu
, irq
, lr
);
602 vgic_v3_populate_lr(vcpu
, irq
, lr
);
605 static inline void vgic_clear_lr(struct kvm_vcpu
*vcpu
, int lr
)
607 if (kvm_vgic_global_state
.type
== VGIC_V2
)
608 vgic_v2_clear_lr(vcpu
, lr
);
610 vgic_v3_clear_lr(vcpu
, lr
);
613 static inline void vgic_set_underflow(struct kvm_vcpu
*vcpu
)
615 if (kvm_vgic_global_state
.type
== VGIC_V2
)
616 vgic_v2_set_underflow(vcpu
);
618 vgic_v3_set_underflow(vcpu
);
621 /* Requires the ap_list_lock to be held. */
622 static int compute_ap_list_depth(struct kvm_vcpu
*vcpu
)
624 struct vgic_cpu
*vgic_cpu
= &vcpu
->arch
.vgic_cpu
;
625 struct vgic_irq
*irq
;
628 DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu
->ap_list_lock
));
630 list_for_each_entry(irq
, &vgic_cpu
->ap_list_head
, ap_list
) {
631 spin_lock(&irq
->irq_lock
);
632 /* GICv2 SGIs can count for more than one... */
633 if (vgic_irq_is_sgi(irq
->intid
) && irq
->source
)
634 count
+= hweight8(irq
->source
);
637 spin_unlock(&irq
->irq_lock
);
642 /* Requires the VCPU's ap_list_lock to be held. */
643 static void vgic_flush_lr_state(struct kvm_vcpu
*vcpu
)
645 struct vgic_cpu
*vgic_cpu
= &vcpu
->arch
.vgic_cpu
;
646 struct vgic_irq
*irq
;
649 DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu
->ap_list_lock
));
651 if (compute_ap_list_depth(vcpu
) > kvm_vgic_global_state
.nr_lr
)
652 vgic_sort_ap_list(vcpu
);
654 list_for_each_entry(irq
, &vgic_cpu
->ap_list_head
, ap_list
) {
655 spin_lock(&irq
->irq_lock
);
657 if (unlikely(vgic_target_oracle(irq
) != vcpu
))
661 * If we get an SGI with multiple sources, try to get
662 * them in all at once.
665 vgic_populate_lr(vcpu
, irq
, count
++);
666 } while (irq
->source
&& count
< kvm_vgic_global_state
.nr_lr
);
669 spin_unlock(&irq
->irq_lock
);
671 if (count
== kvm_vgic_global_state
.nr_lr
) {
672 if (!list_is_last(&irq
->ap_list
,
673 &vgic_cpu
->ap_list_head
))
674 vgic_set_underflow(vcpu
);
679 vcpu
->arch
.vgic_cpu
.used_lrs
= count
;
681 /* Nuke remaining LRs */
682 for ( ; count
< kvm_vgic_global_state
.nr_lr
; count
++)
683 vgic_clear_lr(vcpu
, count
);
686 /* Sync back the hardware VGIC state into our emulation after a guest's run. */
687 void kvm_vgic_sync_hwstate(struct kvm_vcpu
*vcpu
)
689 struct vgic_cpu
*vgic_cpu
= &vcpu
->arch
.vgic_cpu
;
691 /* An empty ap_list_head implies used_lrs == 0 */
692 if (list_empty(&vcpu
->arch
.vgic_cpu
.ap_list_head
))
695 if (vgic_cpu
->used_lrs
)
696 vgic_fold_lr_state(vcpu
);
697 vgic_prune_ap_list(vcpu
);
700 /* Flush our emulation state into the GIC hardware before entering the guest. */
701 void kvm_vgic_flush_hwstate(struct kvm_vcpu
*vcpu
)
704 * If there are no virtual interrupts active or pending for this
705 * VCPU, then there is no work to do and we can bail out without
706 * taking any lock. There is a potential race with someone injecting
707 * interrupts to the VCPU, but it is a benign race as the VCPU will
708 * either observe the new interrupt before or after doing this check,
709 * and introducing additional synchronization mechanism doesn't change
712 if (list_empty(&vcpu
->arch
.vgic_cpu
.ap_list_head
))
715 DEBUG_SPINLOCK_BUG_ON(!irqs_disabled());
717 spin_lock(&vcpu
->arch
.vgic_cpu
.ap_list_lock
);
718 vgic_flush_lr_state(vcpu
);
719 spin_unlock(&vcpu
->arch
.vgic_cpu
.ap_list_lock
);
722 void kvm_vgic_load(struct kvm_vcpu
*vcpu
)
724 if (unlikely(!vgic_initialized(vcpu
->kvm
)))
727 if (kvm_vgic_global_state
.type
== VGIC_V2
)
733 void kvm_vgic_put(struct kvm_vcpu
*vcpu
)
735 if (unlikely(!vgic_initialized(vcpu
->kvm
)))
738 if (kvm_vgic_global_state
.type
== VGIC_V2
)
744 int kvm_vgic_vcpu_pending_irq(struct kvm_vcpu
*vcpu
)
746 struct vgic_cpu
*vgic_cpu
= &vcpu
->arch
.vgic_cpu
;
747 struct vgic_irq
*irq
;
748 bool pending
= false;
751 if (!vcpu
->kvm
->arch
.vgic
.enabled
)
754 spin_lock_irqsave(&vgic_cpu
->ap_list_lock
, flags
);
756 list_for_each_entry(irq
, &vgic_cpu
->ap_list_head
, ap_list
) {
757 spin_lock(&irq
->irq_lock
);
758 pending
= irq_is_pending(irq
) && irq
->enabled
;
759 spin_unlock(&irq
->irq_lock
);
765 spin_unlock_irqrestore(&vgic_cpu
->ap_list_lock
, flags
);
770 void vgic_kick_vcpus(struct kvm
*kvm
)
772 struct kvm_vcpu
*vcpu
;
776 * We've injected an interrupt, time to find out who deserves
779 kvm_for_each_vcpu(c
, vcpu
, kvm
) {
780 if (kvm_vgic_vcpu_pending_irq(vcpu
)) {
781 kvm_make_request(KVM_REQ_IRQ_PENDING
, vcpu
);
787 bool kvm_vgic_map_is_active(struct kvm_vcpu
*vcpu
, unsigned int virt_irq
)
789 struct vgic_irq
*irq
= vgic_get_irq(vcpu
->kvm
, vcpu
, virt_irq
);
793 if (!vgic_initialized(vcpu
->kvm
))
796 spin_lock_irqsave(&irq
->irq_lock
, flags
);
797 map_is_active
= irq
->hw
&& irq
->active
;
798 spin_unlock_irqrestore(&irq
->irq_lock
, flags
);
799 vgic_put_irq(vcpu
->kvm
, irq
);
801 return map_is_active
;