xref: /linux/arch/x86/kernel/idt.c (revision 82c73e0a3868e580da56b559d4940c9be8359c06)
1*82c73e0aSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
2d8ed9d48SThomas Gleixner /*
3d8ed9d48SThomas Gleixner  * Interrupt descriptor table related code
4d8ed9d48SThomas Gleixner  */
5d8ed9d48SThomas Gleixner #include <linux/interrupt.h>
6d8ed9d48SThomas Gleixner 
73318e974SThomas Gleixner #include <asm/traps.h>
83318e974SThomas Gleixner #include <asm/proto.h>
9d8ed9d48SThomas Gleixner #include <asm/desc.h>
10447ae316SNicolai Stange #include <asm/hw_irq.h>
11d8ed9d48SThomas Gleixner 
123318e974SThomas Gleixner struct idt_data {
133318e974SThomas Gleixner 	unsigned int	vector;
143318e974SThomas Gleixner 	unsigned int	segment;
153318e974SThomas Gleixner 	struct idt_bits	bits;
163318e974SThomas Gleixner 	const void	*addr;
173318e974SThomas Gleixner };
183318e974SThomas Gleixner 
193318e974SThomas Gleixner #define DPL0		0x0
203318e974SThomas Gleixner #define DPL3		0x3
213318e974SThomas Gleixner 
223318e974SThomas Gleixner #define DEFAULT_STACK	0
233318e974SThomas Gleixner 
243318e974SThomas Gleixner #define G(_vector, _addr, _ist, _type, _dpl, _segment)	\
253318e974SThomas Gleixner 	{						\
263318e974SThomas Gleixner 		.vector		= _vector,		\
273318e974SThomas Gleixner 		.bits.ist	= _ist,			\
283318e974SThomas Gleixner 		.bits.type	= _type,		\
293318e974SThomas Gleixner 		.bits.dpl	= _dpl,			\
303318e974SThomas Gleixner 		.bits.p		= 1,			\
313318e974SThomas Gleixner 		.addr		= _addr,		\
323318e974SThomas Gleixner 		.segment	= _segment,		\
333318e974SThomas Gleixner 	}
343318e974SThomas Gleixner 
353318e974SThomas Gleixner /* Interrupt gate */
363318e974SThomas Gleixner #define INTG(_vector, _addr)				\
373318e974SThomas Gleixner 	G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL0, __KERNEL_CS)
383318e974SThomas Gleixner 
393318e974SThomas Gleixner /* System interrupt gate */
403318e974SThomas Gleixner #define SYSG(_vector, _addr)				\
413318e974SThomas Gleixner 	G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL3, __KERNEL_CS)
423318e974SThomas Gleixner 
438f34c5b5SThomas Gleixner /*
448f34c5b5SThomas Gleixner  * Interrupt gate with interrupt stack. The _ist index is the index in
458f34c5b5SThomas Gleixner  * the tss.ist[] array, but for the descriptor it needs to start at 1.
468f34c5b5SThomas Gleixner  */
473318e974SThomas Gleixner #define ISTG(_vector, _addr, _ist)			\
488f34c5b5SThomas Gleixner 	G(_vector, _addr, _ist + 1, GATE_INTERRUPT, DPL0, __KERNEL_CS)
493318e974SThomas Gleixner 
503318e974SThomas Gleixner /* Task gate */
513318e974SThomas Gleixner #define TSKG(_vector, _gdt)				\
523318e974SThomas Gleixner 	G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3)
533318e974SThomas Gleixner 
54433f8924SThomas Gleixner /*
55433f8924SThomas Gleixner  * Early traps running on the DEFAULT_STACK because the other interrupt
56433f8924SThomas Gleixner  * stacks work only after cpu_init().
57433f8924SThomas Gleixner  */
58327867faSAndi Kleen static const __initconst struct idt_data early_idts[] = {
59433f8924SThomas Gleixner 	INTG(X86_TRAP_DB,		debug),
60433f8924SThomas Gleixner 	SYSG(X86_TRAP_BP,		int3),
61433f8924SThomas Gleixner #ifdef CONFIG_X86_32
62433f8924SThomas Gleixner 	INTG(X86_TRAP_PF,		page_fault),
63433f8924SThomas Gleixner #endif
64433f8924SThomas Gleixner };
65433f8924SThomas Gleixner 
66b70543a0SThomas Gleixner /*
67b70543a0SThomas Gleixner  * The default IDT entries which are set up in trap_init() before
68b70543a0SThomas Gleixner  * cpu_init() is invoked. Interrupt stacks cannot be used at that point and
69b70543a0SThomas Gleixner  * the traps which use them are reinitialized with IST after cpu_init() has
70b70543a0SThomas Gleixner  * set up TSS.
71b70543a0SThomas Gleixner  */
72327867faSAndi Kleen static const __initconst struct idt_data def_idts[] = {
73b70543a0SThomas Gleixner 	INTG(X86_TRAP_DE,		divide_error),
74b70543a0SThomas Gleixner 	INTG(X86_TRAP_NMI,		nmi),
75b70543a0SThomas Gleixner 	INTG(X86_TRAP_BR,		bounds),
76b70543a0SThomas Gleixner 	INTG(X86_TRAP_UD,		invalid_op),
77b70543a0SThomas Gleixner 	INTG(X86_TRAP_NM,		device_not_available),
78b70543a0SThomas Gleixner 	INTG(X86_TRAP_OLD_MF,		coprocessor_segment_overrun),
79b70543a0SThomas Gleixner 	INTG(X86_TRAP_TS,		invalid_TSS),
80b70543a0SThomas Gleixner 	INTG(X86_TRAP_NP,		segment_not_present),
81b70543a0SThomas Gleixner 	INTG(X86_TRAP_SS,		stack_segment),
82b70543a0SThomas Gleixner 	INTG(X86_TRAP_GP,		general_protection),
83b70543a0SThomas Gleixner 	INTG(X86_TRAP_SPURIOUS,		spurious_interrupt_bug),
84b70543a0SThomas Gleixner 	INTG(X86_TRAP_MF,		coprocessor_error),
85b70543a0SThomas Gleixner 	INTG(X86_TRAP_AC,		alignment_check),
86b70543a0SThomas Gleixner 	INTG(X86_TRAP_XF,		simd_coprocessor_error),
87b70543a0SThomas Gleixner 
88b70543a0SThomas Gleixner #ifdef CONFIG_X86_32
89b70543a0SThomas Gleixner 	TSKG(X86_TRAP_DF,		GDT_ENTRY_DOUBLEFAULT_TSS),
90b70543a0SThomas Gleixner #else
91b70543a0SThomas Gleixner 	INTG(X86_TRAP_DF,		double_fault),
92b70543a0SThomas Gleixner #endif
93b70543a0SThomas Gleixner 	INTG(X86_TRAP_DB,		debug),
94b70543a0SThomas Gleixner 
95b70543a0SThomas Gleixner #ifdef CONFIG_X86_MCE
96b70543a0SThomas Gleixner 	INTG(X86_TRAP_MC,		&machine_check),
97b70543a0SThomas Gleixner #endif
98b70543a0SThomas Gleixner 
99b70543a0SThomas Gleixner 	SYSG(X86_TRAP_OF,		overflow),
100b70543a0SThomas Gleixner #if defined(CONFIG_IA32_EMULATION)
101b70543a0SThomas Gleixner 	SYSG(IA32_SYSCALL_VECTOR,	entry_INT80_compat),
102b70543a0SThomas Gleixner #elif defined(CONFIG_X86_32)
103b70543a0SThomas Gleixner 	SYSG(IA32_SYSCALL_VECTOR,	entry_INT80_32),
104b70543a0SThomas Gleixner #endif
105b70543a0SThomas Gleixner };
106b70543a0SThomas Gleixner 
107636a7598SThomas Gleixner /*
108636a7598SThomas Gleixner  * The APIC and SMP idt entries
109636a7598SThomas Gleixner  */
110327867faSAndi Kleen static const __initconst struct idt_data apic_idts[] = {
111636a7598SThomas Gleixner #ifdef CONFIG_SMP
112636a7598SThomas Gleixner 	INTG(RESCHEDULE_VECTOR,		reschedule_interrupt),
113636a7598SThomas Gleixner 	INTG(CALL_FUNCTION_VECTOR,	call_function_interrupt),
114636a7598SThomas Gleixner 	INTG(CALL_FUNCTION_SINGLE_VECTOR, call_function_single_interrupt),
115636a7598SThomas Gleixner 	INTG(IRQ_MOVE_CLEANUP_VECTOR,	irq_move_cleanup_interrupt),
116636a7598SThomas Gleixner 	INTG(REBOOT_VECTOR,		reboot_interrupt),
117636a7598SThomas Gleixner #endif
118636a7598SThomas Gleixner 
119636a7598SThomas Gleixner #ifdef CONFIG_X86_THERMAL_VECTOR
120636a7598SThomas Gleixner 	INTG(THERMAL_APIC_VECTOR,	thermal_interrupt),
121636a7598SThomas Gleixner #endif
122636a7598SThomas Gleixner 
123636a7598SThomas Gleixner #ifdef CONFIG_X86_MCE_THRESHOLD
124636a7598SThomas Gleixner 	INTG(THRESHOLD_APIC_VECTOR,	threshold_interrupt),
125636a7598SThomas Gleixner #endif
126636a7598SThomas Gleixner 
127636a7598SThomas Gleixner #ifdef CONFIG_X86_MCE_AMD
128636a7598SThomas Gleixner 	INTG(DEFERRED_ERROR_VECTOR,	deferred_error_interrupt),
129636a7598SThomas Gleixner #endif
130636a7598SThomas Gleixner 
131636a7598SThomas Gleixner #ifdef CONFIG_X86_LOCAL_APIC
132636a7598SThomas Gleixner 	INTG(LOCAL_TIMER_VECTOR,	apic_timer_interrupt),
133636a7598SThomas Gleixner 	INTG(X86_PLATFORM_IPI_VECTOR,	x86_platform_ipi),
134636a7598SThomas Gleixner # ifdef CONFIG_HAVE_KVM
135636a7598SThomas Gleixner 	INTG(POSTED_INTR_VECTOR,	kvm_posted_intr_ipi),
136636a7598SThomas Gleixner 	INTG(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi),
137636a7598SThomas Gleixner 	INTG(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi),
138636a7598SThomas Gleixner # endif
139636a7598SThomas Gleixner # ifdef CONFIG_IRQ_WORK
140636a7598SThomas Gleixner 	INTG(IRQ_WORK_VECTOR,		irq_work_interrupt),
141636a7598SThomas Gleixner # endif
142151ad17fSAndrew Banman #ifdef CONFIG_X86_UV
143151ad17fSAndrew Banman 	INTG(UV_BAU_MESSAGE,		uv_bau_message_intr1),
144151ad17fSAndrew Banman #endif
145636a7598SThomas Gleixner 	INTG(SPURIOUS_APIC_VECTOR,	spurious_interrupt),
146636a7598SThomas Gleixner 	INTG(ERROR_APIC_VECTOR,		error_interrupt),
147636a7598SThomas Gleixner #endif
148636a7598SThomas Gleixner };
149636a7598SThomas Gleixner 
150433f8924SThomas Gleixner #ifdef CONFIG_X86_64
151433f8924SThomas Gleixner /*
152433f8924SThomas Gleixner  * Early traps running on the DEFAULT_STACK because the other interrupt
153433f8924SThomas Gleixner  * stacks work only after cpu_init().
154433f8924SThomas Gleixner  */
155327867faSAndi Kleen static const __initconst struct idt_data early_pf_idts[] = {
156433f8924SThomas Gleixner 	INTG(X86_TRAP_PF,		page_fault),
157433f8924SThomas Gleixner };
1580a30908bSThomas Gleixner 
1590a30908bSThomas Gleixner /*
1600a30908bSThomas Gleixner  * Override for the debug_idt. Same as the default, but with interrupt
1610a30908bSThomas Gleixner  * stack set to DEFAULT_STACK (0). Required for NMI trap handling.
1620a30908bSThomas Gleixner  */
163327867faSAndi Kleen static const __initconst struct idt_data dbg_idts[] = {
1640a30908bSThomas Gleixner 	INTG(X86_TRAP_DB,	debug),
1650a30908bSThomas Gleixner };
166433f8924SThomas Gleixner #endif
167433f8924SThomas Gleixner 
168d8ed9d48SThomas Gleixner /* Must be page-aligned because the real IDT is used in a fixmap. */
169d8ed9d48SThomas Gleixner gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss;
170d8ed9d48SThomas Gleixner 
17116bc18d8SThomas Gleixner struct desc_ptr idt_descr __ro_after_init = {
17216bc18d8SThomas Gleixner 	.size		= (IDT_ENTRIES * 2 * sizeof(unsigned long)) - 1,
17316bc18d8SThomas Gleixner 	.address	= (unsigned long) idt_table,
17416bc18d8SThomas Gleixner };
17516bc18d8SThomas Gleixner 
176d8ed9d48SThomas Gleixner #ifdef CONFIG_X86_64
177d8ed9d48SThomas Gleixner /* No need to be aligned, but done to keep all IDTs defined the same way. */
178d8ed9d48SThomas Gleixner gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss;
179d8ed9d48SThomas Gleixner 
1800a30908bSThomas Gleixner /*
18190f6225fSThomas Gleixner  * The exceptions which use Interrupt stacks. They are setup after
18290f6225fSThomas Gleixner  * cpu_init() when the TSS has been initialized.
18390f6225fSThomas Gleixner  */
184327867faSAndi Kleen static const __initconst struct idt_data ist_idts[] = {
18532074269SThomas Gleixner 	ISTG(X86_TRAP_DB,	debug,		IST_INDEX_DB),
18632074269SThomas Gleixner 	ISTG(X86_TRAP_NMI,	nmi,		IST_INDEX_NMI),
18732074269SThomas Gleixner 	ISTG(X86_TRAP_DF,	double_fault,	IST_INDEX_DF),
18890f6225fSThomas Gleixner #ifdef CONFIG_X86_MCE
18932074269SThomas Gleixner 	ISTG(X86_TRAP_MC,	&machine_check,	IST_INDEX_MCE),
19090f6225fSThomas Gleixner #endif
19190f6225fSThomas Gleixner };
19290f6225fSThomas Gleixner 
19390f6225fSThomas Gleixner /*
1940a30908bSThomas Gleixner  * Override for the debug_idt. Same as the default, but with interrupt
1950a30908bSThomas Gleixner  * stack set to DEFAULT_STACK (0). Required for NMI trap handling.
1960a30908bSThomas Gleixner  */
197d8ed9d48SThomas Gleixner const struct desc_ptr debug_idt_descr = {
198d8ed9d48SThomas Gleixner 	.size		= IDT_ENTRIES * 16 - 1,
199d8ed9d48SThomas Gleixner 	.address	= (unsigned long) debug_idt_table,
200d8ed9d48SThomas Gleixner };
201d8ed9d48SThomas Gleixner #endif
202e802a51eSThomas Gleixner 
2033318e974SThomas Gleixner static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d)
2043318e974SThomas Gleixner {
2053318e974SThomas Gleixner 	unsigned long addr = (unsigned long) d->addr;
2063318e974SThomas Gleixner 
2073318e974SThomas Gleixner 	gate->offset_low	= (u16) addr;
2083318e974SThomas Gleixner 	gate->segment		= (u16) d->segment;
2093318e974SThomas Gleixner 	gate->bits		= d->bits;
2103318e974SThomas Gleixner 	gate->offset_middle	= (u16) (addr >> 16);
2113318e974SThomas Gleixner #ifdef CONFIG_X86_64
2123318e974SThomas Gleixner 	gate->offset_high	= (u32) (addr >> 32);
2133318e974SThomas Gleixner 	gate->reserved		= 0;
2143318e974SThomas Gleixner #endif
2153318e974SThomas Gleixner }
2163318e974SThomas Gleixner 
217db18da78SThomas Gleixner static void
218db18da78SThomas Gleixner idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys)
2193318e974SThomas Gleixner {
2203318e974SThomas Gleixner 	gate_desc desc;
2213318e974SThomas Gleixner 
2223318e974SThomas Gleixner 	for (; size > 0; t++, size--) {
2233318e974SThomas Gleixner 		idt_init_desc(&desc, t);
2243318e974SThomas Gleixner 		write_idt_entry(idt, t->vector, &desc);
225db18da78SThomas Gleixner 		if (sys)
2267854f822SThomas Gleixner 			set_bit(t->vector, system_vectors);
2273318e974SThomas Gleixner 	}
2283318e974SThomas Gleixner }
2293318e974SThomas Gleixner 
230facaa3e3SThomas Gleixner static void set_intr_gate(unsigned int n, const void *addr)
231facaa3e3SThomas Gleixner {
232facaa3e3SThomas Gleixner 	struct idt_data data;
233facaa3e3SThomas Gleixner 
234facaa3e3SThomas Gleixner 	BUG_ON(n > 0xFF);
235facaa3e3SThomas Gleixner 
236facaa3e3SThomas Gleixner 	memset(&data, 0, sizeof(data));
237facaa3e3SThomas Gleixner 	data.vector	= n;
238facaa3e3SThomas Gleixner 	data.addr	= addr;
239facaa3e3SThomas Gleixner 	data.segment	= __KERNEL_CS;
240facaa3e3SThomas Gleixner 	data.bits.type	= GATE_INTERRUPT;
241facaa3e3SThomas Gleixner 	data.bits.p	= 1;
242facaa3e3SThomas Gleixner 
243facaa3e3SThomas Gleixner 	idt_setup_from_table(idt_table, &data, 1, false);
244facaa3e3SThomas Gleixner }
245facaa3e3SThomas Gleixner 
246e802a51eSThomas Gleixner /**
247433f8924SThomas Gleixner  * idt_setup_early_traps - Initialize the idt table with early traps
248433f8924SThomas Gleixner  *
249433f8924SThomas Gleixner  * On X8664 these traps do not use interrupt stacks as they can't work
250433f8924SThomas Gleixner  * before cpu_init() is invoked and sets up TSS. The IST variants are
251433f8924SThomas Gleixner  * installed after that.
252433f8924SThomas Gleixner  */
253433f8924SThomas Gleixner void __init idt_setup_early_traps(void)
254433f8924SThomas Gleixner {
255db18da78SThomas Gleixner 	idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts),
256db18da78SThomas Gleixner 			     true);
257433f8924SThomas Gleixner 	load_idt(&idt_descr);
258433f8924SThomas Gleixner }
259433f8924SThomas Gleixner 
260b70543a0SThomas Gleixner /**
261b70543a0SThomas Gleixner  * idt_setup_traps - Initialize the idt table with default traps
262b70543a0SThomas Gleixner  */
263b70543a0SThomas Gleixner void __init idt_setup_traps(void)
264b70543a0SThomas Gleixner {
265db18da78SThomas Gleixner 	idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts), true);
266b70543a0SThomas Gleixner }
267b70543a0SThomas Gleixner 
268433f8924SThomas Gleixner #ifdef CONFIG_X86_64
269433f8924SThomas Gleixner /**
270433f8924SThomas Gleixner  * idt_setup_early_pf - Initialize the idt table with early pagefault handler
271433f8924SThomas Gleixner  *
272433f8924SThomas Gleixner  * On X8664 this does not use interrupt stacks as they can't work before
273433f8924SThomas Gleixner  * cpu_init() is invoked and sets up TSS. The IST variant is installed
274433f8924SThomas Gleixner  * after that.
275433f8924SThomas Gleixner  *
276433f8924SThomas Gleixner  * FIXME: Why is 32bit and 64bit installing the PF handler at different
277433f8924SThomas Gleixner  * places in the early setup code?
278433f8924SThomas Gleixner  */
279433f8924SThomas Gleixner void __init idt_setup_early_pf(void)
280433f8924SThomas Gleixner {
281433f8924SThomas Gleixner 	idt_setup_from_table(idt_table, early_pf_idts,
282db18da78SThomas Gleixner 			     ARRAY_SIZE(early_pf_idts), true);
283433f8924SThomas Gleixner }
2840a30908bSThomas Gleixner 
2850a30908bSThomas Gleixner /**
28690f6225fSThomas Gleixner  * idt_setup_ist_traps - Initialize the idt table with traps using IST
28790f6225fSThomas Gleixner  */
28890f6225fSThomas Gleixner void __init idt_setup_ist_traps(void)
28990f6225fSThomas Gleixner {
290db18da78SThomas Gleixner 	idt_setup_from_table(idt_table, ist_idts, ARRAY_SIZE(ist_idts), true);
29190f6225fSThomas Gleixner }
29290f6225fSThomas Gleixner 
29390f6225fSThomas Gleixner /**
2940a30908bSThomas Gleixner  * idt_setup_debugidt_traps - Initialize the debug idt table with debug traps
2950a30908bSThomas Gleixner  */
2960a30908bSThomas Gleixner void __init idt_setup_debugidt_traps(void)
2970a30908bSThomas Gleixner {
2980a30908bSThomas Gleixner 	memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16);
2990a30908bSThomas Gleixner 
300db18da78SThomas Gleixner 	idt_setup_from_table(debug_idt_table, dbg_idts, ARRAY_SIZE(dbg_idts), false);
3010a30908bSThomas Gleixner }
302433f8924SThomas Gleixner #endif
303433f8924SThomas Gleixner 
304433f8924SThomas Gleixner /**
305636a7598SThomas Gleixner  * idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
306636a7598SThomas Gleixner  */
307636a7598SThomas Gleixner void __init idt_setup_apic_and_irq_gates(void)
308636a7598SThomas Gleixner {
309dc20b2d5SThomas Gleixner 	int i = FIRST_EXTERNAL_VECTOR;
310dc20b2d5SThomas Gleixner 	void *entry;
311dc20b2d5SThomas Gleixner 
312db18da78SThomas Gleixner 	idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true);
313dc20b2d5SThomas Gleixner 
3147854f822SThomas Gleixner 	for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) {
315dc20b2d5SThomas Gleixner 		entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR);
316dc20b2d5SThomas Gleixner 		set_intr_gate(i, entry);
317dc20b2d5SThomas Gleixner 	}
318dc20b2d5SThomas Gleixner 
319dc20b2d5SThomas Gleixner #ifdef CONFIG_X86_LOCAL_APIC
32033662812SDou Liyang 	for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
3217854f822SThomas Gleixner 		set_bit(i, system_vectors);
322dc20b2d5SThomas Gleixner 		set_intr_gate(i, spurious_interrupt);
323dc20b2d5SThomas Gleixner 	}
32433662812SDou Liyang #endif
325636a7598SThomas Gleixner }
326636a7598SThomas Gleixner 
327636a7598SThomas Gleixner /**
328588787fdSThomas Gleixner  * idt_setup_early_handler - Initializes the idt table with early handlers
329588787fdSThomas Gleixner  */
330588787fdSThomas Gleixner void __init idt_setup_early_handler(void)
331588787fdSThomas Gleixner {
332588787fdSThomas Gleixner 	int i;
333588787fdSThomas Gleixner 
334588787fdSThomas Gleixner 	for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
335588787fdSThomas Gleixner 		set_intr_gate(i, early_idt_handler_array[i]);
33687e81786SThomas Gleixner #ifdef CONFIG_X86_32
33787e81786SThomas Gleixner 	for ( ; i < NR_VECTORS; i++)
33887e81786SThomas Gleixner 		set_intr_gate(i, early_ignore_irq);
33987e81786SThomas Gleixner #endif
340588787fdSThomas Gleixner 	load_idt(&idt_descr);
341588787fdSThomas Gleixner }
342588787fdSThomas Gleixner 
343588787fdSThomas Gleixner /**
344e802a51eSThomas Gleixner  * idt_invalidate - Invalidate interrupt descriptor table
345e802a51eSThomas Gleixner  * @addr:	The virtual address of the 'invalid' IDT
346e802a51eSThomas Gleixner  */
347e802a51eSThomas Gleixner void idt_invalidate(void *addr)
348e802a51eSThomas Gleixner {
349e802a51eSThomas Gleixner 	struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 };
350e802a51eSThomas Gleixner 
351e802a51eSThomas Gleixner 	load_idt(&idt);
352e802a51eSThomas Gleixner }
353db18da78SThomas Gleixner 
354facaa3e3SThomas Gleixner void __init update_intr_gate(unsigned int n, const void *addr)
355db18da78SThomas Gleixner {
3567854f822SThomas Gleixner 	if (WARN_ON_ONCE(!test_bit(n, system_vectors)))
357facaa3e3SThomas Gleixner 		return;
358facaa3e3SThomas Gleixner 	set_intr_gate(n, addr);
359db18da78SThomas Gleixner }
360db18da78SThomas Gleixner 
361db18da78SThomas Gleixner void alloc_intr_gate(unsigned int n, const void *addr)
362db18da78SThomas Gleixner {
3634447ac11SThomas Gleixner 	BUG_ON(n < FIRST_SYSTEM_VECTOR);
3647854f822SThomas Gleixner 	if (!test_and_set_bit(n, system_vectors))
365db18da78SThomas Gleixner 		set_intr_gate(n, addr);
366db18da78SThomas Gleixner }
367