xen/arm: gic: Document how gic_set_irq_type should be called
authorJulien Grall <julien.grall@arm.com>
Wed, 27 Jul 2016 13:58:26 +0000 (14:58 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Wed, 27 Jul 2016 19:23:35 +0000 (12:23 -0700)
Changing the value of Int_config is UNPREDICTABLE when the corresponding
interrupt is not disabled.

The driver is assuming the interrupt will be disabled by the caller of
gic_set_irq_type. Add an ASSERT to ensure it.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/gic.c

index b9371a76371bb1fdb492d24f93b7c6558e98f382..72bb885d8d82a68e7ac44e3b4eba6b41bae97ac3 100644 (file)
@@ -96,8 +96,14 @@ void gic_restore_state(struct vcpu *v)
     gic_restore_pending_irqs(v);
 }
 
+/* desc->irq needs to be disabled before calling this function */
 static void gic_set_irq_type(struct irq_desc *desc, unsigned int type)
 {
+    /*
+     * IRQ must be disabled before configuring it (see 4.3.13 in ARM IHI
+     * 0048B.b). We rely on the caller to do it.
+     */
+    ASSERT(test_bit(_IRQ_DISABLED, &desc->status));
     ASSERT(spin_is_locked(&desc->lock));
     ASSERT(type != IRQ_TYPE_INVALID);