Skip to content

Commit b052df3

Browse files
committed
x86/entry: Get rid of ist_begin/end_non_atomic()
This is completely overengineered and definitely not an interface which should be made available to anything else than this particular MCE case. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Alexandre Chartre <[email protected]> Acked-by: Peter Zijlstra <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent f93524e commit b052df3

File tree

3 files changed

+4
-41
lines changed

3 files changed

+4
-41
lines changed

arch/x86/include/asm/traps.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ asmlinkage void smp_irq_move_cleanup_interrupt(void);
120120

121121
extern void ist_enter(struct pt_regs *regs);
122122
extern void ist_exit(struct pt_regs *regs);
123-
extern void ist_begin_non_atomic(struct pt_regs *regs);
124-
extern void ist_end_non_atomic(void);
125123

126124
#ifdef CONFIG_VMAP_STACK
127125
void __noreturn handle_stack_overflow(const char *message,

arch/x86/kernel/cpu/mce/core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,13 +1352,15 @@ void notrace do_machine_check(struct pt_regs *regs, long error_code)
13521352

13531353
/* Fault was in user mode and we need to take some action */
13541354
if ((m.cs & 3) == 3) {
1355-
ist_begin_non_atomic(regs);
1355+
/* If this triggers there is no way to recover. Die hard. */
1356+
BUG_ON(!on_thread_stack() || !user_mode(regs));
13561357
local_irq_enable();
1358+
preempt_enable();
13571359

13581360
if (kill_it || do_memory_failure(&m))
13591361
force_sig(SIGBUS);
1362+
preempt_disable();
13601363
local_irq_disable();
1361-
ist_end_non_atomic();
13621364
} else {
13631365
if (!fixup_exception(regs, X86_TRAP_MC, error_code, 0))
13641366
mce_panic("Failed kernel mode recovery", &m, msg);

arch/x86/kernel/traps.c

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -117,43 +117,6 @@ void ist_exit(struct pt_regs *regs)
117117
rcu_nmi_exit();
118118
}
119119

120-
/**
121-
* ist_begin_non_atomic() - begin a non-atomic section in an IST exception
122-
* @regs: regs passed to the IST exception handler
123-
*
124-
* IST exception handlers normally cannot schedule. As a special
125-
* exception, if the exception interrupted userspace code (i.e.
126-
* user_mode(regs) would return true) and the exception was not
127-
* a double fault, it can be safe to schedule. ist_begin_non_atomic()
128-
* begins a non-atomic section within an ist_enter()/ist_exit() region.
129-
* Callers are responsible for enabling interrupts themselves inside
130-
* the non-atomic section, and callers must call ist_end_non_atomic()
131-
* before ist_exit().
132-
*/
133-
void ist_begin_non_atomic(struct pt_regs *regs)
134-
{
135-
BUG_ON(!user_mode(regs));
136-
137-
/*
138-
* Sanity check: we need to be on the normal thread stack. This
139-
* will catch asm bugs and any attempt to use ist_preempt_enable
140-
* from double_fault.
141-
*/
142-
BUG_ON(!on_thread_stack());
143-
144-
preempt_enable_no_resched();
145-
}
146-
147-
/**
148-
* ist_end_non_atomic() - begin a non-atomic section in an IST exception
149-
*
150-
* Ends a non-atomic section started with ist_begin_non_atomic().
151-
*/
152-
void ist_end_non_atomic(void)
153-
{
154-
preempt_disable();
155-
}
156-
157120
int is_valid_bugaddr(unsigned long addr)
158121
{
159122
unsigned short ud;

0 commit comments

Comments
 (0)