Skip to content

Commit 3ffdfdc

Browse files
committed
x86/entry: Move paranoid irq tracing out of ASM code
The last step to remove the irq tracing cruft from ASM. Ignore #DF as the maschine is going to die anyway. Signed-off-by: Thomas Gleixner <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Andy Lutomirski <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9628f26 commit 3ffdfdc

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

arch/x86/entry/entry_64.S

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*
1717
* Some macro usage:
1818
* - SYM_FUNC_START/END:Define functions in the symbol table.
19-
* - TRACE_IRQ_*: Trace hardirq state for lock debugging.
2019
* - idtentry: Define exception entry points.
2120
*/
2221
#include <linux/linkage.h>
@@ -107,11 +106,6 @@ SYM_CODE_END(native_usergs_sysret64)
107106

108107
SYM_CODE_START(entry_SYSCALL_64)
109108
UNWIND_HINT_EMPTY
110-
/*
111-
* Interrupts are off on entry.
112-
* We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
113-
* it is too small to ever cause noticeable irq latency.
114-
*/
115109

116110
swapgs
117111
/* tss.sp2 is scratch space. */
@@ -462,8 +456,6 @@ SYM_CODE_START(\asmsym)
462456

463457
UNWIND_HINT_REGS
464458

465-
TRACE_IRQS_OFF
466-
467459
movq %rsp, %rdi /* pt_regs pointer */
468460

469461
.if \vector == X86_TRAP_DB
@@ -881,17 +873,13 @@ SYM_CODE_END(paranoid_entry)
881873
*/
882874
SYM_CODE_START_LOCAL(paranoid_exit)
883875
UNWIND_HINT_REGS
884-
DISABLE_INTERRUPTS(CLBR_ANY)
885-
TRACE_IRQS_OFF
886876
testl %ebx, %ebx /* swapgs needed? */
887877
jnz .Lparanoid_exit_no_swapgs
888-
TRACE_IRQS_IRETQ
889878
/* Always restore stashed CR3 value (see paranoid_entry) */
890879
RESTORE_CR3 scratch_reg=%rbx save_reg=%r14
891880
SWAPGS_UNSAFE_STACK
892881
jmp restore_regs_and_return_to_kernel
893882
.Lparanoid_exit_no_swapgs:
894-
TRACE_IRQS_IRETQ
895883
/* Always restore stashed CR3 value (see paranoid_entry) */
896884
RESTORE_CR3 scratch_reg=%rbx save_reg=%r14
897885
jmp restore_regs_and_return_to_kernel
@@ -1292,7 +1280,6 @@ end_repeat_nmi:
12921280
call paranoid_entry
12931281
UNWIND_HINT_REGS
12941282

1295-
/* paranoidentry exc_nmi(), 0; without TRACE_IRQS_OFF */
12961283
movq %rsp, %rdi
12971284
movq $-1, %rsi
12981285
call exc_nmi

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,10 @@ static __always_inline void exc_machine_check_kernel(struct pt_regs *regs)
19221922
* that out because it's an indirect call. Annotate it.
19231923
*/
19241924
instrumentation_begin();
1925+
trace_hardirqs_off_prepare();
19251926
machine_check_vector(regs);
1927+
if (regs->flags & X86_EFLAGS_IF)
1928+
trace_hardirqs_on_prepare();
19261929
instrumentation_end();
19271930
nmi_exit();
19281931
}

arch/x86/kernel/nmi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ static noinstr void default_do_nmi(struct pt_regs *regs)
330330
__this_cpu_write(last_nmi_rip, regs->ip);
331331

332332
instrumentation_begin();
333+
trace_hardirqs_off_prepare();
333334

334335
handled = nmi_handle(NMI_LOCAL, regs);
335336
__this_cpu_add(nmi_stats.normal, handled);
@@ -416,6 +417,8 @@ static noinstr void default_do_nmi(struct pt_regs *regs)
416417
unknown_nmi_error(reason, regs);
417418

418419
out:
420+
if (regs->flags & X86_EFLAGS_IF)
421+
trace_hardirqs_on_prepare();
419422
instrumentation_end();
420423
}
421424

arch/x86/kernel/traps.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,11 @@ DEFINE_IDTENTRY_RAW(exc_int3)
634634
} else {
635635
nmi_enter();
636636
instrumentation_begin();
637+
trace_hardirqs_off_prepare();
637638
if (!do_int3(regs))
638639
die("int3", regs, 0);
640+
if (regs->flags & X86_EFLAGS_IF)
641+
trace_hardirqs_on_prepare();
639642
instrumentation_end();
640643
nmi_exit();
641644
}
@@ -850,6 +853,10 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
850853
unsigned long dr6)
851854
{
852855
nmi_enter();
856+
instrumentation_begin();
857+
trace_hardirqs_off_prepare();
858+
instrumentation_end();
859+
853860
/*
854861
* The SDM says "The processor clears the BTF flag when it
855862
* generates a debug exception." Clear TIF_BLOCKSTEP to keep
@@ -871,6 +878,10 @@ static __always_inline void exc_debug_kernel(struct pt_regs *regs,
871878
if (dr6)
872879
handle_debug(regs, dr6, false);
873880

881+
instrumentation_begin();
882+
if (regs->flags & X86_EFLAGS_IF)
883+
trace_hardirqs_on_prepare();
884+
instrumentation_end();
874885
nmi_exit();
875886
}
876887

0 commit comments

Comments
 (0)