From 66d5ede8096a7994bf1c6a73ffc308bfef3adbea Mon Sep 17 00:00:00 2001 From: Gordon Willem Klok Date: Mon, 12 Jun 2006 04:41:31 +0000 Subject: Add stray interrupt reporting to the apicvec.s, fix the code for stray interrupt reporting in vector.s. Stray interrupts will only be reported if a kernel is compiled with option DEBUG, in the case of a non-ioapic kernel some stray interrupts may be erroneously reported durring the boot process. ok toby@, "get it in" deraadt@ --- sys/arch/i386/i386/apicvec.s | 31 +++++++++++++++++++++++++++---- sys/arch/i386/i386/ioapic.c | 16 +++++++++++++++- sys/arch/i386/i386/vector.s | 10 +++++----- 3 files changed, 47 insertions(+), 10 deletions(-) (limited to 'sys/arch/i386') diff --git a/sys/arch/i386/i386/apicvec.s b/sys/arch/i386/i386/apicvec.s index 4bd274b2a5e..48a3f8e4f5a 100644 --- a/sys/arch/i386/i386/apicvec.s +++ b/sys/arch/i386/i386/apicvec.s @@ -1,4 +1,4 @@ -/* $OpenBSD: apicvec.s,v 1.6 2006/03/14 14:46:53 mickey Exp $ */ +/* $OpenBSD: apicvec.s,v 1.7 2006/06/12 04:41:30 gwk Exp $ */ /* $NetBSD: apicvec.s,v 1.1.2.2 2000/02/21 21:54:01 sommerfeld Exp $ */ /*- @@ -48,6 +48,8 @@ #define XINTR(vec) _Xintr/**/vec #endif + .globl _C_LABEL(apic_stray) + #ifdef MULTIPROCESSOR .globl XINTR(ipi) XINTR(ipi): @@ -167,7 +169,6 @@ XINTR(softtty): * We sort out which one is which based on the value of * the processor priority register. * - * XXX no stray interrupt mangling stuff.. * XXX use cmove when appropriate. */ @@ -189,7 +190,8 @@ _C_LABEL(Xintr_/**/name/**/num): \ incl _C_LABEL(apic_intrcount)(,%eax,4) ;\ movl _C_LABEL(apic_intrhand)(,%eax,4),%ebx /* chain head */ ;\ testl %ebx,%ebx ;\ - jz 8f /* oops, no handlers.. */ ;\ + jz _C_LABEL(Xstray_/**/name/**/num) ;\ + APIC_STRAY_INIT /* nobody claimed it yet */ ;\ 7: \ LOCK_KERNEL(IF_PPL(%esp)) ;\ movl IH_ARG(%ebx),%eax /* get handler arg */ ;\ @@ -200,6 +202,7 @@ _C_LABEL(Xintr_/**/name/**/num): \ pushl %eax ;\ call *IH_FUN(%ebx) /* call it */ ;\ addl $4,%esp /* toss the arg */ ;\ + APIC_STRAY_INTEGRATE /* maybe he claimed it */ ;\ orl %eax,%eax /* should it be counted? */ ;\ jz 4f ;\ addl $1,IH_COUNT(%ebx) /* count the intrs */ ;\ @@ -209,10 +212,30 @@ _C_LABEL(Xintr_/**/name/**/num): \ movl IH_NEXT(%ebx),%ebx /* next handler in chain */ ;\ testl %ebx,%ebx ;\ jnz 7b ;\ + APIC_STRAY_TEST(name,num) /* see if it's a stray */ ;\ 8: \ unmask(num) /* unmask it in hardware */ ;\ late_ack(num) ;\ - jmp _C_LABEL(Xdoreti) + jmp _C_LABEL(Xdoreti) ;\ +_C_LABEL(Xstray_/**/name/**/num): \ + pushl $num ;\ + call _C_LABEL(apic_stray) ;\ + addl $4,%esp ;\ + jmp 8b ;\ + +#if defined(DEBUG) +#define APIC_STRAY_INIT \ + xorl %esi,%esi +#define APIC_STRAY_INTEGRATE \ + orl %eax,%esi +#define APIC_STRAY_TEST(name,num) \ + testl %esi,%esi ;\ + jz _C_LABEL(Xstray_/**/name/**/num) +#else /* !DEBUG */ +#define APIC_STRAY_INIT +#define APIC_STRAY_INTEGRATE +#define APIC_STRAY_TEST(name,num) +#endif /* DEBUG */ APICINTR(ioapic,0, voidop, ioapic_asm_ack, voidop, voidop, voidop) APICINTR(ioapic,1, voidop, ioapic_asm_ack, voidop, voidop, voidop) diff --git a/sys/arch/i386/i386/ioapic.c b/sys/arch/i386/i386/ioapic.c index 1cdb463ebaf..fa719aa3099 100644 --- a/sys/arch/i386/i386/ioapic.c +++ b/sys/arch/i386/i386/ioapic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ioapic.c,v 1.10 2006/05/11 13:21:11 mickey Exp $ */ +/* $OpenBSD: ioapic.c,v 1.11 2006/06/12 04:41:30 gwk Exp $ */ /* $NetBSD: ioapic.c,v 1.7 2003/07/14 22:32:40 lukem Exp $ */ /*- @@ -107,6 +107,8 @@ extern int bus_mem_add_mapping(bus_addr_t, bus_size_t, int, void apic_set_redir(struct ioapic_softc *, int); void apic_vectorset(struct ioapic_softc *, int, int, int); +void apic_stray(int); + int apic_verbose = 0; int ioapic_bsp_id = 0; @@ -781,6 +783,18 @@ apic_intr_disestablish(void *arg) free(ih, M_DEVBUF); } +void +apic_stray(int irqnum) { + unsigned int apicid; + struct ioapic_softc *sc; + + apicid = APIC_IRQ_APIC(irqnum); + sc = ioapic_find(apicid); + if (sc == NULL) + return; + printf("%s: stray interrupt %d\n", sc->sc_dev.dv_xname, irqnum); +} + #ifdef DDB void ioapic_dump(void); diff --git a/sys/arch/i386/i386/vector.s b/sys/arch/i386/i386/vector.s index 534bc424635..78052d1f95d 100644 --- a/sys/arch/i386/i386/vector.s +++ b/sys/arch/i386/i386/vector.s @@ -1,4 +1,4 @@ -/* $OpenBSD: vector.s,v 1.7 2005/12/13 16:14:49 aaron Exp $ */ +/* $OpenBSD: vector.s,v 1.8 2006/06/12 04:41:30 gwk Exp $ */ /* $NetBSD: vector.s,v 1.32 1996/01/07 21:29:47 mycroft Exp $ */ /* @@ -141,7 +141,7 @@ _C_LABEL(Xintr_/**/name/**/num): ;\ testl %ebx,%ebx ;\ jnz 7b ;\ UNLOCK_KERNEL(IF_PPL(%esp)) ;\ - STRAY_TEST /* see if it's a stray */ ;\ + STRAY_TEST(name,num) /* see if it's a stray */ ;\ 6: unmask(num) /* unmask it in hardware */ ;\ late_ack(num) ;\ jmp _C_LABEL(Xdoreti) /* lower spl and do ASTs */ ;\ @@ -154,18 +154,18 @@ IDTVEC(hold_/**/name/**/num) ;\ orb $IRQ_BIT(num),_C_LABEL(ipending) + IRQ_BYTE(num) ;\ INTRFASTEXIT -#if defined(DEBUG) && defined(notdef) +#if defined(DEBUG) #define STRAY_INITIALIZE \ xorl %esi,%esi #define STRAY_INTEGRATE \ orl %eax,%esi -#define STRAY_TEST \ +#define STRAY_TEST(name,num) \ testl %esi,%esi ;\ jz _C_LABEL(Xstray_/**/name/**/num) #else /* !DEBUG */ #define STRAY_INITIALIZE #define STRAY_INTEGRATE -#define STRAY_TEST +#define STRAY_TEST(name,num) #endif /* DEBUG */ #ifdef DDB -- cgit v1.2.3