Release 4.14 arch/x86/kernel/irq_32.c
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
*
* This file contains the lowest level x86-specific interrupt
* entry, irq-stacks and irq statistics code. All the remaining
* irq logic is done by the generic kernel/irq/ code and
* by the x86-specific irq controller code. (e.g. i8259.c and
* io_apic.c.)
*/
#include <linux/seq_file.h>
#include <linux/interrupt.h>
#include <linux/kernel_stat.h>
#include <linux/notifier.h>
#include <linux/cpu.h>
#include <linux/delay.h>
#include <linux/uaccess.h>
#include <linux/percpu.h>
#include <linux/mm.h>
#include <asm/apic.h>
#ifdef CONFIG_DEBUG_STACKOVERFLOW
int sysctl_panic_on_stackoverflow __read_mostly;
/* Debugging check for stack overflow: is there less than 1KB free? */
static int check_stack_overflow(void)
{
long sp;
__asm__ __volatile__("andl %%esp,%0" :
"=r" (sp) : "0" (THREAD_SIZE - 1));
return sp < (sizeof(struct thread_info) + STACK_WARN);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Gleixner | 27 | 100.00% | 1 | 100.00% |
Total | 27 | 100.00% | 1 | 100.00% |
static void print_stack_overflow(void)
{
printk(KERN_WARNING "low stack detected by irq handler\n");
dump_stack();
if (sysctl_panic_on_stackoverflow)
panic("low stack detected by irq handler - check messages\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Gleixner | 17 | 65.38% | 1 | 50.00% |
Mitsuo Hayasaka | 9 | 34.62% | 1 | 50.00% |
Total | 26 | 100.00% | 2 | 100.00% |
#else
static inline int check_stack_overflow(void) { return 0; }
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Gleixner | 12 | 100.00% | 1 | 100.00% |
Total | 12 | 100.00% | 1 | 100.00% |
static inline void print_stack_overflow(void) { }
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Gleixner | 8 | 100.00% | 1 | 100.00% |
Total | 8 | 100.00% | 1 | 100.00% |
#endif
DEFINE_PER_CPU(struct irq_stack *, hardirq_stack);
DEFINE_PER_CPU(struct irq_stack *, softirq_stack);
static void call_on_stack(void *func, void *stack)
{
asm volatile("xchgl %%ebx,%%esp \n"
"call *%%edi \n"
"movl %%ebx,%%esp \n"
: "=b" (stack)
: "0" (stack),
"D"(func)
: "memory", "cc", "edx", "ecx", "eax");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andi Kleen | 11 | 64.71% | 1 | 14.29% |
Thomas Gleixner | 2 | 11.76% | 2 | 28.57% |
Linus Torvalds | 2 | 11.76% | 2 | 28.57% |
Linus Torvalds (pre-git) | 1 | 5.88% | 1 | 14.29% |
Ingo Molnar | 1 | 5.88% | 1 | 14.29% |
Total | 17 | 100.00% | 7 | 100.00% |
static inline void *current_stack(void)
{
return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Steven Rostedt | 26 | 100.00% | 1 | 100.00% |
Total | 26 | 100.00% | 1 | 100.00% |
static inline int execute_on_irq_stack(int overflow, struct irq_desc *desc)
{
struct irq_stack *curstk, *irqstk;
u32 *isp, *prev_esp, arg1;
curstk = (struct irq_stack *) current_stack();
irqstk = __this_cpu_read(hardirq_stack);
/*
* this is where we switch to the IRQ stack. However, if we are
* already using the IRQ stack (because we interrupted a hardirq
* handler) we can't do that and just have to keep using the
* current stack (which is the irq stack already after all)
*/
if (unlikely(curstk == irqstk))
return 0;
isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
/* Save the next esp at the bottom of the stack */
prev_esp = (u32 *)irqstk;
*prev_esp = current_stack_pointer;
if (unlikely(overflow))
call_on_stack(print_stack_overflow, isp);
asm volatile("xchgl %%ebx,%%esp \n"
"call *%%edi \n"
"movl %%ebx,%%esp \n"
: "=a" (arg1), "=b" (isp)
: "0" (desc), "1" (isp),
"D" (desc->handle_irq)
: "memory", "cc", "ecx");
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 51 | 43.97% | 2 | 16.67% |
Steven Rostedt | 28 | 24.14% | 2 | 16.67% |
Thomas Gleixner | 21 | 18.10% | 3 | 25.00% |
Andi Kleen | 7 | 6.03% | 1 | 8.33% |
David Howells | 3 | 2.59% | 1 | 8.33% |
Linus Torvalds (pre-git) | 3 | 2.59% | 1 | 8.33% |
Lai Jiangshan | 2 | 1.72% | 1 | 8.33% |
Tejun Heo | 1 | 0.86% | 1 | 8.33% |
Total | 116 | 100.00% | 12 | 100.00% |
/*
* allocate per-cpu stacks for hardirq and for softirq processing
*/
void irq_ctx_init(int cpu)
{
struct irq_stack *irqstk;
if (per_cpu(hardirq_stack, cpu))
return;
irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
THREADINFO_GFP,
THREAD_SIZE_ORDER));
per_cpu(hardirq_stack, cpu) = irqstk;
irqstk = page_address(alloc_pages_node(cpu_to_node(cpu),
THREADINFO_GFP,
THREAD_SIZE_ORDER));
per_cpu(softirq_stack, cpu) = irqstk;
printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Lai Jiangshan | 26 | 26.80% | 1 | 11.11% |
Ingo Molnar | 21 | 21.65% | 1 | 11.11% |
Eric Dumazet | 18 | 18.56% | 1 | 11.11% |
Linus Torvalds (pre-git) | 14 | 14.43% | 2 | 22.22% |
Steven Rostedt | 12 | 12.37% | 1 | 11.11% |
Thomas Gleixner | 5 | 5.15% | 2 | 22.22% |
Linus Torvalds | 1 | 1.03% | 1 | 11.11% |
Total | 97 | 100.00% | 9 | 100.00% |
void do_softirq_own_stack(void)
{
struct irq_stack *irqstk;
u32 *isp, *prev_esp;
irqstk = __this_cpu_read(softirq_stack);
/* build the stack frame on the softirq stack */
isp = (u32 *) ((char *)irqstk + sizeof(*irqstk));
/* Push the previous esp onto the stack */
prev_esp = (u32 *)irqstk;
*prev_esp = current_stack_pointer;
call_on_stack(__do_softirq, isp);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ingo Molnar | 24 | 35.29% | 1 | 10.00% |
Steven Rostedt | 23 | 33.82% | 2 | 20.00% |
Linus Torvalds (pre-git) | 8 | 11.76% | 2 | 20.00% |
Thomas Gleixner | 7 | 10.29% | 1 | 10.00% |
Lai Jiangshan | 2 | 2.94% | 1 | 10.00% |
Linus Torvalds | 2 | 2.94% | 1 | 10.00% |
Frédéric Weisbecker | 1 | 1.47% | 1 | 10.00% |
Tejun Heo | 1 | 1.47% | 1 | 10.00% |
Total | 68 | 100.00% | 10 | 100.00% |
bool handle_irq(struct irq_desc *desc, struct pt_regs *regs)
{
int overflow = check_stack_overflow();
if (IS_ERR_OR_NULL(desc))
return false;
if (user_mode(regs) || !execute_on_irq_stack(overflow, desc)) {
if (unlikely(overflow))
print_stack_overflow();
generic_handle_irq_desc(desc);
}
return true;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeremy Fitzhardinge | 53 | 80.30% | 1 | 20.00% |
Thomas Gleixner | 8 | 12.12% | 2 | 40.00% |
Linus Torvalds | 4 | 6.06% | 1 | 20.00% |
Andrew Lutomirski | 1 | 1.52% | 1 | 20.00% |
Total | 66 | 100.00% | 5 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Gleixner | 115 | 21.86% | 6 | 15.79% |
Ingo Molnar | 103 | 19.58% | 3 | 7.89% |
Steven Rostedt | 95 | 18.06% | 2 | 5.26% |
Jeremy Fitzhardinge | 53 | 10.08% | 1 | 2.63% |
Lai Jiangshan | 45 | 8.56% | 1 | 2.63% |
Linus Torvalds (pre-git) | 34 | 6.46% | 7 | 18.42% |
Eric Dumazet | 21 | 3.99% | 1 | 2.63% |
Andi Kleen | 18 | 3.42% | 1 | 2.63% |
Linus Torvalds | 9 | 1.71% | 5 | 13.16% |
Mitsuo Hayasaka | 9 | 1.71% | 1 | 2.63% |
Zwane Mwaikambo | 9 | 1.71% | 1 | 2.63% |
David Howells | 3 | 0.57% | 1 | 2.63% |
Jaswinder Singh Rajput | 2 | 0.38% | 1 | 2.63% |
Andrew Morton | 2 | 0.38% | 1 | 2.63% |
Stéphane Eranian | 2 | 0.38% | 1 | 2.63% |
Tejun Heo | 2 | 0.38% | 1 | 2.63% |
Dave Jones | 1 | 0.19% | 1 | 2.63% |
Frédéric Weisbecker | 1 | 0.19% | 1 | 2.63% |
Greg Kroah-Hartman | 1 | 0.19% | 1 | 2.63% |
Andrew Lutomirski | 1 | 0.19% | 1 | 2.63% |
Total | 526 | 100.00% | 38 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.