Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1554103 > unrolled thread
| Started by | Jintack Lim <jintack@cs.columbia.edu> |
|---|---|
| First post | 2017-01-09 07:40 +0100 |
| Last post | 2017-01-09 07:40 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC 30/55] KVM: arm/arm64: Inject irqs to the guest hypervisor Jintack Lim <jintack@cs.columbia.edu> - 2017-01-09 07:40 +0100
| From | Jintack Lim <jintack@cs.columbia.edu> |
|---|---|
| Date | 2017-01-09 07:40 +0100 |
| Subject | [RFC 30/55] KVM: arm/arm64: Inject irqs to the guest hypervisor |
| Message-ID | <sXBMC-zF-49@gated-at.bofh.it> |
If we have a pending IRQ for the guest and the guest expects IRQs
to be handled in its virtual EL2 mode (the virtual IMO bit is set)
and it is not already running in virtual EL2 mode, then we have to
emulate an IRQ exception.
Signed-off-by: Jintack Lim <jintack@cs.columbia.edu>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
---
virt/kvm/arm/vgic/vgic.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c
index 6440b56..4a98654 100644
--- a/virt/kvm/arm/vgic/vgic.c
+++ b/virt/kvm/arm/vgic/vgic.c
@@ -17,6 +17,7 @@
#include <linux/kvm.h>
#include <linux/kvm_host.h>
#include <linux/list_sort.h>
+#include <asm/kvm_emulate.h>
#include "vgic.h"
@@ -652,6 +653,28 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu)
/* Nuke remaining LRs */
for ( ; count < kvm_vgic_global_state.nr_lr; count++)
vgic_clear_lr(vcpu, count);
+
+ /*
+ * If we have any pending IRQ for the guest and the guest expects IRQs
+ * to be handled in its virtual EL2 mode (the virtual IMO bit is set)
+ * and it is not already running in virtual EL2 mode, then we have to
+ * emulate an IRQ exception to virtual IRQ. Note that a pending IRQ
+ * means an irq of which state is pending but not active.
+ */
+ if (vcpu_el2_imo_is_set(vcpu) && !vcpu_mode_el2(vcpu)) {
+ bool pending = false;
+
+ list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) {
+ spin_lock(&irq->irq_lock);
+ pending = irq->pending && irq->enabled && !irq->active;
+ spin_unlock(&irq->irq_lock);
+
+ if (pending) {
+ kvm_inject_nested_irq(vcpu);
+ break;
+ }
+ }
+ }
}
/* Sync back the hardware VGIC state into our emulation after a guest's run. */
--
1.9.1
Back to top | Article view | linux.kernel
csiph-web