From: "Jan Beulich" Subject: [PATCH] linux: mor assign_irq_vector() adjustments Date: Tue, 25 Apr 2006 14:38:47 +0200 Message-ID: <444E3477.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3D183A47.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part3D183A47.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 --=__Part3D183A47.0__= Content-Type: text/plain; name="xenlinux-x86-assign_irq_vector.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xenlinux-x86-assign_irq_vector.patch" Index: head-2006-04-24/arch/i386/kernel/io_apic-xen.c =================================================================== --- head-2006-04-24.orig/arch/i386/kernel/io_apic-xen.c 2006-04-25 12:14:36.000000000 +0200 +++ head-2006-04-24/arch/i386/kernel/io_apic-xen.c 2006-04-25 13:11:31.000000000 +0200 @@ -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; } Index: head-2006-04-24/arch/x86_64/kernel/io_apic-xen.c =================================================================== --- head-2006-04-24.orig/arch/x86_64/kernel/io_apic-xen.c 2006-04-25 12:14:36.000000000 +0200 +++ head-2006-04-24/arch/x86_64/kernel/io_apic-xen.c 2006-04-25 13:11:31.000000000 +0200 @@ -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; --=__Part3D183A47.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part3D183A47.0__=--