Skip to content

Commit 636a759

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
x86/idt: Move APIC gate initialization to tables
Replace the APIC/SMP vector gate initialization with the table based mechanism. Signed-off-by: Thomas Gleixner <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Brian Gerst <[email protected]> Cc: Denys Vlasenko <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent b70543a commit 636a759

File tree

3 files changed

+50
-68
lines changed

3 files changed

+50
-68
lines changed

arch/x86/include/asm/desc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,7 @@ static inline void load_current_idt(void)
507507
extern void idt_setup_early_handler(void);
508508
extern void idt_setup_early_traps(void);
509509
extern void idt_setup_traps(void);
510+
extern void idt_setup_apic_and_irq_gates(void);
510511

511512
#ifdef CONFIG_X86_64
512513
extern void idt_setup_early_pf(void);

arch/x86/kernel/idt.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,46 @@ static const __initdata struct idt_data def_idts[] = {
103103
#endif
104104
};
105105

106+
/*
107+
* The APIC and SMP idt entries
108+
*/
109+
static const __initdata struct idt_data apic_idts[] = {
110+
#ifdef CONFIG_SMP
111+
INTG(RESCHEDULE_VECTOR, reschedule_interrupt),
112+
INTG(CALL_FUNCTION_VECTOR, call_function_interrupt),
113+
INTG(CALL_FUNCTION_SINGLE_VECTOR, call_function_single_interrupt),
114+
INTG(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt),
115+
INTG(REBOOT_VECTOR, reboot_interrupt),
116+
#endif
117+
118+
#ifdef CONFIG_X86_THERMAL_VECTOR
119+
INTG(THERMAL_APIC_VECTOR, thermal_interrupt),
120+
#endif
121+
122+
#ifdef CONFIG_X86_MCE_THRESHOLD
123+
INTG(THRESHOLD_APIC_VECTOR, threshold_interrupt),
124+
#endif
125+
126+
#ifdef CONFIG_X86_MCE_AMD
127+
INTG(DEFERRED_ERROR_VECTOR, deferred_error_interrupt),
128+
#endif
129+
130+
#ifdef CONFIG_X86_LOCAL_APIC
131+
INTG(LOCAL_TIMER_VECTOR, apic_timer_interrupt),
132+
INTG(X86_PLATFORM_IPI_VECTOR, x86_platform_ipi),
133+
# ifdef CONFIG_HAVE_KVM
134+
INTG(POSTED_INTR_VECTOR, kvm_posted_intr_ipi),
135+
INTG(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi),
136+
INTG(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi),
137+
# endif
138+
# ifdef CONFIG_IRQ_WORK
139+
INTG(IRQ_WORK_VECTOR, irq_work_interrupt),
140+
# endif
141+
INTG(SPURIOUS_APIC_VECTOR, spurious_interrupt),
142+
INTG(ERROR_APIC_VECTOR, error_interrupt),
143+
#endif
144+
};
145+
106146
#ifdef CONFIG_X86_64
107147
/*
108148
* Early traps running on the DEFAULT_STACK because the other interrupt
@@ -241,6 +281,14 @@ void __init idt_setup_debugidt_traps(void)
241281
}
242282
#endif
243283

284+
/**
285+
* idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
286+
*/
287+
void __init idt_setup_apic_and_irq_gates(void)
288+
{
289+
idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts));
290+
}
291+
244292
/**
245293
* idt_setup_early_handler - Initializes the idt table with early handlers
246294
*/

arch/x86/kernel/irqinit.c

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -87,81 +87,14 @@ void __init init_IRQ(void)
8787
x86_init.irqs.intr_init();
8888
}
8989

90-
static void __init smp_intr_init(void)
91-
{
92-
#ifdef CONFIG_SMP
93-
/*
94-
* The reschedule interrupt is a CPU-to-CPU reschedule-helper
95-
* IPI, driven by wakeup.
96-
*/
97-
alloc_intr_gate(RESCHEDULE_VECTOR, reschedule_interrupt);
98-
99-
/* IPI for generic function call */
100-
alloc_intr_gate(CALL_FUNCTION_VECTOR, call_function_interrupt);
101-
102-
/* IPI for generic single function call */
103-
alloc_intr_gate(CALL_FUNCTION_SINGLE_VECTOR,
104-
call_function_single_interrupt);
105-
106-
/* Low priority IPI to cleanup after moving an irq */
107-
set_intr_gate(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt);
108-
set_bit(IRQ_MOVE_CLEANUP_VECTOR, used_vectors);
109-
110-
/* IPI used for rebooting/stopping */
111-
alloc_intr_gate(REBOOT_VECTOR, reboot_interrupt);
112-
#endif /* CONFIG_SMP */
113-
}
114-
115-
static void __init apic_intr_init(void)
116-
{
117-
smp_intr_init();
118-
119-
#ifdef CONFIG_X86_THERMAL_VECTOR
120-
alloc_intr_gate(THERMAL_APIC_VECTOR, thermal_interrupt);
121-
#endif
122-
#ifdef CONFIG_X86_MCE_THRESHOLD
123-
alloc_intr_gate(THRESHOLD_APIC_VECTOR, threshold_interrupt);
124-
#endif
125-
126-
#ifdef CONFIG_X86_MCE_AMD
127-
alloc_intr_gate(DEFERRED_ERROR_VECTOR, deferred_error_interrupt);
128-
#endif
129-
130-
#ifdef CONFIG_X86_LOCAL_APIC
131-
/* self generated IPI for local APIC timer */
132-
alloc_intr_gate(LOCAL_TIMER_VECTOR, apic_timer_interrupt);
133-
134-
/* IPI for X86 platform specific use */
135-
alloc_intr_gate(X86_PLATFORM_IPI_VECTOR, x86_platform_ipi);
136-
#ifdef CONFIG_HAVE_KVM
137-
/* IPI for KVM to deliver posted interrupt */
138-
alloc_intr_gate(POSTED_INTR_VECTOR, kvm_posted_intr_ipi);
139-
/* IPI for KVM to deliver interrupt to wake up tasks */
140-
alloc_intr_gate(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi);
141-
/* IPI for KVM to deliver nested posted interrupt */
142-
alloc_intr_gate(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi);
143-
#endif
144-
145-
/* IPI vectors for APIC spurious and error interrupts */
146-
alloc_intr_gate(SPURIOUS_APIC_VECTOR, spurious_interrupt);
147-
alloc_intr_gate(ERROR_APIC_VECTOR, error_interrupt);
148-
149-
/* IRQ work interrupts: */
150-
# ifdef CONFIG_IRQ_WORK
151-
alloc_intr_gate(IRQ_WORK_VECTOR, irq_work_interrupt);
152-
# endif
153-
154-
#endif
155-
}
156-
15790
void __init native_init_IRQ(void)
15891
{
15992
int i;
16093

16194
/* Execute any quirks before the call gates are initialised: */
16295
x86_init.irqs.pre_vector_init();
16396

164-
apic_intr_init();
97+
idt_setup_apic_and_irq_gates();
16598

16699
/*
167100
* Cover the whole vector space, no vector can escape

0 commit comments

Comments
 (0)