From: "Jan Beulich" Subject: [PATCH] x86: irq_move_cleanup_interrupt() must ignore legacy vectors Date: Thu, 28 Mar 2013 15:24:25 +0000 Message-ID: <51546EB902000078000C95B2@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartB484BCB9.2__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Andrew Cooper , Keir Fraser , Marek Marczykowski 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. --=__PartB484BCB9.2__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Since the main loop in the function includes legacy vectors, and since vector_irq[] gets set up for legacy vectors regardless of whether those get handled through the IO-APIC, it must not do anything on this vector range. In fact, we should never get here for IRQs not handled through the IO-APIC, so add a respective assertion at once. For that assertion to not have false positives we however need to suppress setting up IRQ2 as an 8259A interrupt (which wasn't correct anyway). Furthermore, there's no point iterating over the vectors past LAST_HIPRIORITY_VECTOR, so terminate the loop accordingly. Signed-off-by: Jan Beulich --- a/xen/arch/x86/i8259.c +++ b/xen/arch/x86/i8259.c @@ -416,6 +416,8 @@ void __init init_IRQ(void) for (irq =3D 0; platform_legacy_irq(irq); irq++) { struct irq_desc *desc =3D irq_to_desc(irq); =20 + if ( irq =3D=3D 2 ) /* IRQ2 doesn't exist */ + continue; desc->handler =3D &i8259A_irq_type; per_cpu(vector_irq, cpu)[FIRST_LEGACY_VECTOR + irq] =3D irq; cpumask_copy(desc->arch.cpu_mask, cpumask_of(cpu)); --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -616,7 +616,9 @@ void irq_move_cleanup_interrupt(struct c ack_APIC_irq(); =20 me =3D smp_processor_id(); - for (vector =3D FIRST_DYNAMIC_VECTOR; vector < NR_VECTORS; vector++) = { + for ( vector =3D FIRST_DYNAMIC_VECTOR; + vector <=3D LAST_HIPRIORITY_VECTOR; vector++) + { unsigned int irq; unsigned int irr; struct irq_desc *desc; @@ -625,6 +627,12 @@ void irq_move_cleanup_interrupt(struct c if ((int)irq < 0) continue; =20 + if ( vector >=3D FIRST_LEGACY_VECTOR && vector <=3D LAST_LEGACY_VE= CTOR ) + { + ASSERT(IO_APIC_IRQ(irq)); + continue; + } + desc =3D irq_to_desc(irq); if (!desc) continue; --=__PartB484BCB9.2__= Content-Type: text/plain; name="x86-IRQ-move-cleanup-skip-legacy.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-IRQ-move-cleanup-skip-legacy.patch" x86: irq_move_cleanup_interrupt() must ignore legacy vectors=0A=0ASince = the main loop in the function includes legacy vectors, and since=0Avector_i= rq[] gets set up for legacy vectors regardless of whether those=0Aget = handled through the IO-APIC, it must not do anything on this vector=0Arange= . In fact, we should never get here for IRQs not handled through=0Athe = IO-APIC, so add a respective assertion at once. For that assertion=0Ato = not have false positives we however need to suppress setting up IRQ2=0Aas = an 8259A interrupt (which wasn't correct anyway).=0A=0AFurthermore, = there's no point iterating over the vectors past=0ALAST_HIPRIORITY_VECTOR, = so terminate the loop accordingly.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/i8259.c=0A+++ b/xen/arch/x86/i8= 259.c=0A@@ -416,6 +416,8 @@ void __init init_IRQ(void)=0A for (irq =3D = 0; platform_legacy_irq(irq); irq++) {=0A struct irq_desc *desc =3D = irq_to_desc(irq);=0A =0A+ if ( irq =3D=3D 2 ) /* IRQ2 = doesn't exist */=0A+ continue;=0A desc->handler =3D = &i8259A_irq_type;=0A per_cpu(vector_irq, cpu)[FIRST_LEGACY_VECTOR = + irq] =3D irq;=0A cpumask_copy(desc->arch.cpu_mask, cpumask_of(cpu= ));=0A--- a/xen/arch/x86/irq.c=0A+++ b/xen/arch/x86/irq.c=0A@@ -616,7 = +616,9 @@ void irq_move_cleanup_interrupt(struct c=0A ack_APIC_irq();= =0A =0A me =3D smp_processor_id();=0A- for (vector =3D FIRST_DYNAMIC= _VECTOR; vector < NR_VECTORS; vector++) {=0A+ for ( vector =3D = FIRST_DYNAMIC_VECTOR;=0A+ vector <=3D LAST_HIPRIORITY_VECTOR; = vector++)=0A+ {=0A unsigned int irq;=0A unsigned int = irr;=0A struct irq_desc *desc;=0A@@ -625,6 +627,12 @@ void = irq_move_cleanup_interrupt(struct c=0A if ((int)irq < 0)=0A = continue;=0A =0A+ if ( vector >=3D FIRST_LEGACY_VECTOR && = vector <=3D LAST_LEGACY_VECTOR )=0A+ {=0A+ ASSERT(IO_APIC= _IRQ(irq));=0A+ continue;=0A+ }=0A+=0A desc =3D = irq_to_desc(irq);=0A if (!desc)=0A continue;=0A --=__PartB484BCB9.2__= 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.xen.org http://lists.xen.org/xen-devel --=__PartB484BCB9.2__=--