[PATCH 5/8] x86,tracing: Mark debug_stack_{set_zero,reset)() notrace

From: Peter Zijlstra
Date: Wed Feb 12 2020 - 04:44:10 EST


Because do_nmi() must not call into tracing outside of
nmi_enter()/nmi_exit(), these functions must be notrace.

Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
---
arch/x86/kernel/cpu/common.c | 4 ++--
arch/x86/kernel/nmi.c | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)

--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -1690,14 +1690,14 @@ void syscall_init(void)
DEFINE_PER_CPU(int, debug_stack_usage);
DEFINE_PER_CPU(u32, debug_idt_ctr);

-void debug_stack_set_zero(void)
+void notrace debug_stack_set_zero(void)
{
this_cpu_inc(debug_idt_ctr);
load_current_idt();
}
NOKPROBE_SYMBOL(debug_stack_set_zero);

-void debug_stack_reset(void)
+void notrace debug_stack_reset(void)
{
if (WARN_ON(!this_cpu_read(debug_idt_ctr)))
return;
--- a/arch/x86/kernel/nmi.c
+++ b/arch/x86/kernel/nmi.c
@@ -534,6 +534,9 @@ do_nmi(struct pt_regs *regs, long error_
}
#endif

+ /*
+ * It is important that no tracing happens before nmi_enter()!
+ */
nmi_enter();

inc_irq_stat(__nmi_count);
@@ -542,6 +545,9 @@ do_nmi(struct pt_regs *regs, long error_
default_do_nmi(regs);

nmi_exit();
+ /*
+ * No tracing after nmi_exit()!
+ */

#ifdef CONFIG_X86_64
if (unlikely(this_cpu_read(update_debug_stack))) {