x86/entry: Implement user mode C entry points for #DB and #MCE
The MCE entry point uses the same mechanism as the IST entry point for now. For #DB split the inner workings and just keep the nmi_enter/exit() magic in the IST variant. Fixup the ASM code to emit the proper noist_##cfunc call. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com> Acked-by: Peter Zijlstra <peterz@infradead.org> Acked-by: Andy Lutomirski <luto@kernel.org> Link: https://lkml.kernel.org/r/20200505135315.177564104@linutronix.de
This commit is contained in:
@@ -1904,25 +1904,51 @@ static void unexpected_machine_check(struct pt_regs *regs)
|
||||
/* Call the installed machine check handler for this CPU setup. */
|
||||
void (*machine_check_vector)(struct pt_regs *) = unexpected_machine_check;
|
||||
|
||||
DEFINE_IDTENTRY_MCE(exc_machine_check)
|
||||
static __always_inline void exc_machine_check_kernel(struct pt_regs *regs)
|
||||
{
|
||||
/*
|
||||
* Only required when from kernel mode. See
|
||||
* mce_check_crashing_cpu() for details.
|
||||
*/
|
||||
if (machine_check_vector == do_machine_check &&
|
||||
mce_check_crashing_cpu())
|
||||
return;
|
||||
|
||||
if (user_mode(regs))
|
||||
idtentry_enter(regs);
|
||||
else
|
||||
nmi_enter();
|
||||
|
||||
nmi_enter();
|
||||
machine_check_vector(regs);
|
||||
|
||||
if (user_mode(regs))
|
||||
idtentry_exit(regs);
|
||||
else
|
||||
nmi_exit();
|
||||
nmi_exit();
|
||||
}
|
||||
|
||||
static __always_inline void exc_machine_check_user(struct pt_regs *regs)
|
||||
{
|
||||
idtentry_enter(regs);
|
||||
machine_check_vector(regs);
|
||||
idtentry_exit(regs);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
/* MCE hit kernel mode */
|
||||
DEFINE_IDTENTRY_MCE(exc_machine_check)
|
||||
{
|
||||
exc_machine_check_kernel(regs);
|
||||
}
|
||||
|
||||
/* The user mode variant. */
|
||||
DEFINE_IDTENTRY_MCE_USER(exc_machine_check)
|
||||
{
|
||||
exc_machine_check_user(regs);
|
||||
}
|
||||
#else
|
||||
/* 32bit unified entry point */
|
||||
DEFINE_IDTENTRY_MCE(exc_machine_check)
|
||||
{
|
||||
if (user_mode(regs))
|
||||
exc_machine_check_user(regs);
|
||||
else
|
||||
exc_machine_check_kernel(regs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Called for each booted CPU to set up machine checks.
|
||||
* Must be called with preempt off:
|
||||
|
Reference in New Issue
Block a user