Skip to content

Commit 90f6225

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/idt: Move IST stack based traps to table init
Initialize the IST based traps via a table. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/20170828064959.091328949@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 0a30908 commit 90f6225

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

arch/x86/include/asm/desc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,11 @@ extern void idt_setup_early_traps(void);
509509

510510
#ifdef CONFIG_X86_64
511511
extern void idt_setup_early_pf(void);
512+
extern void idt_setup_ist_traps(void);
512513
extern void idt_setup_debugidt_traps(void);
513514
#else
514515
static inline void idt_setup_early_pf(void) { }
516+
static inline void idt_setup_ist_traps(void) { }
515517
static inline void idt_setup_debugidt_traps(void) { }
516518
#endif
517519

arch/x86/kernel/idt.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ struct desc_ptr idt_descr __ro_after_init = {
9191
/* No need to be aligned, but done to keep all IDTs defined the same way. */
9292
gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss;
9393

94+
/*
95+
* The exceptions which use Interrupt stacks. They are setup after
96+
* cpu_init() when the TSS has been initialized.
97+
*/
98+
static const __initdata struct idt_data ist_idts[] = {
99+
ISTG(X86_TRAP_DB, debug, DEBUG_STACK),
100+
ISTG(X86_TRAP_NMI, nmi, NMI_STACK),
101+
ISTG(X86_TRAP_BP, int3, DEBUG_STACK),
102+
ISTG(X86_TRAP_DF, double_fault, DOUBLEFAULT_STACK),
103+
#ifdef CONFIG_X86_MCE
104+
ISTG(X86_TRAP_MC, &machine_check, MCE_STACK),
105+
#endif
106+
};
107+
94108
/*
95109
* Override for the debug_idt. Same as the default, but with interrupt
96110
* stack set to DEFAULT_STACK (0). Required for NMI trap handling.
@@ -157,6 +171,14 @@ void __init idt_setup_early_pf(void)
157171
ARRAY_SIZE(early_pf_idts));
158172
}
159173

174+
/**
175+
* idt_setup_ist_traps - Initialize the idt table with traps using IST
176+
*/
177+
void __init idt_setup_ist_traps(void)
178+
{
179+
idt_setup_from_table(idt_table, ist_idts, ARRAY_SIZE(ist_idts));
180+
}
181+
160182
/**
161183
* idt_setup_debugidt_traps - Initialize the debug idt table with debug traps
162184
*/

arch/x86/kernel/traps.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -979,14 +979,7 @@ void __init trap_init(void)
979979
*/
980980
cpu_init();
981981

982-
/*
983-
* X86_TRAP_DB and X86_TRAP_BP have been set
984-
* in early_trap_init(). However, ITS works only after
985-
* cpu_init() loads TSS. See comments in early_trap_init().
986-
*/
987-
set_intr_gate_ist(X86_TRAP_DB, &debug, DEBUG_STACK);
988-
/* int3 can be called from all */
989-
set_system_intr_gate_ist(X86_TRAP_BP, &int3, DEBUG_STACK);
982+
idt_setup_ist_traps();
990983

991984
x86_init.irqs.trap_init();
992985

0 commit comments

Comments
 (0)