linux: mor assign_irq_vector() adjustments
PATCH 1/1 linux: mor assign_irq_vector() adjustments
Instead of adding locking to also protect irq_vector[] in xenlinux, this patch adds verification that the vector passed up from Xen for a certain IRQ is matching a potential previously obtained value. Besides that, two minor cleanup hunks.
Jan
arch/i386/kernel/io_apic-xen.c +6 -3
@@ -1207,7 +1207,7 @@ int assign_irq_vector(int irq) {physdev_op_t op; -BUG_ON (irq >=NR_IRQ_VECTORS ); +BUG_ON (irq !=AUTO_ASSIGN && (unsigned )irq >=NR_IRQ_VECTORS );if (irq !=AUTO_ASSIGN &&IO_APIC_VECTOR (irq) >0 )return IO_APIC_VECTOR (irq);
@@ -1217,8 +1217,11 @@ int assign_irq_vector(int irq)return -ENOSPC ; vector_irq[op.u.irq_op.vector] = irq; -if (irq !=AUTO_ASSIGN ) -IO_APIC_VECTOR (irq) = op.u.irq_op.vector; +if (irq !=AUTO_ASSIGN ) { +u8 vector =cmpxchg (&IO_APIC_VECTOR (irq),0 , op.u.irq_op.vector); + +BUG_ON (vector && vector != op.u.irq_op.vector); + }return op.u.irq_op.vector; }
arch/x86_64/kernel/io_apic-xen.c +6 -3
@@ -881,14 +881,17 @@ int assign_irq_vector(int irq)return -ENOSPC ; vector_irq[op.u.irq_op.vector] = irq; -if (irq !=AUTO_ASSIGN ) -IO_APIC_VECTOR (irq) = op.u.irq_op.vector; +if (irq !=AUTO_ASSIGN ) { +u8 vector =cmpxchg (&IO_APIC_VECTOR (irq),0 , op.u.irq_op.vector); + +BUG_ON (vector && vector != op.u.irq_op.vector); + }return op.u.irq_op.vector; } -extern void (*interrupt[NR_IRQS ])(void );#ifndef CONFIG_XEN +extern void (*interrupt[NR_IRQS ])(void );static struct hw_interrupt_type ioapic_level_type;static struct hw_interrupt_type ioapic_edge_type;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 2 lines · Jan Beulich
Instead of adding locking to also protect irq_vector[] in xenlinux, this patch adds verification that the vector passed up from Xen for a certain IRQ is matching a potential previously obtained value. Besides that, two minor cleanup hunks.
I think the extra checking here adds pointless complexity. If the check fails then you are totally screwed -- you're just going to have to trust Xen here.
-- Keir