[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200507161828.683233459@infradead.org>
Date: Thu, 07 May 2020 18:10:21 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: tglx@...utronix.de
Cc: jpoimboe@...hat.com, x86@...nel.org, linux-kernel@...r.kernel.org,
luto@...nel.org, peterz@...radead.org
Subject: [RFC][PATCH 1/3] x86/entry: Collapse the 3 IRQ stack instances into a single macro
Because 1 copy of this magic is plenty.
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
---
--- a/arch/x86/include/asm/irq_stack.h
+++ b/arch/x86/include/asm/irq_stack.h
@@ -12,10 +12,8 @@ static __always_inline bool irqstack_act
return __this_cpu_read(irq_count) != -1;
}
-/*
- * Macro to emit code for running @func on the irq stack.
- */
-#define RUN_ON_IRQSTACK(func) { \
+#define __RUN_ON_IRQSTACK(_asm, ...) \
+do { \
unsigned long tos; \
\
lockdep_assert_irqs_disabled(); \
@@ -30,45 +28,27 @@ static __always_inline bool irqstack_act
" .pushsection .discard.instr_begin \n" \
" .long 1b - . \n" \
" .popsection \n" \
- "call " __ASM_FORM(func) " \n" \
+ _asm " \n" \
"2: \n" \
" .pushsection .discard.instr_end \n" \
" .long 2b - . \n" \
" .popsection \n" \
"popq %%rsp \n" \
: \
- : [ts] "r" (tos) \
+ : [ts] "r" (tos), ##__VA_ARGS__ \
: "memory" \
); \
__this_cpu_sub(irq_count, 1); \
-}
+} while (0)
-#define RUN_ON_IRQSTACK_ARG1(func, arg) { \
- unsigned long tos; \
- \
- tos = ((unsigned long)__this_cpu_read(hardirq_stack_ptr)) - 8; \
- \
- __this_cpu_add(irq_count, 1); \
- asm volatile( \
- "movq %%rsp, (%[ts]) \n" \
- "movq %[ts], %%rsp \n" \
- "1: \n" \
- " .pushsection .discard.instr_begin \n" \
- " .long 1b - . \n" \
- " .popsection \n" \
- "call " __ASM_FORM(func) " \n" \
- "2: \n" \
- " .pushsection .discard.instr_end \n" \
- " .long 2b - . \n" \
- " .popsection \n" \
- "popq %%rsp \n" \
- : \
- : [ts] "r" (tos), \
- "D" (arg) \
- : "memory" \
- ); \
- __this_cpu_sub(irq_count, 1); \
-}
+/*
+ * Macro to emit code for running @func on the irq stack.
+ */
+#define RUN_ON_IRQSTACK(func) \
+ __RUN_ON_IRQSTACK("call" __ASM_FORM(func))
+
+#define RUN_ON_IRQSTACK_ARG1(func, arg) \
+ __RUN_ON_IRQSTACK("call" __ASM_FORM(func), "D" (arg))
#else /* CONFIG_X86_64 */
static __always_inline bool irqstack_active(void) { return false; }
--- a/arch/x86/kernel/irq_64.c
+++ b/arch/x86/kernel/irq_64.c
@@ -74,35 +74,7 @@ int irq_init_percpu_irqstack(unsigned in
static noinstr void handle_irq_on_irqstack(struct irq_desc *desc)
{
- unsigned long tos;
-
- tos = (unsigned long) __this_cpu_read(hardirq_stack_ptr) - 8;
-
- __this_cpu_add(irq_count, 1);
- /*
- * The unwinder requires that the top of the IRQ stack links back
- * to the previous stack and RBP is set up.
- */
- asm volatile(
- "movq %%rsp, (%[ts]) \n"
- "movq %[ts], %%rsp \n"
- "1: \n"
- " .pushsection .discard.instr_begin \n"
- " .long 1b - . \n"
- " .popsection \n"
- CALL_NOSPEC
- "2: \n"
- " .pushsection .discard.instr_end \n"
- " .long 2b - . \n"
- " .popsection \n"
- "popq %%rsp \n"
- :
- : [ts] "r" (tos),
- [thunk_target] "r" (desc->handle_irq),
- "D" (desc)
- : "memory"
- );
- __this_cpu_sub(irq_count, 1);
+ __RUN_ON_IRQSTACK(CALL_NOSPEC, THUNK_TARGET(desc->handle_irq), "D" (desc));
}
void handle_irq(struct irq_desc *desc, struct pt_regs *regs)
Powered by blists - more mailing lists