diff options
author | George Dunlap <george.dunlap@eu.citrix.com> | 2011-08-22 16:15:33 +0100 |
---|---|---|
committer | George Dunlap <george.dunlap@eu.citrix.com> | 2011-08-22 16:15:33 +0100 |
commit | 45627433b2c0eec655bef8d02a48f75bc9b80fc2 (patch) | |
tree | baca59da6a10167cffa3b95dce47633954ea3aba /xen/arch/x86/irq.c | |
parent | 1ded71e27c5ca61935734eadcd79e722cdf99732 (diff) | |
download | xen-45627433b2c0eec655bef8d02a48f75bc9b80fc2.tar.gz xen-45627433b2c0eec655bef8d02a48f75bc9b80fc2.tar.bz2 xen-45627433b2c0eec655bef8d02a48f75bc9b80fc2.zip |
x86: Fix up irq vector map logic
We need to make sure that cfg->used_vector is only cleared once;
otherwise there may be a race condition that allows the same vector to
be assigned twice, defeating the whole purpose of the map.
This makes two changes:
* __clear_irq_vector() only clears the vector if the irq is not being
moved
* smp_iqr_move_cleanup_interrupt() only clears used_vector if this
is the last place it's being used (move_cleanup_count==0 after
decrement).
Also make use of asserts more consistent, to catch this kind of logic
bug in the future.
Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com>
Diffstat (limited to 'xen/arch/x86/irq.c')
-rw-r--r-- | xen/arch/x86/irq.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 8d598c28ca..22de938a5f 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -113,7 +113,10 @@ static int __init __bind_irq_vector(int irq, int vector, cpumask_t cpu_mask) cfg->vector = vector; cfg->cpu_mask = online_mask; if ( cfg->used_vectors ) + { + ASSERT(!test_bit(vector, cfg->used_vectors)); set_bit(vector, cfg->used_vectors); + } irq_status[irq] = IRQ_USED; if (IO_APIC_IRQ(irq)) irq_vector[irq] = vector; @@ -207,15 +210,13 @@ static void __clear_irq_vector(int irq) for_each_cpu_mask(cpu, tmp_mask) per_cpu(vector_irq, cpu)[vector] = -1; - if ( cfg->used_vectors ) - clear_bit(vector, cfg->used_vectors); - cfg->vector = IRQ_VECTOR_UNASSIGNED; cpus_clear(cfg->cpu_mask); init_one_irq_status(irq); if (likely(!cfg->move_in_progress)) return; + cpus_and(tmp_mask, cfg->old_cpu_mask, cpu_online_map); for_each_cpu_mask(cpu, tmp_mask) { for (vector = FIRST_DYNAMIC_VECTOR; vector <= LAST_DYNAMIC_VECTOR; @@ -229,6 +230,12 @@ static void __clear_irq_vector(int irq) } } + if ( cfg->used_vectors ) + { + ASSERT(test_bit(vector, cfg->used_vectors)); + clear_bit(vector, cfg->used_vectors); + } + cfg->move_in_progress = 0; } |