Index: src/sys/arch/amd64/amd64/machdep.c =================================================================== --- src.orig/sys/arch/amd64/amd64/machdep.c 2010-06-05 00:19:26.220727715 +0100 +++ src/sys/arch/amd64/amd64/machdep.c 2010-06-06 11:39:57.679154664 +0100 @@ -1800,3 +1800,29 @@ { return memseg_baseaddr(l, seg, ldtp, len, NULL); } + +/* Number of times to warn about an unhandled interrupt */ +#define NUM_WARNINGS 10 + +static struct timeval lasttime; +static struct timeval intervaltime = { 5, 0 }; /* interval time is 5 seconds */ + +static unsigned long long intr_count[MAX_INTR_SOURCES]; +static int warn_count[MAX_INTR_SOURCES]; + +void unhandled_intr(int slot) +{ + intr_count[slot]++; + + if (ratecheck(&lasttime, &intervaltime)) { + if (warn_count[slot] == NUM_WARNINGS) { + warn_count[slot]++; /* So we don't warn again. */ + printf("Warned about unhandled interrupt %d times. Shutting up now.\n", + NUM_WARNINGS); + } else if (warn_count[slot] < NUM_WARNINGS) { + warn_count[slot]++; + printf("Unhandled interrupt! slot #%d, count %llu\n", + slot, intr_count[slot]); + } + } +} Index: src/sys/arch/amd64/amd64/vector.S =================================================================== --- src.orig/sys/arch/amd64/amd64/vector.S 2010-06-05 00:19:26.221322897 +0100 +++ src/sys/arch/amd64/amd64/vector.S 2010-06-05 00:19:34.732863852 +0100 @@ -682,6 +682,7 @@ sti ;\ incl CPUVAR(IDEPTH) ;\ movq IS_HANDLERS(%r14),%rbx ;\ + pushq $0 /* push 'handled' */ ;\ 6: \ movl IH_LEVEL(%rbx),%r12d ;\ cmpl %r13d,%r12d ;\ @@ -691,15 +692,22 @@ movl %r12d,CPUVAR(ILEVEL) ;\ call *IH_FUN(%rbx) /* call it */ ;\ movq IH_NEXT(%rbx),%rbx /* next handler in chain */ ;\ + addl %eax,(%rsp) ;\ testq %rbx,%rbx ;\ jnz 6b ;\ + cmpl $0,(%rsp) /* was the intr handled? */ ;\ + jne 5f ;\ + movl $num,%edi ;\ + call _C_LABEL(unhandled_intr) ;\ 5: \ + addq $8,%rsp /* pop 'handled' */ ;\ cli ;\ unmask(num) /* unmask it in hardware */ ;\ late_ack(num) ;\ sti ;\ jmp _C_LABEL(Xdoreti) /* lower spl and do ASTs */ ;\ 7: \ + addq $8,%rsp /* pop 'handled' */ ;\ cli ;\ orl $(1 << num),CPUVAR(IPENDING) ;\ level_mask(num) ;\ Index: src/sys/arch/amd64/include/intr.h =================================================================== --- src.orig/sys/arch/amd64/include/intr.h 2010-06-05 00:19:26.222315979 +0100 +++ src/sys/arch/amd64/include/intr.h 2010-06-05 00:19:34.734404421 +0100 @@ -1,3 +1,5 @@ /* $NetBSD: intr.h,v 1.1 2003/04/26 18:39:42 fvdl Exp $ */ #include + +extern void unhandled_intr(int);