Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 99657
b: refs/heads/master
c: 04b361a
h: refs/heads/master
i:
  99655: 041de59
v: v3
  • Loading branch information
Andi Kleen authored and Ingo Molnar committed May 12, 2008
1 parent 121109a commit fe0b9ae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ce17833183bf0a08ce3d174a2088eff0a06f2080
refs/heads/master: 04b361abfdc522239e3a071f3afdebf5787d9f03
49 changes: 33 additions & 16 deletions trunk/arch/x86/kernel/irq_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ static union irq_ctx *hardirq_ctx[NR_CPUS] __read_mostly;
static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
#endif

static void stack_overflow(void)
{
printk("low stack detected by irq handler\n");
dump_stack();
}

static inline void call_on_stack2(void *func, void *stack,
unsigned long arg1, unsigned long arg2)
{
unsigned long bx;
asm volatile(
" xchgl %%ebx,%%esp \n"
" call *%%edi \n"
" movl %%ebx,%%esp \n"
: "=a" (arg1), "=d" (arg2), "=b" (bx)
: "0" (arg1), "1" (arg2), "2" (stack),
"D" (func)
: "memory", "cc", "ecx");
}

/*
* do_IRQ handles all normal device IRQ's (the special
* SMP cross-CPU interrupts have their own specific
Expand All @@ -76,6 +96,7 @@ unsigned int do_IRQ(struct pt_regs *regs)
union irq_ctx *curctx, *irqctx;
u32 *isp;
#endif
int overflow = 0;

if (unlikely((unsigned)irq >= NR_IRQS)) {
printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
Expand All @@ -92,11 +113,8 @@ unsigned int do_IRQ(struct pt_regs *regs)

__asm__ __volatile__("andl %%esp,%0" :
"=r" (sp) : "0" (THREAD_SIZE - 1));
if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN))) {
printk("do_IRQ: stack overflow: %ld\n",
sp - sizeof(struct thread_info));
dump_stack();
}
if (unlikely(sp < (sizeof(struct thread_info) + STACK_WARN)))
overflow = 1;
}
#endif

Expand All @@ -112,8 +130,6 @@ unsigned int do_IRQ(struct pt_regs *regs)
* current stack (which is the irq stack already after all)
*/
if (curctx != irqctx) {
int arg1, arg2, bx;

/* build the stack frame on the IRQ stack */
isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
irqctx->tinfo.task = curctx->tinfo.task;
Expand All @@ -127,18 +143,19 @@ unsigned int do_IRQ(struct pt_regs *regs)
(irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) |
(curctx->tinfo.preempt_count & SOFTIRQ_MASK);

asm volatile(
" xchgl %%ebx,%%esp \n"
" call *%%edi \n"
" movl %%ebx,%%esp \n"
: "=a" (arg1), "=d" (arg2), "=b" (bx)
: "0" (irq), "1" (desc), "2" (isp),
"D" (desc->handle_irq)
: "memory", "cc", "ecx"
);
/* Execute warning on interrupt stack */
if (unlikely(overflow))
call_on_stack2(stack_overflow, isp, 0, 0);

call_on_stack2(desc->handle_irq, isp, irq, (unsigned long)desc);
} else
#endif
{
/* AK: Slightly bogus here */
if (overflow)
stack_overflow();
desc->handle_irq(irq, desc);
}

irq_exit();
set_irq_regs(old_regs);
Expand Down

0 comments on commit fe0b9ae

Please sign in to comment.