2012-03-05 18:49:29 +07:00
|
|
|
#ifndef __ASM_IRQ_H
|
|
|
|
#define __ASM_IRQ_H
|
|
|
|
|
2015-12-04 18:02:26 +07:00
|
|
|
#define IRQ_STACK_SIZE THREAD_SIZE
|
|
|
|
#define IRQ_STACK_START_SP THREAD_START_SP
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLER__
|
|
|
|
|
|
|
|
#include <linux/percpu.h>
|
2017-07-22 18:48:34 +07:00
|
|
|
#include <linux/sched/task_stack.h>
|
2015-12-04 18:02:26 +07:00
|
|
|
|
2012-03-05 18:49:29 +07:00
|
|
|
#include <asm-generic/irq.h>
|
2015-12-04 18:02:26 +07:00
|
|
|
#include <asm/thread_info.h>
|
2012-03-05 18:49:29 +07:00
|
|
|
|
2014-12-04 13:29:35 +07:00
|
|
|
struct pt_regs;
|
|
|
|
|
2015-12-04 18:02:26 +07:00
|
|
|
DECLARE_PER_CPU(unsigned long [IRQ_STACK_SIZE/sizeof(long)], irq_stack);
|
|
|
|
|
2013-01-14 19:39:31 +07:00
|
|
|
extern void set_handle_irq(void (*handle_irq)(struct pt_regs *));
|
2012-03-05 18:49:29 +07:00
|
|
|
|
2015-11-20 23:25:04 +07:00
|
|
|
static inline int nr_legacy_irqs(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
arm64: unwind: avoid percpu indirection for irq stack
Our IRQ_STACK_PTR() and on_irq_stack() helpers both take a cpu argument,
used to generate a percpu address. In all cases, they are passed
{raw_,}smp_processor_id(), so this parameter is redundant.
Since {raw_,}smp_processor_id() use a percpu variable internally, this
approach means we generate a percpu offset to find the current cpu, then
use this to index an array of percpu offsets, which we then use to find
the current CPU's IRQ stack pointer. Thus, most of the work is
redundant.
Instead, we can consistently use raw_cpu_ptr() to generate the CPU's
irq_stack pointer by simply adding the percpu offset to the irq_stack
address, which is simpler in both respects.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
2017-07-20 20:01:01 +07:00
|
|
|
static inline bool on_irq_stack(unsigned long sp)
|
2015-12-04 18:02:26 +07:00
|
|
|
{
|
arm64: unwind: avoid percpu indirection for irq stack
Our IRQ_STACK_PTR() and on_irq_stack() helpers both take a cpu argument,
used to generate a percpu address. In all cases, they are passed
{raw_,}smp_processor_id(), so this parameter is redundant.
Since {raw_,}smp_processor_id() use a percpu variable internally, this
approach means we generate a percpu offset to find the current cpu, then
use this to index an array of percpu offsets, which we then use to find
the current CPU's IRQ stack pointer. Thus, most of the work is
redundant.
Instead, we can consistently use raw_cpu_ptr() to generate the CPU's
irq_stack pointer by simply adding the percpu offset to the irq_stack
address, which is simpler in both respects.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
2017-07-20 20:01:01 +07:00
|
|
|
unsigned long low = (unsigned long)raw_cpu_ptr(irq_stack);
|
2015-12-04 18:02:26 +07:00
|
|
|
unsigned long high = low + IRQ_STACK_START_SP;
|
|
|
|
|
|
|
|
return (low <= sp && sp <= high);
|
|
|
|
}
|
|
|
|
|
2017-07-22 18:48:34 +07:00
|
|
|
static inline bool on_task_stack(struct task_struct *tsk, unsigned long sp)
|
|
|
|
{
|
|
|
|
unsigned long low = (unsigned long)task_stack_page(tsk);
|
|
|
|
unsigned long high = low + THREAD_SIZE;
|
|
|
|
|
|
|
|
return (low <= sp && sp < high);
|
|
|
|
}
|
|
|
|
|
2015-12-04 18:02:26 +07:00
|
|
|
#endif /* !__ASSEMBLER__ */
|
2012-03-05 18:49:29 +07:00
|
|
|
#endif
|