aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2017-08-28 02:47:53 -0400
committerIngo Molnar <mingo@kernel.org>2017-08-29 06:07:27 -0400
commitb70543a0b2b680f8953b6917a83b9203b20d7abd (patch)
tree7d6f1e47612eeac3826d5cd32f42b309104b08e9
parent90f6225fba0c732f3f5f9f5e265bdefa021ff12d (diff)
x86/idt: Move regular trap init to tables
Initialize the regular traps with 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.182128165@linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/desc.h1
-rw-r--r--arch/x86/kernel/idt.c51
-rw-r--r--arch/x86/kernel/traps.c41
3 files changed, 53 insertions, 40 deletions
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
index e62452777067..0a5735ef06cb 100644
--- a/arch/x86/include/asm/desc.h
+++ b/arch/x86/include/asm/desc.h
@@ -506,6 +506,7 @@ static inline void load_current_idt(void)
506 506
507extern void idt_setup_early_handler(void); 507extern void idt_setup_early_handler(void);
508extern void idt_setup_early_traps(void); 508extern void idt_setup_early_traps(void);
509extern void idt_setup_traps(void);
509 510
510#ifdef CONFIG_X86_64 511#ifdef CONFIG_X86_64
511extern void idt_setup_early_pf(void); 512extern void idt_setup_early_pf(void);
diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c
index a6326fd6698a..14d9eb29763c 100644
--- a/arch/x86/kernel/idt.c
+++ b/arch/x86/kernel/idt.c
@@ -60,6 +60,49 @@ static const __initdata struct idt_data early_idts[] = {
60#endif 60#endif
61}; 61};
62 62
63/*
64 * The default IDT entries which are set up in trap_init() before
65 * cpu_init() is invoked. Interrupt stacks cannot be used at that point and
66 * the traps which use them are reinitialized with IST after cpu_init() has
67 * set up TSS.
68 */
69static const __initdata struct idt_data def_idts[] = {
70 INTG(X86_TRAP_DE, divide_error),
71 INTG(X86_TRAP_NMI, nmi),
72 INTG(X86_TRAP_BR, bounds),
73 INTG(X86_TRAP_UD, invalid_op),
74 INTG(X86_TRAP_NM, device_not_available),
75 INTG(X86_TRAP_OLD_MF, coprocessor_segment_overrun),
76 INTG(X86_TRAP_TS, invalid_TSS),
77 INTG(X86_TRAP_NP, segment_not_present),
78 INTG(X86_TRAP_SS, stack_segment),
79 INTG(X86_TRAP_GP, general_protection),
80 INTG(X86_TRAP_SPURIOUS, spurious_interrupt_bug),
81 INTG(X86_TRAP_MF, coprocessor_error),
82 INTG(X86_TRAP_AC, alignment_check),
83 INTG(X86_TRAP_XF, simd_coprocessor_error),
84
85#ifdef CONFIG_X86_32
86 TSKG(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS),
87#else
88 INTG(X86_TRAP_DF, double_fault),
89#endif
90 INTG(X86_TRAP_DB, debug),
91 INTG(X86_TRAP_NMI, nmi),
92 INTG(X86_TRAP_BP, int3),
93
94#ifdef CONFIG_X86_MCE
95 INTG(X86_TRAP_MC, &machine_check),
96#endif
97
98 SYSG(X86_TRAP_OF, overflow),
99#if defined(CONFIG_IA32_EMULATION)
100 SYSG(IA32_SYSCALL_VECTOR, entry_INT80_compat),
101#elif defined(CONFIG_X86_32)
102 SYSG(IA32_SYSCALL_VECTOR, entry_INT80_32),
103#endif
104};
105
63#ifdef CONFIG_X86_64 106#ifdef CONFIG_X86_64
64/* 107/*
65 * Early traps running on the DEFAULT_STACK because the other interrupt 108 * Early traps running on the DEFAULT_STACK because the other interrupt
@@ -154,6 +197,14 @@ void __init idt_setup_early_traps(void)
154 load_idt(&idt_descr); 197 load_idt(&idt_descr);
155} 198}
156 199
200/**
201 * idt_setup_traps - Initialize the idt table with default traps
202 */
203void __init idt_setup_traps(void)
204{
205 idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts));
206}
207
157#ifdef CONFIG_X86_64 208#ifdef CONFIG_X86_64
158/** 209/**
159 * idt_setup_early_pf - Initialize the idt table with early pagefault handler 210 * idt_setup_early_pf - Initialize the idt table with early pagefault handler
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 293f5bddd761..34ea3651362e 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -925,46 +925,7 @@ dotraplinkage void do_iret_error(struct pt_regs *regs, long error_code)
925 925
926void __init trap_init(void) 926void __init trap_init(void)
927{ 927{
928 int i; 928 idt_setup_traps();
929
930 set_intr_gate(X86_TRAP_DE, divide_error);
931 set_intr_gate_ist(X86_TRAP_NMI, &nmi, NMI_STACK);
932 /* int4 can be called from all */
933 set_system_intr_gate(X86_TRAP_OF, &overflow);
934 set_intr_gate(X86_TRAP_BR, bounds);
935 set_intr_gate(X86_TRAP_UD, invalid_op);
936 set_intr_gate(X86_TRAP_NM, device_not_available);
937#ifdef CONFIG_X86_32
938 set_task_gate(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS);
939#else
940 set_intr_gate_ist(X86_TRAP_DF, &double_fault, DOUBLEFAULT_STACK);
941#endif
942 set_intr_gate(X86_TRAP_OLD_MF, coprocessor_segment_overrun);
943 set_intr_gate(X86_TRAP_TS, invalid_TSS);
944 set_intr_gate(X86_TRAP_NP, segment_not_present);
945 set_intr_gate(X86_TRAP_SS, stack_segment);
946 set_intr_gate(X86_TRAP_GP, general_protection);
947 set_intr_gate(X86_TRAP_SPURIOUS, spurious_interrupt_bug);
948 set_intr_gate(X86_TRAP_MF, coprocessor_error);
949 set_intr_gate(X86_TRAP_AC, alignment_check);
950#ifdef CONFIG_X86_MCE
951 set_intr_gate_ist(X86_TRAP_MC, &machine_check, MCE_STACK);
952#endif
953 set_intr_gate(X86_TRAP_XF, simd_coprocessor_error);
954
955 /* Reserve all the builtin and the syscall vector: */
956 for (i = 0; i < FIRST_EXTERNAL_VECTOR; i++)
957 set_bit(i, used_vectors);
958
959#ifdef CONFIG_IA32_EMULATION
960 set_system_intr_gate(IA32_SYSCALL_VECTOR, entry_INT80_compat);
961 set_bit(IA32_SYSCALL_VECTOR, used_vectors);
962#endif
963
964#ifdef CONFIG_X86_32
965 set_system_intr_gate(IA32_SYSCALL_VECTOR, entry_INT80_32);
966 set_bit(IA32_SYSCALL_VECTOR, used_vectors);
967#endif
968 929
969 /* 930 /*
970 * Set the IDT descriptor to a fixed read-only location, so that the 931 * Set the IDT descriptor to a fixed read-only location, so that the