Commit 0a30908b authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Ingo Molnar

x86/idt: Move debug stack init to table based

Add the debug_idt init table and make use of it.
Signed-off-by: default avatarThomas 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.006502252@linutronix.deSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 433f8924
...@@ -509,8 +509,10 @@ extern void idt_setup_early_traps(void); ...@@ -509,8 +509,10 @@ extern void idt_setup_early_traps(void);
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
extern void idt_setup_early_pf(void); extern void idt_setup_early_pf(void);
extern void idt_setup_debugidt_traps(void);
#else #else
static inline void idt_setup_early_pf(void) { } static inline void idt_setup_early_pf(void) { }
static inline void idt_setup_debugidt_traps(void) { }
#endif #endif
extern void idt_invalidate(void *addr); extern void idt_invalidate(void *addr);
......
...@@ -68,6 +68,15 @@ static const __initdata struct idt_data early_idts[] = { ...@@ -68,6 +68,15 @@ static const __initdata struct idt_data early_idts[] = {
static const __initdata struct idt_data early_pf_idts[] = { static const __initdata struct idt_data early_pf_idts[] = {
INTG(X86_TRAP_PF, page_fault), INTG(X86_TRAP_PF, page_fault),
}; };
/*
* Override for the debug_idt. Same as the default, but with interrupt
* stack set to DEFAULT_STACK (0). Required for NMI trap handling.
*/
static const __initdata struct idt_data dbg_idts[] = {
INTG(X86_TRAP_DB, debug),
INTG(X86_TRAP_BP, int3),
};
#endif #endif
/* Must be page-aligned because the real IDT is used in a fixmap. */ /* Must be page-aligned because the real IDT is used in a fixmap. */
...@@ -82,6 +91,10 @@ struct desc_ptr idt_descr __ro_after_init = { ...@@ -82,6 +91,10 @@ struct desc_ptr idt_descr __ro_after_init = {
/* No need to be aligned, but done to keep all IDTs defined the same way. */ /* No need to be aligned, but done to keep all IDTs defined the same way. */
gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss; gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss;
/*
* Override for the debug_idt. Same as the default, but with interrupt
* stack set to DEFAULT_STACK (0). Required for NMI trap handling.
*/
const struct desc_ptr debug_idt_descr = { const struct desc_ptr debug_idt_descr = {
.size = IDT_ENTRIES * 16 - 1, .size = IDT_ENTRIES * 16 - 1,
.address = (unsigned long) debug_idt_table, .address = (unsigned long) debug_idt_table,
...@@ -143,6 +156,16 @@ void __init idt_setup_early_pf(void) ...@@ -143,6 +156,16 @@ void __init idt_setup_early_pf(void)
idt_setup_from_table(idt_table, early_pf_idts, idt_setup_from_table(idt_table, early_pf_idts,
ARRAY_SIZE(early_pf_idts)); ARRAY_SIZE(early_pf_idts));
} }
/**
* idt_setup_debugidt_traps - Initialize the debug idt table with debug traps
*/
void __init idt_setup_debugidt_traps(void)
{
memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16);
idt_setup_from_table(debug_idt_table, dbg_idts, ARRAY_SIZE(dbg_idts));
}
#endif #endif
/** /**
......
...@@ -990,9 +990,5 @@ void __init trap_init(void) ...@@ -990,9 +990,5 @@ void __init trap_init(void)
x86_init.irqs.trap_init(); x86_init.irqs.trap_init();
#ifdef CONFIG_X86_64 idt_setup_debugidt_traps();
memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16);
set_nmi_gate(X86_TRAP_DB, &debug);
set_nmi_gate(X86_TRAP_BP, &int3);
#endif
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment