x86/irq/64: Inline irq stack switching
Subsystems (9)
v2 cover x86/irq/64: Inline irq stack switching
This is the second version of this series. V1 is available here:
https://lore.kernel.org/r/[email protected]
The recent effort to make the ASM entry code slim and unified moved the irq stack switching out of the low level ASM code so that the whole return from interrupt work and state handling can be done in C and the ASM code just handles the true low level details of entry and exit (which is horrible enough already due to the well thought out architeture).
The main goal at this point was to get instrumentation and RCU state under control in a validated way. Inlining the switch mechanism was attempted back then, but that caused more objtool and unwinder trouble than we had already on our plate, so we ended up with a simple, functional but suboptimal implementation. The main issues are:
- The unnecessary indirect call which is expensive thanks to retpoline
- The inability to stay on the irq stack for softirq processing on return from interrupt which requires another stack switch operation.
- The fact that the stack switching code ended up being an easy to find exploit gadget.
This series revisits the problem and reimplements the stack switch mechanics via evil inline assembly. Peter Zijlstra provided the required objtool and unwinder changes already. These are available here:
https://lore.kernel.org/r/[email protected]
and the latest iteration of them is available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git objtool/core
The full series based on Peter's git branch is also available from git:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/entry
All function calls are now direct and fully inlined including the single instance in the softirq code which is invoked from local_bh_enable() in task context.
The extra 100 lines in the diffstat are pretty much the extensive commentry for the whole magic to spare everyone including myself to scratch heads 2 weeks down the road.
The text size impact is in the noise and looking at the actual entry functions there is depending on the compiler variant even a small size decrease.
The patches have been tested with gcc8, gcc10 and clang-13 (fresh from git). The difference between the output of these compilers is minimal. gcc8 being slightly worse due to stupid register selection and random NOPs injected.
Changes vs. V1:
- Use ASM_CALL_CONSTRAINT unconditionally (Josh)
- New approach to handle the inlining without the extra #ifdeffery (Lai)
- Added stable/fixes tag to patch 1 (Boris)
- Style and comment updates (Boris)
- Clarified the cacheline effect in the changelog (Peter)
- Picked up Reviewed-by from Kees where appropriate
Thanks,
tglx
--- arch/Kconfig | 6 arch/parisc/Kconfig | 1 arch/parisc/include/asm/hardirq.h | 4 arch/parisc/kernel/irq.c | 1 arch/powerpc/Kconfig | 1 arch/powerpc/include/asm/irq.h | 2 arch/powerpc/kernel/irq.c | 1 arch/s390/Kconfig | 1 arch/s390/include/asm/hardirq.h | 1 arch/s390/kernel/irq.c | 1 arch/sh/Kconfig | 1 arch/sh/include/asm/irq.h | 1 arch/sh/kernel/irq.c | 1 arch/sparc/Kconfig | 1 arch/sparc/include/asm/irq_64.h | 1 arch/sparc/kernel/irq_64.c | 1 arch/x86/Kconfig | 2 arch/x86/entry/common.c | 19 -- arch/x86/entry/entry_64.S | 41 ----- arch/x86/include/asm/idtentry.h | 11 - arch/x86/include/asm/irq.h | 2 arch/x86/include/asm/irq_stack.h | 279 ++++++++++++++++++++++++----------- arch/x86/include/asm/processor.h | 9 - arch/x86/include/asm/softirq_stack.h | 11 + arch/x86/kernel/apic/apic.c | 31 ++- arch/x86/kernel/cpu/common.c | 4 arch/x86/kernel/dumpstack_64.c | 22 ++ arch/x86/kernel/irq.c | 2 arch/x86/kernel/irq_32.c | 1 arch/x86/kernel/irq_64.c | 12 - arch/x86/kernel/process_64.c | 2 include/asm-generic/Kbuild | 1 include/asm-generic/softirq_stack.h | 14 + include/linux/interrupt.h | 9 - kernel/softirq.c | 2 35 files changed, 303 insertions(+), 196 deletions(-)
PATCH v2 1/13 x86/entry: Fix instrumentation annotation
From: Thomas Gleixner <[email protected]>
Embracing a callout into instrumentation_begin() / instrumentation_begin() does not really make sense. Make the latter instrumentation_end().
--- arch/x86/entry/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/common.c +1 -1
@@ -270,7 +270,7 @@ static void __xen_pv_evtchn_do_upcall(voinstrumentation_begin ();run_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); -instrumentation_begin (); +instrumentation_end ();set_irq_regs (old_regs);
[tip: x86/entry] x86/entry: Fix instrumentation annotation
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 15f720aabe71a5662c4198b22532d95bbeec80ef Gitweb: https://git.kernel.org/tip/15f720aabe71a5662c4198b22532d95bbeec80ef Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:42 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:13 +01:00
x86/entry: Fix instrumentation annotation
Embracing a callout into instrumentation_begin() / instrumentation_begin() does not really make sense. Make the latter instrumentation_end().
--- arch/x86/entry/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/entry/common.c +1 -1
@@ -266,7 +266,7 @@ __visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs)instrumentation_begin ();run_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); -instrumentation_begin (); +instrumentation_end ();set_irq_regs (old_regs);
PATCH v2 2/13 x86/irq: Sanitize irq stack tracking
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
The recursion protection for hard interrupt stacks is an unsigned int per CPU variable initialized to -1 named __irq_count.
The irq stack switching is only done when the variable is -1, which creates worse code than just checking for 0. When the stack switching happens it uses this_cpu_add/sub(1), but there is no reason to do so. It simply can use straight writes. This is a historical leftover from the low level ASM code which used inc and jz to make a decision.
Rename it to hardirq_stack_inuse, make it a bool and use plain stores.
--- arch/x86/include/asm/irq_stack.h | 14 +++++++------- arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/irq_stack.h +7 -7
@@ -9,7 +9,7 @@#ifdef CONFIG_X86_64 static __always_inline bool irqstack_active(void) { -return __this_cpu_read (irq_count) !=-1 ; +return __this_cpu_read (hardirq_stack_inuse); }void asm_call_on_stack (void *sp,void (*func)(void ),void *arg);
@@ -22,9 +22,9 @@ static __always_inline void __run_on_irq {void *tos =__this_cpu_read (hardirq_stack_ptr); -__this_cpu_add (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, true);asm_call_on_stack (tos -8 , func,NULL ); -__this_cpu_sub (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, false); }static __always_inline void
@@ -33,9 +33,9 @@ static __always_inline void {void *tos =__this_cpu_read (hardirq_stack_ptr); -__this_cpu_add (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, true);asm_call_sysvec_on_stack (tos -8 , func, regs); -__this_cpu_sub (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, false); }static __always_inline void
@@ -44,9 +44,9 @@ static __always_inline void {void *tos =__this_cpu_read (hardirq_stack_ptr); -__this_cpu_add (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, true);asm_call_irq_on_stack (tos -8 , func, desc); -__this_cpu_sub (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, false); }#else /* CONFIG_X86_64 */
arch/x86/include/asm/processor.h +1 -1
@@ -454,7 +454,7 @@ static inline unsigned long cpu_kernelmoreturn (unsigned long )per_cpu (fixed_percpu_data.gs_base, cpu); } -DECLARE_PER_CPU(unsigned int, irq_count); +DECLARE_PER_CPU (bool, hardirq_stack_inuse); extern asmlinkage void ignore_sysret(void);/* Save actual FS/GS selectors and bases to current->thread */
arch/x86/kernel/cpu/common.c +1 -1
@@ -1740,7 +1740,7 @@ DEFINE_PER_CPU(struct task_struct *, curEXPORT_PER_CPU_SYMBOL (current_task); DEFINE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); -DEFINE_PER_CPU(unsigned int, irq_count) __visible = -1; +DEFINE_PER_CPU (bool, hardirq_stack_inuse);DEFINE_PER_CPU (int, __preempt_count) =INIT_PREEMPT_COUNT ;EXPORT_PER_CPU_SYMBOL (__preempt_count);
arch/x86/kernel/process_64.c +1 -1
@@ -539,7 +539,7 @@ void compat_start_thread(struct pt_regsint cpu =smp_processor_id ();WARN_ON_ONCE (IS_ENABLED (CONFIG_DEBUG_ENTRY ) && -this_cpu_read (irq_count) !=-1 ); +this_cpu_read (hardirq_stack_inuse));if (!test_thread_flag (TIF_NEED_FPU_LOAD ))switch_fpu_prepare (prev_fpu, cpu);
[tip: x86/entry] x86/irq: Sanitize irq stack tracking
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: e7f89001797148e8dc7060c335df2c56e73a8c7a Gitweb: https://git.kernel.org/tip/e7f89001797148e8dc7060c335df2c56e73a8c7a Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:43 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:13 +01:00
x86/irq: Sanitize irq stack tracking
The recursion protection for hard interrupt stacks is an unsigned int per CPU variable initialized to -1 named __irq_count.
The irq stack switching is only done when the variable is -1, which creates worse code than just checking for 0. When the stack switching happens it uses this_cpu_add/sub(1), but there is no reason to do so. It simply can use straight writes. This is a historical leftover from the low level ASM code which used inc and jz to make a decision.
Rename it to hardirq_stack_inuse, make it a bool and use plain stores.
--- arch/x86/include/asm/irq_stack.h | 14 +++++++------- arch/x86/include/asm/processor.h | 2 +- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/process_64.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/irq_stack.h +7 -7
@@ -9,7 +9,7 @@#ifdef CONFIG_X86_64 static __always_inline bool irqstack_active(void) { -return __this_cpu_read (irq_count) !=-1 ; +return __this_cpu_read (hardirq_stack_inuse); }void asm_call_on_stack (void *sp,void (*func)(void ),void *arg);
@@ -22,9 +22,9 @@ static __always_inline void __run_on_irqstack(void (*func)(void)) {void *tos =__this_cpu_read (hardirq_stack_ptr); -__this_cpu_add (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, true);asm_call_on_stack (tos -8 , func,NULL ); -__this_cpu_sub (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, false); }static __always_inline void
@@ -33,9 +33,9 @@ __run_sysvec_on_irqstack(void (*func)(struct pt_regs *regs), {void *tos =__this_cpu_read (hardirq_stack_ptr); -__this_cpu_add (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, true);asm_call_sysvec_on_stack (tos -8 , func, regs); -__this_cpu_sub (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, false); }static __always_inline void
@@ -44,9 +44,9 @@ __run_irq_on_irqstack(void (*func)(struct irq_desc *desc), {void *tos =__this_cpu_read (hardirq_stack_ptr); -__this_cpu_add (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, true);asm_call_irq_on_stack (tos -8 , func, desc); -__this_cpu_sub (irq_count,1 ); +__this_cpu_write (hardirq_stack_inuse, false); }#else /* CONFIG_X86_64 */
arch/x86/include/asm/processor.h +1 -1
@@ -454,7 +454,7 @@ static inline unsigned long cpu_kernelmode_gs_base(int cpu)return (unsigned long )per_cpu (fixed_percpu_data.gs_base, cpu); } -DECLARE_PER_CPU(unsigned int, irq_count); +DECLARE_PER_CPU (bool, hardirq_stack_inuse); extern asmlinkage void ignore_sysret(void);/* Save actual FS/GS selectors and bases to current->thread */
arch/x86/kernel/cpu/common.c +1 -1
@@ -1740,7 +1740,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =EXPORT_PER_CPU_SYMBOL (current_task); DEFINE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); -DEFINE_PER_CPU(unsigned int, irq_count) __visible = -1; +DEFINE_PER_CPU (bool, hardirq_stack_inuse);DEFINE_PER_CPU (int, __preempt_count) =INIT_PREEMPT_COUNT ;EXPORT_PER_CPU_SYMBOL (__preempt_count);
arch/x86/kernel/process_64.c +1 -1
@@ -539,7 +539,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)int cpu =smp_processor_id ();WARN_ON_ONCE (IS_ENABLED (CONFIG_DEBUG_ENTRY ) && -this_cpu_read (irq_count) !=-1 ); +this_cpu_read (hardirq_stack_inuse));if (!test_thread_flag (TIF_NEED_FPU_LOAD ))switch_fpu_prepare (prev_fpu, cpu);
PATCH v2 3/13 x86/irq/64: Adjust the per CPU irq stack pointer by 8
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
The per CPU hardirq_stack_ptr contains the pointer to the irq stack in the form that it is ready to be assigned to [ER]SP so that the first push ends up on the top entry of the stack.
But the stack switching on 64 bit has the following rules:
1) Store the current stack pointer (RSP) in the top most stack entry to allow the unwinder to link back to the previous stack
2) Set RSP to the top most stack entry
3) Invoke functions on the irq stack
4) Pop RSP from the top most stack entry (stored in #1) so it's back to the original stack.
That requires all stack switching code to decrement the stored pointer by 8 in order to be able to store the current RSP and then set RSP to that location. That's a pointless exercise.
Do the -8 adjustment right when storing the pointer and make the data type a void pointer to avoid confusion vs. the struct irq_stack data type which is on 64bit only used to declare the backing store. Move the definition next to the inuse flag so they likely end up in the same cache line. Sticking them into a struct to enforce it is a seperate change.
---
V2: Reworded changelog so that it's clear that ending up in the cache line
is not guaranteed.
--- arch/x86/include/asm/irq_stack.h | 6 +++--- arch/x86/include/asm/processor.h | 7 +++---- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/dumpstack_64.c | 22 ++++++++++++++++------ arch/x86/kernel/irq_64.c | 6 ++++-- 5 files changed, 27 insertions(+), 16 deletions(-)
arch/x86/include/asm/irq_stack.h +3 -3
@@ -23,7 +23,7 @@ static __always_inline void __run_on_irqvoid *tos =__this_cpu_read (hardirq_stack_ptr);__this_cpu_write (hardirq_stack_inuse, true); -asm_call_on_stack (tos -8 , func,NULL ); +asm_call_on_stack (tos, func,NULL );__this_cpu_write (hardirq_stack_inuse, false); }
@@ -34,7 +34,7 @@ static __always_inline voidvoid *tos =__this_cpu_read (hardirq_stack_ptr);__this_cpu_write (hardirq_stack_inuse, true); -asm_call_sysvec_on_stack (tos -8 , func, regs); +asm_call_sysvec_on_stack (tos, func, regs);__this_cpu_write (hardirq_stack_inuse, false); }
@@ -45,7 +45,7 @@ static __always_inline voidvoid *tos =__this_cpu_read (hardirq_stack_ptr);__this_cpu_write (hardirq_stack_inuse, true); -asm_call_irq_on_stack (tos -8 , func, desc); +asm_call_irq_on_stack (tos, func, desc);__this_cpu_write (hardirq_stack_inuse, false); }
arch/x86/include/asm/processor.h +3 -4
@@ -426,8 +426,6 @@ struct irq_stack {char stack[IRQ_STACK_SIZE ]; }__aligned(IRQ_STACK_SIZE) ; -DECLARE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); -#ifdef CONFIG_X86_32 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);#else
@@ -454,6 +452,7 @@ static inline unsigned long cpu_kernelmoreturn (unsigned long )per_cpu (fixed_percpu_data.gs_base, cpu); } +DECLARE_PER_CPU(void *, hardirq_stack_ptr);DECLARE_PER_CPU (bool, hardirq_stack_inuse); extern asmlinkage void ignore_sysret(void);
@@ -473,9 +472,9 @@ struct stack_canary { }; DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);#endif -/* Per CPU softirq stack pointer */ +DECLARE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); DECLARE_PER_CPU(struct irq_stack *, softirq_stack_ptr); -#endif /* X86_64 */ +#endif /* !X86_64 */ extern unsigned int fpu_kernel_xstate_size;extern unsigned int fpu_user_xstate_size;
arch/x86/kernel/cpu/common.c +1 -1
@@ -1739,7 +1739,7 @@ DEFINE_PER_CPU(struct task_struct *, cur &init_task;EXPORT_PER_CPU_SYMBOL (current_task); -DEFINE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); +DEFINE_PER_CPU(void *, hardirq_stack_ptr);DEFINE_PER_CPU (bool, hardirq_stack_inuse);DEFINE_PER_CPU (int, __preempt_count) =INIT_PREEMPT_COUNT ;
arch/x86/kernel/dumpstack_64.c +16 -6
@@ -128,12 +128,21 @@ static __always_inline bool in_exception static __always_inline bool in_irq_stack(unsigned long *stack, struct stack_info *info) { -unsigned long *end = (unsigned long *)this_cpu_read (hardirq_stack_ptr); -unsigned long *begin = end - (IRQ_STACK_SIZE /sizeof (long )); +unsigned long *end = (unsigned long *)this_cpu_read (hardirq_stack_ptr); +unsigned long *begin;/* -* This is a software stack, so 'end' can be a valid stack pointer. -* It just means the stack is empty. +* @end points directly to the top most stack entry to avoid a -8 +* adjustment in the stack switch hotpath. Adjust it back before +* calculating @begin. +*/ + end++; + begin = end - (IRQ_STACK_SIZE /sizeof (long )); + +/* +* Due to the switching logic RSP can never be == @end because the +* final operation is 'popq %rsp' which means after that RSP points +* to the original stack and not to @end. */ if (stack < begin || stack >= end)return false;
@@ -143,8 +152,9 @@ static __always_inline bool in_irq_stack info->end = end;/* -* The next stack pointer is the first thing pushed by the entry code -* after switching to the irq stack. +* The next stack pointer is stored at the top of the irq stack +* before switching to the irq stack. Actual stack entries are all +* below that. */ info->next_sp = (unsigned long *)*(end -1 );
arch/x86/kernel/irq_64.c +4 -2
@@ -48,7 +48,8 @@ static int map_irq_stack(unsigned int cpif (!va)return -ENOMEM ; -per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE ; +/* Store actual TOS to avoid adjustment in the hotpath */ +per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE -8 ; return 0; }#else
@@ -60,7 +61,8 @@ static int map_irq_stack(unsigned int cp {void *va =per_cpu_ptr (&irq_stack_backing_store, cpu); -per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE ; +/* Store actual TOS to avoid adjustment in the hotpath */ +per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE -8 ;return 0 ; }#endif
RE: [patch V2 03/13] x86/irq/64: Adjust the per CPU irq stack pointer by 8
From: Thomas Gleixner
Quoted 6 lines
Sent: 09 February 2021 23:41
From: Thomas Gleixner <[email protected]>The per CPU
hardirq_stack_ptrcontains the pointer to the irq stack in the form that it is ready to be assigned to [ER]SP so that the first push ends up on the top entry of the stack.
...
Quoted 3 lines
Do the -8 adjustment right when storing the pointer and make the data type a void pointer to avoid confusion vs. the struct
irq_stackdata type which is on 64bit only used to declare the backing store...
It might be better to make it a pointer to an undefined struct. That will stop all accidental assignments - except those that are already 'void *'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
[tip: x86/entry] x86/irq/64: Adjust the per CPU irq stack pointer by 8
In reply to Thomas GleixnerThe following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 951c2a51ae75382d519839e2308394ad43ce4b40 Gitweb: https://git.kernel.org/tip/951c2a51ae75382d519839e2308394ad43ce4b40 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:44 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:14 +01:00
x86/irq/64: Adjust the per CPU irq stack pointer by 8
The per CPU hardirq_stack_ptr contains the pointer to the irq stack in the form that it is ready to be assigned to [ER]SP so that the first push ends up on the top entry of the stack.
But the stack switching on 64 bit has the following rules:
1) Store the current stack pointer (RSP) in the top most stack entry to allow the unwinder to link back to the previous stack
2) Set RSP to the top most stack entry
3) Invoke functions on the irq stack
4) Pop RSP from the top most stack entry (stored in #1) so it's back to the original stack.
That requires all stack switching code to decrement the stored pointer by 8 in order to be able to store the current RSP and then set RSP to that location. That's a pointless exercise.
Do the -8 adjustment right when storing the pointer and make the data type a void pointer to avoid confusion vs. the struct irq_stack data type which is on 64bit only used to declare the backing store. Move the definition next to the inuse flag so they likely end up in the same cache line. Sticking them into a struct to enforce it is a seperate change.
--- arch/x86/include/asm/irq_stack.h | 6 +++--- arch/x86/include/asm/processor.h | 7 +++---- arch/x86/kernel/cpu/common.c | 2 +- arch/x86/kernel/dumpstack_64.c | 22 ++++++++++++++++------ arch/x86/kernel/irq_64.c | 6 ++++-- 5 files changed, 27 insertions(+), 16 deletions(-)
arch/x86/include/asm/irq_stack.h +3 -3
@@ -23,7 +23,7 @@ static __always_inline void __run_on_irqstack(void (*func)(void))void *tos =__this_cpu_read (hardirq_stack_ptr);__this_cpu_write (hardirq_stack_inuse, true); -asm_call_on_stack (tos -8 , func,NULL ); +asm_call_on_stack (tos, func,NULL );__this_cpu_write (hardirq_stack_inuse, false); }
@@ -34,7 +34,7 @@ __run_sysvec_on_irqstack(void (*func)(struct pt_regs *regs),void *tos =__this_cpu_read (hardirq_stack_ptr);__this_cpu_write (hardirq_stack_inuse, true); -asm_call_sysvec_on_stack (tos -8 , func, regs); +asm_call_sysvec_on_stack (tos, func, regs);__this_cpu_write (hardirq_stack_inuse, false); }
@@ -45,7 +45,7 @@ __run_irq_on_irqstack(void (*func)(struct irq_desc *desc),void *tos =__this_cpu_read (hardirq_stack_ptr);__this_cpu_write (hardirq_stack_inuse, true); -asm_call_irq_on_stack (tos -8 , func, desc); +asm_call_irq_on_stack (tos, func, desc);__this_cpu_write (hardirq_stack_inuse, false); }
arch/x86/include/asm/processor.h +3 -4
@@ -426,8 +426,6 @@ struct irq_stack {char stack[IRQ_STACK_SIZE ]; }__aligned(IRQ_STACK_SIZE) ; -DECLARE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); -#ifdef CONFIG_X86_32 DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack);#else
@@ -454,6 +452,7 @@ static inline unsigned long cpu_kernelmode_gs_base(int cpu)return (unsigned long )per_cpu (fixed_percpu_data.gs_base, cpu); } +DECLARE_PER_CPU(void *, hardirq_stack_ptr);DECLARE_PER_CPU (bool, hardirq_stack_inuse); extern asmlinkage void ignore_sysret(void);
@@ -473,9 +472,9 @@ struct stack_canary { }; DECLARE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);#endif -/* Per CPU softirq stack pointer */ +DECLARE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); DECLARE_PER_CPU(struct irq_stack *, softirq_stack_ptr); -#endif /* X86_64 */ +#endif /* !X86_64 */ extern unsigned int fpu_kernel_xstate_size;extern unsigned int fpu_user_xstate_size;
arch/x86/kernel/cpu/common.c +1 -1
@@ -1739,7 +1739,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned = &init_task;EXPORT_PER_CPU_SYMBOL (current_task); -DEFINE_PER_CPU(struct irq_stack *, hardirq_stack_ptr); +DEFINE_PER_CPU(void *, hardirq_stack_ptr);DEFINE_PER_CPU (bool, hardirq_stack_inuse);DEFINE_PER_CPU (int, __preempt_count) =INIT_PREEMPT_COUNT ;
arch/x86/kernel/dumpstack_64.c +16 -6
@@ -128,12 +128,21 @@ static __always_inline bool in_exception_stack(unsigned long *stack, struct stac static __always_inline bool in_irq_stack(unsigned long *stack, struct stack_info *info) { -unsigned long *end = (unsigned long *)this_cpu_read (hardirq_stack_ptr); -unsigned long *begin = end - (IRQ_STACK_SIZE /sizeof (long )); +unsigned long *end = (unsigned long *)this_cpu_read (hardirq_stack_ptr); +unsigned long *begin;/* -* This is a software stack, so 'end' can be a valid stack pointer. -* It just means the stack is empty. +* @end points directly to the top most stack entry to avoid a -8 +* adjustment in the stack switch hotpath. Adjust it back before +* calculating @begin. +*/ + end++; + begin = end - (IRQ_STACK_SIZE /sizeof (long )); + +/* +* Due to the switching logic RSP can never be == @end because the +* final operation is 'popq %rsp' which means after that RSP points +* to the original stack and not to @end. */ if (stack < begin || stack >= end)return false;
@@ -143,8 +152,9 @@ static __always_inline bool in_irq_stack(unsigned long *stack, struct stack_info info->end = end;/* -* The next stack pointer is the first thing pushed by the entry code -* after switching to the irq stack. +* The next stack pointer is stored at the top of the irq stack +* before switching to the irq stack. Actual stack entries are all +* below that. */ info->next_sp = (unsigned long *)*(end -1 );
arch/x86/kernel/irq_64.c +4 -2
@@ -48,7 +48,8 @@ static int map_irq_stack(unsigned int cpu)if (!va)return -ENOMEM ; -per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE ; +/* Store actual TOS to avoid adjustment in the hotpath */ +per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE -8 ; return 0; }#else
@@ -60,7 +61,8 @@ static int map_irq_stack(unsigned int cpu) {void *va =per_cpu_ptr (&irq_stack_backing_store, cpu); -per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE ; +/* Store actual TOS to avoid adjustment in the hotpath */ +per_cpu (hardirq_stack_ptr, cpu) = va +IRQ_STACK_SIZE -8 ;return 0 ; }#endif
PATCH v2 4/13 x86/apic: Split out spurious handling code
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
sysvec_spurious_apic_interrupt() calls into the handling body of __spurious_interrupt() which is not obvious as that function is declared inside the DEFINE_IDTENTRY_IRQ(spurious_interrupt) macro.
As __spurious_interrupt() is currently always inlined this ends up with two copies of the same code for no reason.
Split the handling function out and invoke it from both entry points.
--- arch/x86/kernel/apic/apic.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
arch/x86/kernel/apic/apic.c +19 -12
@@ -2137,18 +2137,11 @@ void __init register_lapic_address(unsig* Local APIC interrupts */ -/** -* spurious_interrupt - Catch all for interrupts raised on unused vectors -* @regs: Pointer to pt_regs on stack -* @vector: The vector number -* -* This is invoked from ASM entry code to catch all interrupts which -* trigger on an entry which is routed to the common_spurious idtentry -* point. -* -* Also called from sysvec_spurious_apic_interrupt(). +/* +* Common handling code for spurious_interrupt and spurious_vector entry +* points below. No point in allowing the compiler to inline it twice. */ -DEFINE_IDTENTRY_IRQ (spurious_interrupt) +static noinline void handle_spurious_interrupt(u8 vector) {u32 v;
@@ -2183,9 +2176,23 @@ DEFINE_IDTENTRY_IRQ(spurious_interrupt)trace_spurious_apic_exit (vector); } +/** +* spurious_interrupt - Catch all for interrupts raised on unused vectors +* @regs: Pointer to pt_regs on stack +* @vector: The vector number +* +* This is invoked from ASM entry code to catch all interrupts which +* trigger on an entry which is routed to the common_spurious idtentry +* point. +*/ +DEFINE_IDTENTRY_IRQ (spurious_interrupt) +{ +handle_spurious_interrupt (vector); +} +DEFINE_IDTENTRY_SYSVEC (sysvec_spurious_apic_interrupt) { -__spurious_interrupt (regs,SPURIOUS_APIC_VECTOR ); +handle_spurious_interrupt (SPURIOUS_APIC_VECTOR ); }/*
[tip: x86/entry] x86/apic: Split out spurious handling code
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 3c5e0267ec3e6ed7d3f1793273cbf0beb4f86a74 Gitweb: https://git.kernel.org/tip/3c5e0267ec3e6ed7d3f1793273cbf0beb4f86a74 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:45 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:14 +01:00
x86/apic: Split out spurious handling code
sysvec_spurious_apic_interrupt() calls into the handling body of __spurious_interrupt() which is not obvious as that function is declared inside the DEFINE_IDTENTRY_IRQ(spurious_interrupt) macro.
As __spurious_interrupt() is currently always inlined this ends up with two copies of the same code for no reason.
Split the handling function out and invoke it from both entry points.
--- arch/x86/kernel/apic/apic.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
arch/x86/kernel/apic/apic.c +19 -12
@@ -2133,18 +2133,11 @@ void __init register_lapic_address(unsigned long address)* Local APIC interrupts */ -/** -* spurious_interrupt - Catch all for interrupts raised on unused vectors -* @regs: Pointer to pt_regs on stack -* @vector: The vector number -* -* This is invoked from ASM entry code to catch all interrupts which -* trigger on an entry which is routed to the common_spurious idtentry -* point. -* -* Also called from sysvec_spurious_apic_interrupt(). +/* +* Common handling code for spurious_interrupt and spurious_vector entry +* points below. No point in allowing the compiler to inline it twice. */ -DEFINE_IDTENTRY_IRQ (spurious_interrupt) +static noinline void handle_spurious_interrupt(u8 vector) {u32 v;
@@ -2179,9 +2172,23 @@ out:trace_spurious_apic_exit (vector); } +/** +* spurious_interrupt - Catch all for interrupts raised on unused vectors +* @regs: Pointer to pt_regs on stack +* @vector: The vector number +* +* This is invoked from ASM entry code to catch all interrupts which +* trigger on an entry which is routed to the common_spurious idtentry +* point. +*/ +DEFINE_IDTENTRY_IRQ (spurious_interrupt) +{ +handle_spurious_interrupt (vector); +} +DEFINE_IDTENTRY_SYSVEC (sysvec_spurious_apic_interrupt) { -__spurious_interrupt (regs,SPURIOUS_APIC_VECTOR ); +handle_spurious_interrupt (SPURIOUS_APIC_VECTOR ); }/*
PATCH v2 5/13 x86/irq: Provide macro for inlining irq stack switching
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
The effort to make the ASM entry code slim and unified moved the irq stack switching out of the low level ASM code so that the whole return from interrupt work and state handling can be done in C and the ASM code just handles the low level details of entry and exit.
This ended up being a suboptimal implementation for various reasons (including tooling). The main pain points are:
- The indirect call which is expensive thanks to retpoline
- The inability to stay on the irq stack for softirq processing on return from interrupt
- The fact that the stack switching code ends up being an easy to target exploit gadget.
Prepare for inlining the stack switching logic into the C entry points by providing a ASM macro which contains the guts of the switching mechanism:
1) Store RSP at the top of the irq stack
2) Switch RSP to the irq stack
3) Invoke code
4) Pop the original RSP back
Document the unholy asm() logic while at it to reduce the amount of head scratching required a half year from now.
---
V2: Cosmetic changes - Borislav
Have ASM_CALL_CONSTRAINT unconditional - Josh
--- arch/x86/include/asm/irq_stack.h | 98 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+)
arch/x86/include/asm/irq_stack.h +98 -0
@@ -7,6 +7,104 @@#include <asm/processor.h> #ifdef CONFIG_X86_64 + +/* +* Macro to inline switching to an interrupt stack and invoking function +* calls from there. The following rules apply: +* +* - Ordering: +* +* 1. Write the stack pointer into the top most place of the irq +* stack. This ensures that the various unwinders can link back to the +* original stack. +* +* 2. Switch the stack pointer to the top of the irq stack. +* +* 3. Invoke whatever needs to be done (@asm_call argument) +* +* 4. Pop the original stack pointer from the top of the irq stack +* which brings it back to the original stack where it left off. +* +* - Function invocation: +* +* To allow flexible usage of the macro, the actual function code including +* the store of the arguments in the call ABI registers is handed in via +* the @asm_call argument. +* +* - Local variables: +* +* @tos: +* The @tos variable holds a pointer to the top of the irq stack and +* _must_ be allocated in a non-callee saved register as this is a +* restriction coming from objtool. +* +* Note, that (tos) is both in input and output constraints to ensure +* that the compiler does not assume that R11 is left untouched in +* case this macro is used in some place where the per cpu interrupt +* stack pointer is used again afterwards +* +* - Function arguments: +* The function argument(s), if any, have to be defined in register +* variables at the place where this is invoked. Storing the +* argument(s) in the proper register(s) is part of the @asm_call +* +* - Constraints: +* +* The constraints have to be done very carefully because the compiler +* does not know about the assembly call. +* +* output: +* As documented already above the @tos variable is required to be in +* the output constraints to make the compiler aware that R11 cannot be +* reused after the asm() statement. +* +* For builds with CONFIG_UNWIND_FRAME_POINTER ASM_CALL_CONSTRAINT is +* required as well as this prevents certain creative GCC variants from +* misplacing the ASM code. +* +* input: +* - func: +* Immediate, which tells the compiler that the function is referenced. +* +* - tos: +* Register. The actual register is defined by the variable declaration. +* +* - function arguments: +* The constraints are handed in via the 'argconstr' argument list. They +* describe the register arguments which are used in @asm_call. +* +* clobbers: +* Function calls can clobber anything except the callee-saved +* registers. Tell the compiler. +*/ +#define call_on_irqstack(func, asm_call, argconstr...) \ +{ \ + register void *tos asm("r11"); \ + \ + tos = ((void *)__this_cpu_read(hardirq_stack_ptr)); \ + \ + asm_inline volatile( \ + "movq %%rsp, (%[tos]) \n" \ + "movq %[tos], %%rsp \n" \ + \ + asm_call \ + \ + "popq %%rsp \n" \ + \ + : "+r" (tos), ASM_CALL_CONSTRAINT \ + : [__func] "i" (func), [tos] "r" (tos) argconstr \ + : "cc", "rax", "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", \ + "memory" \ + ); \ +} + +/* Macros to assert type correctness for run_*_on_irqstack macros */ +#define assert_function_type (func, proto) \ + static_assert(__builtin_types_compatible_p(typeof(&func), proto)) + +#define assert_arg_type (arg, proto) \ + static_assert(__builtin_types_compatible_p(typeof(arg), proto)) + static __always_inline bool irqstack_active(void) {return __this_cpu_read (hardirq_stack_inuse);
[tip: x86/entry] x86/irq: Provide macro for inlining irq stack switching
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: a0cfc74d0b00c5201e1c09e28b2dc01c8088f809 Gitweb: https://git.kernel.org/tip/a0cfc74d0b00c5201e1c09e28b2dc01c8088f809 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:46 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:14 +01:00
x86/irq: Provide macro for inlining irq stack switching
The effort to make the ASM entry code slim and unified moved the irq stack switching out of the low level ASM code so that the whole return from interrupt work and state handling can be done in C and the ASM code just handles the low level details of entry and exit.
This ended up being a suboptimal implementation for various reasons (including tooling). The main pain points are:
- The indirect call which is expensive thanks to retpoline
- The inability to stay on the irq stack for softirq processing on return from interrupt
- The fact that the stack switching code ends up being an easy to target exploit gadget.
Prepare for inlining the stack switching logic into the C entry points by providing a ASM macro which contains the guts of the switching mechanism:
1) Store RSP at the top of the irq stack
2) Switch RSP to the irq stack
3) Invoke code
4) Pop the original RSP back
Document the unholy asm() logic while at it to reduce the amount of head scratching required a half year from now.
--- arch/x86/include/asm/irq_stack.h | 98 +++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+)
arch/x86/include/asm/irq_stack.h +98 -0
@@ -7,6 +7,104 @@#include <asm/processor.h> #ifdef CONFIG_X86_64 + +/* +* Macro to inline switching to an interrupt stack and invoking function +* calls from there. The following rules apply: +* +* - Ordering: +* +* 1. Write the stack pointer into the top most place of the irq +* stack. This ensures that the various unwinders can link back to the +* original stack. +* +* 2. Switch the stack pointer to the top of the irq stack. +* +* 3. Invoke whatever needs to be done (@asm_call argument) +* +* 4. Pop the original stack pointer from the top of the irq stack +* which brings it back to the original stack where it left off. +* +* - Function invocation: +* +* To allow flexible usage of the macro, the actual function code including +* the store of the arguments in the call ABI registers is handed in via +* the @asm_call argument. +* +* - Local variables: +* +* @tos: +* The @tos variable holds a pointer to the top of the irq stack and +* _must_ be allocated in a non-callee saved register as this is a +* restriction coming from objtool. +* +* Note, that (tos) is both in input and output constraints to ensure +* that the compiler does not assume that R11 is left untouched in +* case this macro is used in some place where the per cpu interrupt +* stack pointer is used again afterwards +* +* - Function arguments: +* The function argument(s), if any, have to be defined in register +* variables at the place where this is invoked. Storing the +* argument(s) in the proper register(s) is part of the @asm_call +* +* - Constraints: +* +* The constraints have to be done very carefully because the compiler +* does not know about the assembly call. +* +* output: +* As documented already above the @tos variable is required to be in +* the output constraints to make the compiler aware that R11 cannot be +* reused after the asm() statement. +* +* For builds with CONFIG_UNWIND_FRAME_POINTER ASM_CALL_CONSTRAINT is +* required as well as this prevents certain creative GCC variants from +* misplacing the ASM code. +* +* input: +* - func: +* Immediate, which tells the compiler that the function is referenced. +* +* - tos: +* Register. The actual register is defined by the variable declaration. +* +* - function arguments: +* The constraints are handed in via the 'argconstr' argument list. They +* describe the register arguments which are used in @asm_call. +* +* clobbers: +* Function calls can clobber anything except the callee-saved +* registers. Tell the compiler. +*/ +#define call_on_irqstack(func, asm_call, argconstr...) \ +{ \ + register void *tos asm("r11"); \ + \ + tos = ((void *)__this_cpu_read(hardirq_stack_ptr)); \ + \ + asm_inline volatile( \ + "movq %%rsp, (%[tos]) \n" \ + "movq %[tos], %%rsp \n" \ + \ + asm_call \ + \ + "popq %%rsp \n" \ + \ + : "+r" (tos), ASM_CALL_CONSTRAINT \ + : [__func] "i" (func), [tos] "r" (tos) argconstr \ + : "cc", "rax", "rcx", "rdx", "rsi", "rdi", "r8", "r9", "r10", \ + "memory" \ + ); \ +} + +/* Macros to assert type correctness for run_*_on_irqstack macros */ +#define assert_function_type (func, proto) \ + static_assert(__builtin_types_compatible_p(typeof(&func), proto)) + +#define assert_arg_type (arg, proto) \ + static_assert(__builtin_types_compatible_p(typeof(arg), proto)) + static __always_inline bool irqstack_active(void) {return __this_cpu_read (hardirq_stack_inuse);
PATCH v2 6/13 x86/entry: Convert system vectors to irq stack macro
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
To inline the stack switching and to prepare for enabling CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK provide a macro template for system vectors and device interrupts and convert the system vectors over to it.
---
V2: Adopt to underscore removal
--- arch/x86/entry/entry_64.S | 1 arch/x86/include/asm/idtentry.h | 2 arch/x86/include/asm/irq_stack.h | 93 +++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 30 deletions(-)
arch/x86/entry/entry_64.S +0 -1
@@ -762,7 +762,6 @@ SYM_CODE_END(.Lbad_gs) * rdx: Function argument (can be NULL if none) */ SYM_FUNC_START(asm_call_on_stack) -SYM_INNER_LABEL(asm_call_sysvec_on_stack, SYM_L_GLOBAL) SYM_INNER_LABEL(asm_call_irq_on_stack, SYM_L_GLOBAL) /* * Save the frame pointer unconditionally. This allows the ORC
arch/x86/include/asm/idtentry.h +0 -2
@@ -237,10 +237,8 @@ static void __##func(struct pt_regs *regirqentry_state_t state =irqentry_enter (regs); \ \instrumentation_begin (); \ -irq_enter_rcu (); \kvm_set_cpu_l1tf_flush_l1d (); \ run_sysvec_on_irqstack_cond(__##func, regs); \ - irq_exit_rcu(); \instrumentation_end (); \irqentry_exit (regs, state); \ } \
arch/x86/include/asm/irq_stack.h +66 -27
125 lines not on this page · raw message
[tip: x86/entry] x86/entry: Convert system vectors to irq stack macro
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 569dd8b4eb7ef666b467c41b8e8e4f2820d07f67 Gitweb: https://git.kernel.org/tip/569dd8b4eb7ef666b467c41b8e8e4f2820d07f67 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:47 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:15 +01:00
x86/entry: Convert system vectors to irq stack macro
To inline the stack switching and to prepare for enabling CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK provide a macro template for system vectors and device interrupts and convert the system vectors over to it.
--- arch/x86/entry/entry_64.S | 1 +- arch/x86/include/asm/idtentry.h | 2 +- arch/x86/include/asm/irq_stack.h | 93 ++++++++++++++++++++++--------- 3 files changed, 66 insertions(+), 30 deletions(-)
arch/x86/entry/entry_64.S +0 -1
@@ -762,7 +762,6 @@ SYM_CODE_END(.Lbad_gs) * rdx: Function argument (can be NULL if none) */ SYM_FUNC_START(asm_call_on_stack) -SYM_INNER_LABEL(asm_call_sysvec_on_stack, SYM_L_GLOBAL) SYM_INNER_LABEL(asm_call_irq_on_stack, SYM_L_GLOBAL) /* * Save the frame pointer unconditionally. This allows the ORC
arch/x86/include/asm/idtentry.h +0 -2
@@ -237,10 +237,8 @@ __visible noinstr void func(struct pt_regs *regs) \irqentry_state_t state =irqentry_enter (regs); \ \instrumentation_begin (); \ -irq_enter_rcu (); \kvm_set_cpu_l1tf_flush_l1d (); \ run_sysvec_on_irqstack_cond(__##func, regs); \ - irq_exit_rcu(); \instrumentation_end (); \irqentry_exit (regs, state); \ } \
arch/x86/include/asm/irq_stack.h +66 -27
125 lines not on this page · raw message
PATCH v2 7/13 x86/entry: Convert device interrupts to inline stack switching
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Convert device interrupts to inline stack switching by replacing the existing macro implementation with the new inline version. Tweak the function signature of the actual handler function to have the vector argument as u32. That allows the inline macro to avoid extra intermediates and lets the compiler be smarter about the whole thing.
--- arch/x86/entry/entry_64.S | 1 arch/x86/include/asm/idtentry.h | 9 ++---- arch/x86/include/asm/irq_stack.h | 58 ++++++++++++++++++++------------------- arch/x86/kernel/irq.c | 2 - 4 files changed, 36 insertions(+), 34 deletions(-)
arch/x86/entry/entry_64.S +0 -1
@@ -762,7 +762,6 @@ SYM_CODE_END(.Lbad_gs) * rdx: Function argument (can be NULL if none) */ SYM_FUNC_START(asm_call_on_stack) -SYM_INNER_LABEL(asm_call_irq_on_stack, SYM_L_GLOBAL) /* * Save the frame pointer unconditionally. This allows the ORC * unwinder to handle the stack switch.
arch/x86/include/asm/idtentry.h +4 -5
@@ -187,23 +187,22 @@ static __always_inline void __##func(str* has to be done in the function body if necessary. */ #define DEFINE_IDTENTRY_IRQ (func) \ -static __always_inline void __##func(struct pt_regs *regs, u8 vector); \ +static void __##func(struct pt_regs *regs, u32 vector); \ \ __visible noinstr void func(struct pt_regs *regs, \ unsigned long error_code) \ { \ irqentry_state_t state = irqentry_enter(regs); \ + u32 vector = (u32)(u8)error_code; \ \ instrumentation_begin(); \ - irq_enter_rcu(); \ kvm_set_cpu_l1tf_flush_l1d(); \ - __##func (regs, (u8)error_code); \ - irq_exit_rcu(); \ + run_irq_on_irqstack_cond(__##func, regs, vector); \ instrumentation_end(); \ irqentry_exit(regs, state); \ } \ \ -static __always_inline void __##func(struct pt_regs *regs, u8 vector) +static noinline void __##func(struct pt_regs *regs, u32 vector)/** * DECLARE_IDTENTRY_SYSVEC - Declare functions for system vector entry points
arch/x86/include/asm/irq_stack.h +31 -27
88 lines not on this page · raw message
arch/x86/kernel/irq.c +1 -1
@@ -227,7 +227,7 @@ static __always_inline void handle_irq(s struct pt_regs *regs) {if (IS_ENABLED (CONFIG_X86_64 )) -run_irq_on_irqstack_cond (desc->handle_irq, desc, regs); +generic_handle_irq_desc (desc);else __handle_irq (desc, regs); }
[tip: x86/entry] x86/entry: Convert device interrupts to inline stack switching
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 5b51e1db9bdc312d53087a0c97d54ea150111c0d Gitweb: https://git.kernel.org/tip/5b51e1db9bdc312d53087a0c97d54ea150111c0d Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:48 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:15 +01:00
x86/entry: Convert device interrupts to inline stack switching
Convert device interrupts to inline stack switching by replacing the existing macro implementation with the new inline version. Tweak the function signature of the actual handler function to have the vector argument as u32. That allows the inline macro to avoid extra intermediates and lets the compiler be smarter about the whole thing.
--- arch/x86/entry/entry_64.S | 1 +- arch/x86/include/asm/idtentry.h | 9 ++--- arch/x86/include/asm/irq_stack.h | 58 ++++++++++++++++--------------- arch/x86/kernel/irq.c | 2 +- 4 files changed, 36 insertions(+), 34 deletions(-)
arch/x86/entry/entry_64.S +0 -1
@@ -762,7 +762,6 @@ SYM_CODE_END(.Lbad_gs) * rdx: Function argument (can be NULL if none) */ SYM_FUNC_START(asm_call_on_stack) -SYM_INNER_LABEL(asm_call_irq_on_stack, SYM_L_GLOBAL) /* * Save the frame pointer unconditionally. This allows the ORC * unwinder to handle the stack switch.
arch/x86/include/asm/idtentry.h +4 -5
@@ -187,23 +187,22 @@ __visible noinstr void func(struct pt_regs *regs, unsigned long error_code)* has to be done in the function body if necessary. */ #define DEFINE_IDTENTRY_IRQ (func) \ -static __always_inline void __##func(struct pt_regs *regs, u8 vector); \ +static void __##func(struct pt_regs *regs, u32 vector); \ \ __visible noinstr void func(struct pt_regs *regs, \ unsigned long error_code) \ { \ irqentry_state_t state = irqentry_enter(regs); \ + u32 vector = (u32)(u8)error_code; \ \ instrumentation_begin(); \ - irq_enter_rcu(); \ kvm_set_cpu_l1tf_flush_l1d(); \ - __##func (regs, (u8)error_code); \ - irq_exit_rcu(); \ + run_irq_on_irqstack_cond(__##func, regs, vector); \ instrumentation_end(); \ irqentry_exit(regs, state); \ } \ \ -static __always_inline void __##func(struct pt_regs *regs, u8 vector) +static noinline void __##func(struct pt_regs *regs, u32 vector)/** * DECLARE_IDTENTRY_SYSVEC - Declare functions for system vector entry points
arch/x86/include/asm/irq_stack.h +31 -27
88 lines not on this page · raw message
arch/x86/kernel/irq.c +1 -1
@@ -227,7 +227,7 @@ static __always_inline void handle_irq(struct irq_desc *desc, struct pt_regs *regs) {if (IS_ENABLED (CONFIG_X86_64 )) -run_irq_on_irqstack_cond (desc->handle_irq, desc, regs); +generic_handle_irq_desc (desc);else __handle_irq (desc, regs); }
PATCH v2 8/13 x86/entry: Use run_sysvec_on_irqstack_cond() for XEN upcall
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
To avoid yet another macro implementation reuse the existing run_sysvec_on_irqstack_cond() and move the set_irq_regs() handling into the called function. Makes the code even simpler.
--- arch/x86/entry/common.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
arch/x86/entry/common.c +6 -13
@@ -249,30 +249,23 @@ static __always_inline bool get_and_clea static __always_inline void restore_inhcall(bool inhcall) { }#endif -static void __xen_pv_evtchn_do_upcall (void ) +static void __xen_pv_evtchn_do_upcall (struct pt_regs *regs) { -irq_enter_rcu (); +struct pt_regs *old_regs =set_irq_regs (regs); +inc_irq_stat (irq_hv_callback_count);xen_hvm_evtchn_do_upcall (); -irq_exit_rcu (); +set_irq_regs (old_regs); } __visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs) { -struct pt_regs *old_regs; +irqentry_state_t state =irqentry_enter (regs);bool inhcall; -irqentry_state_t state; - - state =irqentry_enter (regs); - old_regs =set_irq_regs (regs); -instrumentation_begin (); -run_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); -instrumentation_end (); - -set_irq_regs (old_regs); +run_sysvec_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); inhcall =get_and_clear_inhcall ();if (inhcall && !WARN_ON_ONCE (state.exit_rcu)) {
[tip: x86/entry] x86/entry: Use run_sysvec_on_irqstack_cond() for XEN upcall
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 359f01d1816fc1ea0161e6c30722bef1ed6b8abb Gitweb: https://git.kernel.org/tip/359f01d1816fc1ea0161e6c30722bef1ed6b8abb Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:49 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:15 +01:00
x86/entry: Use run_sysvec_on_irqstack_cond() for XEN upcall
To avoid yet another macro implementation reuse the existing run_sysvec_on_irqstack_cond() and move the set_irq_regs() handling into the called function. Makes the code even simpler.
--- arch/x86/entry/common.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
arch/x86/entry/common.c +6 -13
@@ -245,30 +245,23 @@ static __always_inline bool get_and_clear_inhcall(void) { return false; } static __always_inline void restore_inhcall(bool inhcall) { }#endif -static void __xen_pv_evtchn_do_upcall (void ) +static void __xen_pv_evtchn_do_upcall (struct pt_regs *regs) { -irq_enter_rcu (); +struct pt_regs *old_regs =set_irq_regs (regs); +inc_irq_stat (irq_hv_callback_count);xen_hvm_evtchn_do_upcall (); -irq_exit_rcu (); +set_irq_regs (old_regs); } __visible noinstr void xen_pv_evtchn_do_upcall(struct pt_regs *regs) { -struct pt_regs *old_regs; +irqentry_state_t state =irqentry_enter (regs);bool inhcall; -irqentry_state_t state; - state =irqentry_enter (regs); - old_regs =set_irq_regs (regs); - -instrumentation_begin (); -run_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); -instrumentation_end (); - -set_irq_regs (old_regs); +run_sysvec_on_irqstack_cond (__xen_pv_evtchn_do_upcall, regs); inhcall =get_and_clear_inhcall ();if (inhcall && !WARN_ON_ONCE (state.exit_rcu)) {
PATCH v2 9/13 x86/softirq: Remove indirection in do_softirq_own_stack()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Use the new inline stack switching and remove the old ASM indirect call implementation.
--- arch/x86/entry/entry_64.S | 39 ----------------------------- arch/x86/include/asm/irq_stack.h | 52 ++++++++++++--------------------------- arch/x86/kernel/irq_64.c | 2 - 3 files changed, 17 insertions(+), 76 deletions(-)
arch/x86/entry/entry_64.S +0 -39
@@ -756,45 +756,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) SYM_CODE_END(.Lbad_gs) .previous -/* - * rdi: New stack pointer points to the top word of the stack - * rsi: Function pointer - * rdx: Function argument (can be NULL if none) - */ -SYM_FUNC_START(asm_call_on_stack) - /* - * Save the frame pointer unconditionally. This allows the ORC - * unwinder to handle the stack switch. - */ - pushq %rbp - mov %rsp, %rbp - - /* - * The unwinder relies on the word at the top of the new stack - * page linking back to the previous RSP. - */ - mov %rsp, (%rdi) - mov %rdi, %rsp - /* Move the argument to the right place */ - mov %rdx, %rdi - -1: - .pushsection .discard.instr_begin - .long 1b - . - .popsection - - CALL_NOSPEC rsi - -2: - .pushsection .discard.instr_end - .long 2b - . - .popsection - - /* Restore the previous stack pointer from RBP. */ - leaveq - ret -SYM_FUNC_END(asm_call_on_stack) - #ifdef CONFIG_XEN_PV /* * A note on the "critical region" in our callback handler.
arch/x86/include/asm/irq_stack.h +16 -36
65 lines not on this page · raw message
arch/x86/kernel/irq_64.c +1 -1
@@ -76,5 +76,5 @@ int irq_init_percpu_irqstack(unsigned invoid do_softirq_own_stack (void ) { -run_on_irqstack_cond (__do_softirq,NULL ); +run_softirq_on_irqstack_cond (); }
[tip: x86/entry] x86/softirq: Remove indirection in do_softirq_own_stack()
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 52d743f3b71265e14560a38f4c835d07b9c6fc4c Gitweb: https://git.kernel.org/tip/52d743f3b71265e14560a38f4c835d07b9c6fc4c Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:50 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:15 +01:00
x86/softirq: Remove indirection in do_softirq_own_stack()
Use the new inline stack switching and remove the old ASM indirect call implementation.
--- arch/x86/entry/entry_64.S | 39 +----------------------- arch/x86/include/asm/irq_stack.h | 52 +++++++++---------------------- arch/x86/kernel/irq_64.c | 2 +- 3 files changed, 17 insertions(+), 76 deletions(-)
arch/x86/entry/entry_64.S +0 -39
@@ -756,45 +756,6 @@ SYM_CODE_START_LOCAL_NOALIGN(.Lbad_gs) SYM_CODE_END(.Lbad_gs) .previous -/* - * rdi: New stack pointer points to the top word of the stack - * rsi: Function pointer - * rdx: Function argument (can be NULL if none) - */ -SYM_FUNC_START(asm_call_on_stack) - /* - * Save the frame pointer unconditionally. This allows the ORC - * unwinder to handle the stack switch. - */ - pushq %rbp - mov %rsp, %rbp - - /* - * The unwinder relies on the word at the top of the new stack - * page linking back to the previous RSP. - */ - mov %rsp, (%rdi) - mov %rdi, %rsp - /* Move the argument to the right place */ - mov %rdx, %rdi - -1: - .pushsection .discard.instr_begin - .long 1b - . - .popsection - - CALL_NOSPEC rsi - -2: - .pushsection .discard.instr_end - .long 2b - . - .popsection - - /* Restore the previous stack pointer from RBP. */ - leaveq - ret -SYM_FUNC_END(asm_call_on_stack) - #ifdef CONFIG_XEN_PV /* * A note on the "critical region" in our callback handler.
arch/x86/include/asm/irq_stack.h +16 -36
65 lines not on this page · raw message
arch/x86/kernel/irq_64.c +1 -1
@@ -76,5 +76,5 @@ int irq_init_percpu_irqstack(unsigned int cpu)void do_softirq_own_stack (void ) { -run_on_irqstack_cond (__do_softirq,NULL ); +run_softirq_on_irqstack_cond (); }
PATCH v2 10/13 x86: Select CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Now that all invocations of irq_exit_rcu() happen on the irq stack, turn on CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK which causes the core code to invoke __do_softirq() directly without going through do_softirq_own_stack().
That means do_softirq_own_stack() is only invoked from task context which means it can't be on the irq stack. Remove the conditional from run_softirq_on_irqstack_cond() and rename the function accordingly.
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/irq_stack.h | 19 ++++++++----------- arch/x86/kernel/irq_64.c | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-)
arch/x86/Kconfig +1 -0
@@ -187,6 +187,7 @@ config X86 select HAVE_HW_BREAKPOINT select HAVE_IDE select HAVE_IOREMAP_PROT + select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_GZIP
arch/x86/include/asm/irq_stack.h +8 -11
@@ -189,19 +189,16 @@"call %P[__func] \n" /* -* Macro to invoke __do_softirq on the irq stack. Contrary to the above -* the only check which is necessary is whether the interrupt stack is -* in use already. +* Macro to invoke __do_softirq on the irq stack. This is only called from +* task context when bottom halfs are about to be reenabled and soft +* interrupts are pending to be processed. The interrupt stack cannot be in +* use here. */ -#define run_softirq_on_irqstack_cond () \ +#define run_softirq_on_irqstack () \ { \ - if (__this_cpu_read(hardirq_stack_inuse)) { \ - __do_softirq(); \ - } else { \ - __this_cpu_write(hardirq_stack_inuse, true); \ - call_on_irqstack(__do_softirq, ASM_CALL_SOFTIRQ); \ - __this_cpu_write(hardirq_stack_inuse, false); \ - } \ + __this_cpu_write(hardirq_stack_inuse, true); \ + call_on_irqstack(__do_softirq, ASM_CALL_SOFTIRQ); \ + __this_cpu_write(hardirq_stack_inuse, false); \ }#else /* CONFIG_X86_64 */
arch/x86/kernel/irq_64.c +1 -1
@@ -76,5 +76,5 @@ int irq_init_percpu_irqstack(unsigned invoid do_softirq_own_stack (void ) { -run_softirq_on_irqstack_cond (); +run_softirq_on_irqstack (); }
[tip: x86/entry] x86: Select CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 624db9eabc74597f682c0651047a25b54f7260a1 Gitweb: https://git.kernel.org/tip/624db9eabc74597f682c0651047a25b54f7260a1 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:51 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:16 +01:00
x86: Select CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK
Now that all invocations of irq_exit_rcu() happen on the irq stack, turn on CONFIG_HAVE_IRQ_EXIT_ON_IRQ_STACK which causes the core code to invoke __do_softirq() directly without going through do_softirq_own_stack().
That means do_softirq_own_stack() is only invoked from task context which means it can't be on the irq stack. Remove the conditional from run_softirq_on_irqstack_cond() and rename the function accordingly.
--- arch/x86/Kconfig | 1 + arch/x86/include/asm/irq_stack.h | 19 ++++++++----------- arch/x86/kernel/irq_64.c | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-)
arch/x86/Kconfig +1 -0
@@ -187,6 +187,7 @@ config X86 select HAVE_HW_BREAKPOINT select HAVE_IDE select HAVE_IOREMAP_PROT + select HAVE_IRQ_EXIT_ON_IRQ_STACK if X86_64 select HAVE_IRQ_TIME_ACCOUNTING select HAVE_KERNEL_BZIP2 select HAVE_KERNEL_GZIP
arch/x86/include/asm/irq_stack.h +8 -11
@@ -189,19 +189,16 @@"call %P[__func] \n" /* -* Macro to invoke __do_softirq on the irq stack. Contrary to the above -* the only check which is necessary is whether the interrupt stack is -* in use already. +* Macro to invoke __do_softirq on the irq stack. This is only called from +* task context when bottom halfs are about to be reenabled and soft +* interrupts are pending to be processed. The interrupt stack cannot be in +* use here. */ -#define run_softirq_on_irqstack_cond () \ +#define run_softirq_on_irqstack () \ { \ - if (__this_cpu_read(hardirq_stack_inuse)) { \ - __do_softirq(); \ - } else { \ - __this_cpu_write(hardirq_stack_inuse, true); \ - call_on_irqstack(__do_softirq, ASM_CALL_SOFTIRQ); \ - __this_cpu_write(hardirq_stack_inuse, false); \ - } \ + __this_cpu_write(hardirq_stack_inuse, true); \ + call_on_irqstack(__do_softirq, ASM_CALL_SOFTIRQ); \ + __this_cpu_write(hardirq_stack_inuse, false); \ }#else /* CONFIG_X86_64 */
arch/x86/kernel/irq_64.c +1 -1
@@ -76,5 +76,5 @@ int irq_init_percpu_irqstack(unsigned int cpu)void do_softirq_own_stack (void ) { -run_softirq_on_irqstack_cond (); +run_softirq_on_irqstack (); }
PATCH v2 11/13 softirq: Move __ARCH_HAS_DO_SOFTIRQ to Kconfig
In reply to Thomas GleixnerTo prepare for inlining do_softirq_own_stack() replace __ARCH_HAS_DO_SOFTIRQ with a Kconfig switch and select it in the affected architectures.
This allows in the next step to move the function prototype and the inline stub into a seperate asm-generic header file which is required to avoid include recursion.
---
V2: New patch to get rid of the nested #ifdeffery - Lai
--- arch/Kconfig | 6 ++++++ arch/parisc/Kconfig | 1 + arch/parisc/include/asm/hardirq.h | 4 ---- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/irq.h | 2 -- arch/s390/Kconfig | 1 + arch/s390/include/asm/hardirq.h | 1 - arch/sh/Kconfig | 1 + arch/sh/include/asm/irq.h | 1 - arch/sparc/Kconfig | 1 + arch/sparc/include/asm/irq_64.h | 1 - arch/x86/Kconfig | 1 + arch/x86/include/asm/irq.h | 2 -- include/linux/interrupt.h | 2 +- 14 files changed, 13 insertions(+), 12 deletions(-)
arch/Kconfig +6 -0
@@ -759,6 +759,12 @@ config HAVE_IRQ_EXIT_ON_IRQ_STACK This spares a stack switch and improves cache usage on softirq processing. +config HAVE_SOFTIRQ_ON_OWN_STACK + bool + help + Architecture provides a function to run __do_softirq() on a + seperate stack. + config PGTABLE_LEVELS int default 2
arch/parisc/Kconfig +1 -0
@@ -63,6 +63,7 @@ config PARISC select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE select HAVE_KPROBES_ON_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_REGS + select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS select SET_FS help
arch/parisc/include/asm/hardirq.h +0 -4
@@ -12,10 +12,6 @@#include <linux/threads.h> #include <linux/irq.h> -#ifdef CONFIG_IRQSTACKS -#define __ARCH_HAS_DO_SOFTIRQ -#endif - typedef struct { unsigned int __softirq_pending; unsigned int kernel_stack_usage;
arch/powerpc/Kconfig +1 -0
@@ -237,6 +237,7 @@ config PPC select MMU_GATHER_PAGE_SIZE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN + select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING
arch/powerpc/include/asm/irq.h +0 -2
@@ -37,8 +37,6 @@ extern int distribute_irqs;struct pt_regs ; -#define __ARCH_HAS_DO_SOFTIRQ -#if defined(CONFIG_BOOKE ) || defined(CONFIG_40x)/* * Per-cpu stacks for handling critical, debug and machine check
arch/s390/Kconfig +1 -0
@@ -182,6 +182,7 @@ config S390 select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RSEQ + select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_IDLE
arch/s390/include/asm/hardirq.h +0 -1
@@ -18,7 +18,6 @@#define or_softirq_pending (x) (S390_lowcore.softirq_pending |= (x))#define __ARCH_IRQ_STAT -#define __ARCH_HAS_DO_SOFTIRQ#define __ARCH_IRQ_EXIT_IRQS_DISABLEDstatic inline void ack_bad_irq (unsigned int irq)
arch/sh/Kconfig +1 -0
@@ -55,6 +55,7 @@ config SUPERH select HAVE_PERF_EVENTS select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_UID16 + select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select IRQ_FORCED_THREADING
arch/sh/include/asm/irq.h +0 -1
@@ -51,7 +51,6 @@ asmlinkage int do_IRQ(unsigned int irq,#ifdef CONFIG_IRQSTACKS extern void irq_ctx_init (int cpu);extern void irq_ctx_exit (int cpu); -# define __ARCH_HAS_DO_SOFTIRQ#else # define irq_ctx_init (cpu) do { } while (0)# define irq_ctx_exit (cpu) do { } while (0)
arch/sparc/Kconfig +1 -0
@@ -97,6 +97,7 @@ config SPARC64 select ARCH_HAS_PTE_SPECIAL select PCI_DOMAINS if PCI select ARCH_HAS_GIGANTIC_PAGE + select HAVE_SOFTIRQ_ON_OWN_STACK config ARCH_PROC_KCORE_TEXT def_bool y
arch/sparc/include/asm/irq_64.h +0 -1
@@ -93,7 +93,6 @@ void arch_trigger_cpumask_backtrace(consextern void *hardirq_stack[NR_CPUS ];extern void *softirq_stack[NR_CPUS ]; -#define __ARCH_HAS_DO_SOFTIRQ#define NO_IRQ 0xffffffff
arch/x86/Kconfig +1 -0
@@ -221,6 +221,7 @@ config X86 select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION select HAVE_FUNCTION_ARG_ACCESS_API + select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_STACKPROTECTOR if CC_HAS_SANE_STACKPROTECTOR select HAVE_STACK_VALIDATION if X86_64 select HAVE_STATIC_CALL
arch/x86/include/asm/irq.h +0 -2
@@ -25,8 +25,6 @@ static inline int irq_canonicalize(int iextern int irq_init_percpu_irqstack (unsigned int cpu); -#define __ARCH_HAS_DO_SOFTIRQ -struct irq_desc ;extern void fixup_irqs (void );
include/linux/interrupt.h +1 -1
@@ -569,7 +569,7 @@ struct softirq_action asmlinkage void do_softirq(void); asmlinkage void __do_softirq(void); -#ifdef __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK void do_softirq_own_stack (void );#else static inline void do_softirq_own_stack (void )
Re: [patch V2 11/13] softirq: Move __ARCH_HAS_DO_SOFTIRQ to Kconfig
Quoted 9 lines · Thomas Gleixner
To prepare for inlining
do_softirq_own_stack()replace__ARCH_HAS_DO_SOFTIRQwith aKconfigswitch and select it in the affected architectures.This allows in the next step to move the function prototype and the inline stub into a seperate asm-generic header file which is required to avoid include recursion.
Signed-off-by Thomas Gleixner <[email protected]>
Signature · 1 line
Kees Cook
[tip: x86/entry] softirq: Move __ARCH_HAS_DO_SOFTIRQ to Kconfig
In reply to Thomas GleixnerThe following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: cd1a41ceba8a4caef4d18a3a14d6d0f8c656efe4 Gitweb: https://git.kernel.org/tip/cd1a41ceba8a4caef4d18a3a14d6d0f8c656efe4 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:52 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:16 +01:00
softirq: Move __ARCH_HAS_DO_SOFTIRQ to Kconfig
To prepare for inlining do_softirq_own_stack() replace __ARCH_HAS_DO_SOFTIRQ with a Kconfig switch and select it in the affected architectures.
This allows in the next step to move the function prototype and the inline stub into a seperate asm-generic header file which is required to avoid include recursion.
--- arch/Kconfig | 6 ++++++ arch/parisc/Kconfig | 1 + arch/parisc/include/asm/hardirq.h | 4 ---- arch/powerpc/Kconfig | 1 + arch/powerpc/include/asm/irq.h | 2 -- arch/s390/Kconfig | 1 + arch/s390/include/asm/hardirq.h | 1 - arch/sh/Kconfig | 1 + arch/sh/include/asm/irq.h | 1 - arch/sparc/Kconfig | 1 + arch/sparc/include/asm/irq_64.h | 1 - arch/x86/Kconfig | 1 + arch/x86/include/asm/irq.h | 2 -- include/linux/interrupt.h | 2 +- 14 files changed, 13 insertions(+), 12 deletions(-)
arch/Kconfig +6 -0
@@ -759,6 +759,12 @@ config HAVE_IRQ_EXIT_ON_IRQ_STACK This spares a stack switch and improves cache usage on softirq processing. +config HAVE_SOFTIRQ_ON_OWN_STACK + bool + help + Architecture provides a function to run __do_softirq() on a + seperate stack. + config PGTABLE_LEVELS int default 2
arch/parisc/Kconfig +1 -0
@@ -63,6 +63,7 @@ config PARISC select HAVE_FTRACE_MCOUNT_RECORD if HAVE_DYNAMIC_FTRACE select HAVE_KPROBES_ON_FTRACE select HAVE_DYNAMIC_FTRACE_WITH_REGS + select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS select SET_FS help
arch/parisc/include/asm/hardirq.h +0 -4
@@ -12,10 +12,6 @@#include <linux/threads.h> #include <linux/irq.h> -#ifdef CONFIG_IRQSTACKS -#define __ARCH_HAS_DO_SOFTIRQ -#endif - typedef struct { unsigned int __softirq_pending; unsigned int kernel_stack_usage;
arch/powerpc/Kconfig +1 -0
@@ -237,6 +237,7 @@ config PPC select MMU_GATHER_PAGE_SIZE select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if PPC_BOOK3S_64 && CPU_LITTLE_ENDIAN + select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING
arch/powerpc/include/asm/irq.h +0 -2
@@ -37,8 +37,6 @@ extern int distribute_irqs;struct pt_regs ; -#define __ARCH_HAS_DO_SOFTIRQ -#if defined(CONFIG_BOOKE ) || defined(CONFIG_40x)/* * Per-cpu stacks for handling critical, debug and machine check
arch/s390/Kconfig +1 -0
@@ -182,6 +182,7 @@ config S390 select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE select HAVE_RSEQ + select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_SYSCALL_TRACEPOINTS select HAVE_VIRT_CPU_ACCOUNTING select HAVE_VIRT_CPU_ACCOUNTING_IDLE
arch/s390/include/asm/hardirq.h +0 -1
@@ -18,7 +18,6 @@#define or_softirq_pending (x) (S390_lowcore.softirq_pending |= (x))#define __ARCH_IRQ_STAT -#define __ARCH_HAS_DO_SOFTIRQ#define __ARCH_IRQ_EXIT_IRQS_DISABLEDstatic inline void ack_bad_irq (unsigned int irq)
arch/sh/Kconfig +1 -0
@@ -56,6 +56,7 @@ config SUPERH select HAVE_PERF_EVENTS select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_UID16 + select HAVE_SOFTIRQ_ON_OWN_STACK if IRQSTACKS select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS select IRQ_FORCED_THREADING
arch/sh/include/asm/irq.h +0 -1
@@ -51,7 +51,6 @@ asmlinkage int do_IRQ(unsigned int irq, struct pt_regs *regs);#ifdef CONFIG_IRQSTACKS extern void irq_ctx_init (int cpu);extern void irq_ctx_exit (int cpu); -# define __ARCH_HAS_DO_SOFTIRQ#else # define irq_ctx_init (cpu) do { } while (0)# define irq_ctx_exit (cpu) do { } while (0)
arch/sparc/Kconfig +1 -0
@@ -97,6 +97,7 @@ config SPARC64 select ARCH_HAS_PTE_SPECIAL select PCI_DOMAINS if PCI select ARCH_HAS_GIGANTIC_PAGE + select HAVE_SOFTIRQ_ON_OWN_STACK config ARCH_PROC_KCORE_TEXT def_bool y
arch/sparc/include/asm/irq_64.h +0 -1
@@ -93,7 +93,6 @@ void arch_trigger_cpumask_backtrace(const struct cpumask *mask,extern void *hardirq_stack[NR_CPUS ];extern void *softirq_stack[NR_CPUS ]; -#define __ARCH_HAS_DO_SOFTIRQ#define NO_IRQ 0xffffffff
arch/x86/Kconfig +1 -0
@@ -221,6 +221,7 @@ config X86 select HAVE_REGS_AND_STACK_ACCESS_API select HAVE_RELIABLE_STACKTRACE if X86_64 && (UNWINDER_FRAME_POINTER || UNWINDER_ORC) && STACK_VALIDATION select HAVE_FUNCTION_ARG_ACCESS_API + select HAVE_SOFTIRQ_ON_OWN_STACK select HAVE_STACKPROTECTOR if CC_HAS_SANE_STACKPROTECTOR select HAVE_STACK_VALIDATION if X86_64 select HAVE_STATIC_CALL
arch/x86/include/asm/irq.h +0 -2
@@ -25,8 +25,6 @@ static inline int irq_canonicalize(int irq)extern int irq_init_percpu_irqstack (unsigned int cpu); -#define __ARCH_HAS_DO_SOFTIRQ -struct irq_desc ;extern void fixup_irqs (void );
include/linux/interrupt.h +1 -1
@@ -569,7 +569,7 @@ struct softirq_action asmlinkage void do_softirq(void); asmlinkage void __do_softirq(void); -#ifdef __ARCH_HAS_DO_SOFTIRQ +#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK void do_softirq_own_stack (void );#else static inline void do_softirq_own_stack (void )
PATCH v2 12/13 softirq: Move do_softirq_own_stack() to generic asm header
In reply to Thomas GleixnerTo avoid include recursion hell move the do_softirq_own_stack() related content into a generic asm header and include it from all places in arch/ which need the prototype.
This allows architectures to provide an inline implementation of do_softirq_own_stack() without introducing a lot of #ifdeffery all over the place.
---
V2: New patch to get rid of the nested #ifdeffery - Lai
--- arch/parisc/kernel/irq.c | 1 + arch/powerpc/kernel/irq.c | 1 + arch/s390/kernel/irq.c | 1 + arch/sh/kernel/irq.c | 1 + arch/sparc/kernel/irq_64.c | 1 + arch/x86/kernel/irq_32.c | 1 + arch/x86/kernel/irq_64.c | 1 + include/asm-generic/Kbuild | 1 + include/asm-generic/softirq_stack.h | 14 ++++++++++++++ include/linux/interrupt.h | 9 --------- kernel/softirq.c | 2 ++ 11 files changed, 24 insertions(+), 9 deletions(-)
arch/parisc/kernel/irq.c +1 -0
@@ -17,6 +17,7 @@#include <linux/types.h> #include <asm/io.h> +#include <asm/softirq_stack.h> #include <asm/smp.h> #include <asm/ldcw.h>
arch/powerpc/kernel/irq.c +1 -0
@@ -65,6 +65,7 @@#include <asm/livepatch.h> #include <asm/asm-prototypes.h> #include <asm/hw_irq.h> +#include <asm/softirq_stack.h> #ifdef CONFIG_PPC64 #include <asm/paca.h>
arch/s390/kernel/irq.c +1 -0
@@ -27,6 +27,7 @@#include <asm/irq.h> #include <asm/hw_irq.h> #include <asm/stacktrace.h> +#include <asm/softirq_stack.h> #include "entry.h" DEFINE_PER_CPU_SHARED_ALIGNED(struct irq_stat, irq_stat);
arch/sh/kernel/irq.c +1 -0
@@ -20,6 +20,7 @@#include <linux/uaccess.h> #include <asm/thread_info.h> #include <cpu/mmu_context.h> +#include <asm/softirq_stack.h> atomic_t irq_err_count;
arch/sparc/kernel/irq_64.c +1 -0
@@ -42,6 +42,7 @@#include <asm/head.h> #include <asm/hypervisor.h> #include <asm/cacheflush.h> +#include <asm/softirq_stack.h> #include "entry.h" #include "cpumap.h"
arch/x86/kernel/irq_32.c +1 -0
@@ -22,6 +22,7 @@#include <asm/apic.h> #include <asm/nospec-branch.h> +#include <asm/softirq_stack.h> #ifdef CONFIG_DEBUG_STACKOVERFLOW
arch/x86/kernel/irq_64.c +1 -0
@@ -20,6 +20,7 @@#include <linux/sched/task_stack.h> #include <asm/cpu_entry_area.h> +#include <asm/softirq_stack.h> #include <asm/irq_stack.h> #include <asm/io_apic.h> #include <asm/apic.h>
include/asm-generic/Kbuild +1 -0
@@ -51,6 +51,7 @@ mandatory-y += sections.h mandatory-y += serial.h mandatory-y += shmparam.h mandatory-y += simd.h +mandatory-y += softirq_stack.h mandatory-y += switch_to.h mandatory-y += timex.h mandatory-y += tlbflush.h
include/asm-generic/softirq_stack.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __ASM_GENERIC_SOFTIRQ_STACK_H +#define __ASM_GENERIC_SOFTIRQ_STACK_H + +#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK +void do_softirq_own_stack (void ); +#else +static inline void do_softirq_own_stack (void ) +{ +__do_softirq (); +} +#endif + +#endif
include/linux/interrupt.h +0 -9
@@ -569,15 +569,6 @@ struct softirq_action asmlinkage void do_softirq(void); asmlinkage void __do_softirq(void); -#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK -void do_softirq_own_stack (void ); -#else -static inline void do_softirq_own_stack (void ) -{ -__do_softirq (); -} -#endif -extern void open_softirq (int nr,void (*action)(struct softirq_action *));extern void softirq_init (void );extern void __raise_softirq_irqoff (unsigned int nr);
kernel/softirq.c +2 -0
@@ -26,6 +26,8 @@#include <linux/tick.h> #include <linux/irq.h> +#include <asm/softirq_stack.h> +#define CREATE_TRACE_POINTS #include <trace/events/irq.h>
Re: [patch V2 12/13] softirq: Move do_softirq_own_stack() to generic asm header
Quoted 9 lines · Thomas Gleixner
To avoid include recursion hell move the
do_softirq_own_stack()related content into a generic asm header and include it from all places inarch/which need the prototype.This allows architectures to provide an inline implementation of
do_softirq_own_stack()without introducing a lot of #ifdeffery all over the place.Signed-off-by Thomas Gleixner <[email protected]>
Signature · 1 line
Kees Cook
[tip: x86/entry] softirq: Move do_softirq_own_stack() to generic asm header
In reply to Thomas GleixnerThe following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: db1cc7aede37eb9235759131ddfefd9c0ea5136f Gitweb: https://git.kernel.org/tip/db1cc7aede37eb9235759131ddfefd9c0ea5136f Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:53 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:16 +01:00
softirq: Move do_softirq_own_stack() to generic asm header
To avoid include recursion hell move the do_softirq_own_stack() related content into a generic asm header and include it from all places in arch/ which need the prototype.
This allows architectures to provide an inline implementation of do_softirq_own_stack() without introducing a lot of #ifdeffery all over the place.
--- arch/parisc/kernel/irq.c | 1 + arch/powerpc/kernel/irq.c | 1 + arch/s390/kernel/irq.c | 1 + arch/sh/kernel/irq.c | 1 + arch/sparc/kernel/irq_64.c | 1 + arch/x86/kernel/irq_32.c | 1 + arch/x86/kernel/irq_64.c | 1 + include/asm-generic/Kbuild | 1 + include/asm-generic/softirq_stack.h | 14 ++++++++++++++ include/linux/interrupt.h | 9 --------- kernel/softirq.c | 2 ++ 11 files changed, 24 insertions(+), 9 deletions(-) create mode 100644 include/asm-generic/softirq_stack.h
arch/parisc/kernel/irq.c +1 -0
@@ -17,6 +17,7 @@#include <linux/types.h> #include <asm/io.h> +#include <asm/softirq_stack.h> #include <asm/smp.h> #include <asm/ldcw.h>
arch/powerpc/kernel/irq.c +1 -0
@@ -65,6 +65,7 @@#include <asm/livepatch.h> #include <asm/asm-prototypes.h> #include <asm/hw_irq.h> +#include <asm/softirq_stack.h> #ifdef CONFIG_PPC64 #include <asm/paca.h>
arch/s390/kernel/irq.c +1 -0
@@ -27,6 +27,7 @@#include <asm/irq.h> #include <asm/hw_irq.h> #include <asm/stacktrace.h> +#include <asm/softirq_stack.h> #include "entry.h" DEFINE_PER_CPU_SHARED_ALIGNED(struct irq_stat, irq_stat);
arch/sh/kernel/irq.c +1 -0
@@ -20,6 +20,7 @@#include <linux/uaccess.h> #include <asm/thread_info.h> #include <cpu/mmu_context.h> +#include <asm/softirq_stack.h> atomic_t irq_err_count;
arch/sparc/kernel/irq_64.c +1 -0
@@ -42,6 +42,7 @@#include <asm/head.h> #include <asm/hypervisor.h> #include <asm/cacheflush.h> +#include <asm/softirq_stack.h> #include "entry.h" #include "cpumap.h"
arch/x86/kernel/irq_32.c +1 -0
@@ -22,6 +22,7 @@#include <asm/apic.h> #include <asm/nospec-branch.h> +#include <asm/softirq_stack.h> #ifdef CONFIG_DEBUG_STACKOVERFLOW
arch/x86/kernel/irq_64.c +1 -0
@@ -20,6 +20,7 @@#include <linux/sched/task_stack.h> #include <asm/cpu_entry_area.h> +#include <asm/softirq_stack.h> #include <asm/irq_stack.h> #include <asm/io_apic.h> #include <asm/apic.h>
include/asm-generic/Kbuild +1 -0
@@ -51,6 +51,7 @@ mandatory-y += sections.h mandatory-y += serial.h mandatory-y += shmparam.h mandatory-y += simd.h +mandatory-y += softirq_stack.h mandatory-y += switch_to.h mandatory-y += timex.h mandatory-y += tlbflush.h
include/asm-generic/softirq_stack.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef __ASM_GENERIC_SOFTIRQ_STACK_H +#define __ASM_GENERIC_SOFTIRQ_STACK_H + +#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK +void do_softirq_own_stack (void ); +#else +static inline void do_softirq_own_stack (void ) +{ +__do_softirq (); +} +#endif + +#endif
include/linux/interrupt.h +0 -9
@@ -569,15 +569,6 @@ struct softirq_action asmlinkage void do_softirq(void); asmlinkage void __do_softirq(void); -#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK -void do_softirq_own_stack (void ); -#else -static inline void do_softirq_own_stack (void ) -{ -__do_softirq (); -} -#endif -extern void open_softirq (int nr,void (*action)(struct softirq_action *));extern void softirq_init (void );extern void __raise_softirq_irqoff (unsigned int nr);
kernel/softirq.c +2 -0
@@ -26,6 +26,8 @@#include <linux/tick.h> #include <linux/irq.h> +#include <asm/softirq_stack.h> +#define CREATE_TRACE_POINTS #include <trace/events/irq.h>
PATCH v2 13/13 x86/softirq/64: Inline do_softirq_own_stack()
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
There is no reason to have this as a seperate function for a single caller.
---
V2: Adopt to the new header file.
--- arch/x86/include/asm/irq_stack.h | 3 +-- arch/x86/include/asm/softirq_stack.h | 11 +++++++++++ arch/x86/kernel/irq_64.c | 5 ----- 3 files changed, 12 insertions(+), 7 deletions(-)
arch/x86/include/asm/irq_stack.h +1 -2
@@ -194,7 +194,7 @@* interrupts are pending to be processed. The interrupt stack cannot be in * use here. */ -#define run_softirq_on_irqstack () \ +#define do_softirq_own_stack () \ { \ __this_cpu_write(hardirq_stack_inuse, true); \ call_on_irqstack(__do_softirq, ASM_CALL_SOFTIRQ); \
@@ -202,7 +202,6 @@ }#else /* CONFIG_X86_64 */ -/* System vector handlers always run on the stack they interrupted. */ #define run_sysvec_on_irqstack_cond (func, regs) \ { \
arch/x86/include/asm/softirq_stack.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SOFTIRQ_STACK_H +#define _ASM_X86_SOFTIRQ_STACK_H + +#ifdef CONFIG_X86_64 +# include <asm/irq_stack.h> +#else +# include <asm-generic/softirq_stack.h> +#endif + +#endif
arch/x86/kernel/irq_64.c +0 -5
@@ -74,8 +74,3 @@ int irq_init_percpu_irqstack(unsigned inreturn 0 ;return map_irq_stack (cpu); } - -void do_softirq_own_stack (void ) -{ -run_softirq_on_irqstack (); -}
[tip: x86/entry] x86/softirq/64: Inline do_softirq_own_stack()
The following commit has been merged into the x86/entry branch of tip:
The following commit has been merged into the x86/entry branch of tip:
Commit-ID: 72f40a2823d6e16229ab58b898c6f22044e5222f Gitweb: https://git.kernel.org/tip/72f40a2823d6e16229ab58b898c6f22044e5222f Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 10 Feb 2021 00:40:54 +01:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Wed, 10 Feb 2021 23:34:17 +01:00
x86/softirq/64: Inline do_softirq_own_stack()
There is no reason to have this as a seperate function for a single caller.
--- arch/x86/include/asm/irq_stack.h | 3 +-- arch/x86/include/asm/softirq_stack.h | 11 +++++++++++ arch/x86/kernel/irq_64.c | 5 ----- 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 arch/x86/include/asm/softirq_stack.h
arch/x86/include/asm/irq_stack.h +1 -2
@@ -194,7 +194,7 @@* interrupts are pending to be processed. The interrupt stack cannot be in * use here. */ -#define run_softirq_on_irqstack () \ +#define do_softirq_own_stack () \ { \ __this_cpu_write(hardirq_stack_inuse, true); \ call_on_irqstack(__do_softirq, ASM_CALL_SOFTIRQ); \
@@ -202,7 +202,6 @@ }#else /* CONFIG_X86_64 */ -/* System vector handlers always run on the stack they interrupted. */ #define run_sysvec_on_irqstack_cond (func, regs) \ { \
arch/x86/include/asm/softirq_stack.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_SOFTIRQ_STACK_H +#define _ASM_X86_SOFTIRQ_STACK_H + +#ifdef CONFIG_X86_64 +# include <asm/irq_stack.h> +#else +# include <asm-generic/softirq_stack.h> +#endif + +#endif
arch/x86/kernel/irq_64.c +0 -5
@@ -74,8 +74,3 @@ int irq_init_percpu_irqstack(unsigned int cpu)return 0 ;return map_irq_stack (cpu); } - -void do_softirq_own_stack (void ) -{ -run_softirq_on_irqstack (); -}
Re: [patch V2 13/13] x86/softirq/64: Inline do_softirq_own_stack()
In reply to Thomas GleixnerQuoted 6 lines · Thomas Gleixner
From: Thomas Gleixner <[email protected]>
There is no reason to have this as a seperate function for a single caller.
Signed-off-by Thomas Gleixner <[email protected]>Reviewed-by Kees Cook <[email protected]>
When building ARCH=um SUBARCH="x86_64" defconfig:
kernel/softirq.c: In function 'invoke_softirq':arch/x86/include/asm/irq_stack.h:199:19: error: 'hardirq_stack_inuse' undeclared
./arch/x86/include/asm/irq_stack.h:84:33: error: ‘hardirq_stack_ptr’ undeclared (first use in this function)
Guenter
---
bisect log:
# bad: [52a0bcb60e40f30211cb5cbbb0f582ec4e91d896] Add linux-next specific files for 20210215 # good: [92bf22614b21a2706f4993b278017e437f7785b3] Linux 5.11-rc7
git bisect start 'HEAD' 'v5.11-rc7'
# good: [9f44811a4ca6db01e73017e565381549b3c3fc60] next-20210212/mtd
git bisect good 9f44811a4ca6db01e73017e565381549b3c3fc60
# good: [88a516b8c681d666e252abfa5e346606d94653a3] Merge remote-tracking branch 'devicetree/for-next' git bisect good 88a516b8c681d666e252abfa5e346606d94653a3
# bad: [1c623c776046c4b9d47f70f07928980815578cc1] Merge remote-tracking branch 'char-misc/char-misc-next' git bisect bad 1c623c776046c4b9d47f70f07928980815578cc1
# bad: [f70ed845051885a4887dd76cb7c616b8f4a2942c] Merge remote-tracking branch 'drivers-x86/for-next' git bisect bad f70ed845051885a4887dd76cb7c616b8f4a2942c
# bad: [f1b61f7b4fb971f281978fb905507e9ac9b2d973] Merge branch 'core/mm'
git bisect bad f1b61f7b4fb971f281978fb905507e9ac9b2d973
# bad: [364af1939d1ec3512b69bcdc035063a60f9c0b3e] Merge branch 'ras/core'
git bisect bad 364af1939d1ec3512b69bcdc035063a60f9c0b3e
# bad: [9db733e3c78c9c00fa93860078674f23d6dd8b7d] Merge branch 'x86/entry'
git bisect bad 9db733e3c78c9c00fa93860078674f23d6dd8b7d
# bad: [a3251c1a36f595046bea03935ebe37a1e1f1f1d7] Merge branch 'x86/paravirt' into x86/entry git bisect bad a3251c1a36f595046bea03935ebe37a1e1f1f1d7
# good: [f83d1a0190bf6ac788a848454d21daee2299d085] x86/acpi: Annotate indirect branch as safe git bisect good f83d1a0190bf6ac788a848454d21daee2299d085
# good: [a0cfc74d0b00c5201e1c09e28b2dc01c8088f809] x86/irq: Provide macro for inlining irq stack switching git bisect good a0cfc74d0b00c5201e1c09e28b2dc01c8088f809
# good: [db1cc7aede37eb9235759131ddfefd9c0ea5136f] softirq: Move do_softirq_own_stack() to generic asm header git bisect good db1cc7aede37eb9235759131ddfefd9c0ea5136f
# good: [53c9d9240944088274aadbbbafc6138ca462db4f] x86/pv: Switch SWAPGS to ALTERNATIVE
git bisect good 53c9d9240944088274aadbbbafc6138ca462db4f
# good: [ab234a260b1f625b26cbefa93ca365b0ae66df33] x86/pv: Rework arch_local_irq_restore() to not use popf git bisect good ab234a260b1f625b26cbefa93ca365b0ae66df33
# bad: [72f40a2823d6e16229ab58b898c6f22044e5222f] x86/softirq/64: Inline do_softirq_own_stack() git bisect bad 72f40a2823d6e16229ab58b898c6f22044e5222f
# first bad commit: [72f40a2823d6e16229ab58b898c6f22044e5222f] x86/softirq/64: Inline do_softirq_own_stack()