From: c.dall@virtualopensystems.com (Christoffer Dall)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v6 09/13] ARM: KVM: vgic: retire queued, disabled interrupts
Date: Wed, 16 Jan 2013 13:01:15 -0500 [thread overview]
Message-ID: <20130116180115.29393.20261.stgit@ubuntu> (raw)
In-Reply-To: <20130116180013.29393.49165.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.
Reviewed-by: Will Deacon <will.deacon@arm.com>
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 8f32702..2d5e29f 100644
--- a/arch/arm/kvm/vgic.c
+++ b/arch/arm/kvm/vgic.c
@@ -71,6 +71,7 @@
#define ACCESS_WRITE_VALUE (3 << 1)
#define ACCESS_WRITE_MASK(x) ((x) & (3 << 1))
+static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu);
static void vgic_update_state(struct kvm *kvm);
static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg);
@@ -353,6 +354,7 @@ static bool handle_mmio_clear_enable_reg(struct kvm_vcpu *vcpu,
if (mmio->is_write) {
if (offset < 4) /* Force SGI enabled */
*reg |= 0xffff;
+ vgic_retire_disabled_irqs(vcpu);
vgic_update_state(vcpu->kvm);
return true;
}
@@ -804,6 +806,34 @@ static void vgic_update_state(struct kvm *kvm)
(((lr) & GICH_LR_PHYSID_CPUID) >> GICH_LR_PHYSID_CPUID_SHIFT)
#define MK_LR_PEND(src, irq) \
(GICH_LR_PENDING_BIT | ((src) << GICH_LR_PHYSID_CPUID_SHIFT) | (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;
+ int lr;
+
+ for_each_set_bit(lr, vgic_cpu->lr_used, vgic_cpu->nr_lr) {
+ int irq = vgic_cpu->vgic_lr[lr] & GICH_LR_VIRTUALID;
+
+ if (!vgic_irq_is_enabled(vcpu, irq)) {
+ vgic_cpu->vgic_irq_lr_map[irq] = LR_EMPTY;
+ clear_bit(lr, vgic_cpu->lr_used);
+ vgic_cpu->vgic_lr[lr] &= ~GICH_LR_STATE;
+ if (vgic_irq_is_active(vcpu, irq))
+ vgic_irq_clear_active(vcpu, irq);
+ }
+ }
+}
+
/*
* Queue an interrupt to a CPU virtual interface. Return true on success,
* or false if it wasn't possible to queue it.
next prev parent reply other threads:[~2013-01-16 18:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 18:00 [PATCH v6 00/13] KVM/ARM vGIC support Christoffer Dall
2013-01-16 18:00 ` [PATCH v6 01/13] ARM: gic: add missing distributor defintions Christoffer Dall
2013-01-16 18:00 ` [PATCH v6 02/13] KVM: ARM: Introduce KVM_SET_DEVICE_ADDRESS ioctl Christoffer Dall
2013-01-17 17:37 ` [kvmarm] " Peter Maydell
2013-01-20 23:22 ` Christoffer Dall
2013-01-21 0:06 ` Christoffer Dall
2013-01-16 18:00 ` [PATCH v6 03/13] ARM: KVM: Keep track of currently running vcpus Christoffer Dall
2013-01-16 18:00 ` [PATCH v6 04/13] ARM: gic: define GICH offsets for VGIC support Christoffer Dall
2013-01-16 18:00 ` [PATCH v6 05/13] ARM: KVM: Initial VGIC infrastructure code Christoffer Dall
2013-01-16 18:00 ` [PATCH v6 06/13] ARM: KVM: VGIC accept vcpu and dist base addresses from user space Christoffer Dall
2013-01-16 18:01 ` [PATCH v6 07/13] ARM: KVM: VGIC distributor handling Christoffer Dall
2013-01-16 18:01 ` [PATCH v6 08/13] ARM: KVM: VGIC virtual CPU interface management Christoffer Dall
2013-01-16 18:01 ` Christoffer Dall [this message]
2013-01-16 18:01 ` [PATCH v6 10/13] ARM: KVM: VGIC interrupt injection Christoffer Dall
2013-01-16 18:01 ` [PATCH v6 11/13] ARM: KVM: VGIC control interface world switch Christoffer Dall
2013-01-16 18:01 ` [PATCH v6 12/13] ARM: KVM: VGIC initialisation code Christoffer Dall
2013-01-16 18:01 ` [PATCH v6 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=20130116180115.29393.20261.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).