Skip to content

Commit 3383642

Browse files
amlutoIngo Molnar
authored andcommitted
x86/traps: Use a new on_thread_stack() helper to clean up an assertion
Let's keep the stack-related logic together rather than open-coding a comparison in an assertion in the traps code. Signed-off-by: Andy Lutomirski <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/856b15bee1f55017b8f79d3758b0d51c48a08cf8.1509609304.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]>
1 parent d375cf1 commit 3383642

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

arch/x86/include/asm/processor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,12 @@ static inline unsigned long current_top_of_stack(void)
541541
#endif
542542
}
543543

544+
static inline bool on_thread_stack(void)
545+
{
546+
return (unsigned long)(current_top_of_stack() -
547+
current_stack_pointer) < THREAD_SIZE;
548+
}
549+
544550
#ifdef CONFIG_PARAVIRT
545551
#include <asm/paravirt.h>
546552
#else

arch/x86/kernel/traps.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ void ist_begin_non_atomic(struct pt_regs *regs)
141141
* will catch asm bugs and any attempt to use ist_preempt_enable
142142
* from double_fault.
143143
*/
144-
BUG_ON((unsigned long)(current_top_of_stack() -
145-
current_stack_pointer) >= THREAD_SIZE);
144+
BUG_ON(!on_thread_stack());
146145

147146
preempt_enable_no_resched();
148147
}

0 commit comments

Comments
 (0)