Skip to content

Commit

Permalink
x86/traps: Stop using ist_enter/exit() in do_int3()
Browse files Browse the repository at this point in the history
#BP is not longer using IST and using ist_enter() and ist_exit() makes it
harder to change ist_enter() and ist_exit()'s behavior.  Instead open-code
the very small amount of required logic.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Link: https://lkml.kernel.org/r/20200225220217.150607679@linutronix.de
  • Loading branch information
Andy Lutomirski authored and Thomas Gleixner committed Feb 27, 2020
1 parent ac3607f commit 65c668f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions arch/x86/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,20 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
return;

/*
* Use ist_enter despite the fact that we don't use an IST stack.
* We can be called from a kprobe in non-CONTEXT_KERNEL kernel
* mode or even during context tracking state changes.
* Unlike any other non-IST entry, we can be called from a kprobe in
* non-CONTEXT_KERNEL kernel mode or even during context tracking
* state changes. Make sure that we wake up RCU even if we're coming
* from kernel code.
*
* This means that we can't schedule. That's okay.
* This means that we can't schedule even if we came from a
* preemptible kernel context. That's okay.
*/
ist_enter(regs);
if (!user_mode(regs)) {
rcu_nmi_enter();
preempt_disable();
}
RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU");

#ifdef CONFIG_KGDB_LOW_LEVEL_TRAP
if (kgdb_ll_trap(DIE_INT3, "int3", regs, error_code, X86_TRAP_BP,
SIGTRAP) == NOTIFY_STOP)
Expand All @@ -600,7 +606,10 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code)
cond_local_irq_disable(regs);

exit:
ist_exit(regs);
if (!user_mode(regs)) {
preempt_enable_no_resched();
rcu_nmi_exit();
}
}
NOKPROBE_SYMBOL(do_int3);

Expand Down

0 comments on commit 65c668f

Please sign in to comment.