From: c.dall@virtualopensystems.com (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 08/13] ARM: KVM: vgic: retire queued, disabled interrupts
Date: Mon, 22 Oct 2012 02:52:10 -0400 [thread overview]
Message-ID: <20121022065209.18672.42742.stgit@ubuntu> (raw)
In-Reply-To: <20121022065104.18672.52989.stgit@ubuntu>
From: Marc Zyngier <marc.zyngier@arm.com>
An interrupt may have been disabled after being made pending on the
CPU interface (the classic case is a timer running while we're
rebooting the guest - the interrupt would kick as soon as the CPU
interface gets enabled, with deadly consequences).
The solution is to examine already active LRs, and check the
interrupt is still enabled. If not, just retire it.
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
---
arch/arm/kvm/vgic.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/arch/arm/kvm/vgic.c b/arch/arm/kvm/vgic.c
index d7cdec5..dda5623 100644
--- a/arch/arm/kvm/vgic.c
+++ b/arch/arm/kvm/vgic.c
@@ -633,6 +633,34 @@ static void vgic_update_state(struct kvm *kvm)
#define LR_PHYSID(lr) (((lr) & VGIC_LR_PHYSID_CPUID) >> 10)
#define MK_LR_PEND(src, irq) (VGIC_LR_PENDING_BIT | ((src) << 10) | (irq))
+
+/*
+ * An interrupt may have been disabled after being made pending on the
+ * CPU interface (the classic case is a timer running while we're
+ * rebooting the guest - the interrupt would kick as soon as the CPU
+ * interface gets enabled, with deadly consequences).
+ *
+ * The solution is to examine already active LRs, and check the
+ * interrupt is still enabled. If not, just retire it.
+ */
+static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu)
+{
+ struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
+ struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
+ int lr;
+
+ for_each_set_bit(lr, vgic_cpu->lr_used, vgic_cpu->nr_lr) {
+ int irq = vgic_cpu->vgic_lr[lr] & VGIC_LR_VIRTUALID;
+
+ if (!vgic_bitmap_get_irq_val(&dist->irq_enabled,
+ vcpu->vcpu_id, irq)) {
+ vgic_cpu->vgic_irq_lr_map[irq] = LR_EMPTY;
+ clear_bit(lr, vgic_cpu->lr_used);
+ vgic_cpu->vgic_lr[lr] &= ~VGIC_LR_STATE;
+ }
+ }
+}
+
/*
* Queue an interrupt to a CPU virtual interface. Return true on success,
* or false if it wasn't possible to queue it.
@@ -696,6 +724,8 @@ static void __kvm_vgic_sync_to_cpu(struct kvm_vcpu *vcpu)
vcpu_id = vcpu->vcpu_id;
+ vgic_retire_disabled_irqs(vcpu);
+
/*
* We may not have any pending interrupt, or the interrupts
* may have been serviced from another vcpu. In all cases,
next prev parent reply other threads:[~2012-10-22 6:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 6:51 [PATCH v3 00/13] KVM/ARM vGIC support Christoffer Dall
2012-10-22 6:51 ` [PATCH v3 01/13] KVM: ARM: Introduce KVM_SET_DEVICE_ADDRESS ioctl Christoffer Dall
2012-11-09 13:45 ` [kvmarm] " Peter Maydell
2012-11-09 13:51 ` Benjamin Herrenschmidt
2012-11-10 8:36 ` Christoffer Dall
2012-10-22 6:51 ` [PATCH v3 02/13] ARM: KVM: Keep track of currently running vcpus Christoffer Dall
2012-10-22 6:51 ` [PATCH v3 03/13] ARM: KVM: Initial VGIC infrastructure support Christoffer Dall
2012-10-22 6:51 ` [PATCH v3 04/13] ARM: KVM: Initial VGIC MMIO support code Christoffer Dall
2012-10-22 6:51 ` [PATCH v3 05/13] ARM: KVM: VGIC accept vcpu and dist base addresses from user space Christoffer Dall
2012-10-22 6:51 ` [PATCH v3 06/13] ARM: KVM: VGIC distributor handling Christoffer Dall
2012-10-22 6:52 ` [PATCH v3 07/13] ARM: KVM: VGIC virtual CPU interface management Christoffer Dall
2012-10-22 6:52 ` Christoffer Dall [this message]
2012-10-22 6:52 ` [PATCH v3 09/13] ARM: KVM: VGIC interrupt injection Christoffer Dall
2012-10-22 6:52 ` [PATCH v3 10/13] ARM: KVM: VGIC control interface world switch Christoffer Dall
2012-10-22 6:52 ` [PATCH v3 11/13] ARM: KVM: VGIC initialisation code Christoffer Dall
2012-10-22 6:52 ` [PATCH v3 12/13] ARM: KVM: vgic: reduce the number of vcpu kick Christoffer Dall
2012-10-22 6:52 ` [PATCH v3 13/13] ARM: KVM: Add VGIC configuration option Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121022065209.18672.42742.stgit@ubuntu \
--to=c.dall@virtualopensystems.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).