182c73e0aSThomas 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
700229a54SThomas Gleixner #include <asm/cpu_entry_area.h>
83e77abdaSThomas Gleixner #include <asm/set_memory.h>
93318e974SThomas Gleixner #include <asm/traps.h>
103318e974SThomas Gleixner #include <asm/proto.h>
11d8ed9d48SThomas Gleixner #include <asm/desc.h>
12447ae316SNicolai Stange #include <asm/hw_irq.h>
1361382281SNikolay Borisov #include <asm/ia32.h>
148f93402bSPeter Zijlstra #include <asm/idtentry.h>
15d8ed9d48SThomas Gleixner
163318e974SThomas Gleixner #define DPL0 0x0
173318e974SThomas Gleixner #define DPL3 0x3
183318e974SThomas Gleixner
193318e974SThomas Gleixner #define DEFAULT_STACK 0
203318e974SThomas Gleixner
213318e974SThomas Gleixner #define G(_vector, _addr, _ist, _type, _dpl, _segment) \
223318e974SThomas Gleixner { \
233318e974SThomas Gleixner .vector = _vector, \
243318e974SThomas Gleixner .bits.ist = _ist, \
253318e974SThomas Gleixner .bits.type = _type, \
263318e974SThomas Gleixner .bits.dpl = _dpl, \
273318e974SThomas Gleixner .bits.p = 1, \
283318e974SThomas Gleixner .addr = _addr, \
293318e974SThomas Gleixner .segment = _segment, \
303318e974SThomas Gleixner }
313318e974SThomas Gleixner
323318e974SThomas Gleixner /* Interrupt gate */
333318e974SThomas Gleixner #define INTG(_vector, _addr) \
343318e974SThomas Gleixner G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL0, __KERNEL_CS)
353318e974SThomas Gleixner
363318e974SThomas Gleixner /* System interrupt gate */
373318e974SThomas Gleixner #define SYSG(_vector, _addr) \
383318e974SThomas Gleixner G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL3, __KERNEL_CS)
393318e974SThomas Gleixner
401dcc917aSThomas Gleixner #ifdef CONFIG_X86_64
418f34c5b5SThomas Gleixner /*
428f34c5b5SThomas Gleixner * Interrupt gate with interrupt stack. The _ist index is the index in
438f34c5b5SThomas Gleixner * the tss.ist[] array, but for the descriptor it needs to start at 1.
448f34c5b5SThomas Gleixner */
453318e974SThomas Gleixner #define ISTG(_vector, _addr, _ist) \
468f34c5b5SThomas Gleixner G(_vector, _addr, _ist + 1, GATE_INTERRUPT, DPL0, __KERNEL_CS)
471dcc917aSThomas Gleixner #else
481dcc917aSThomas Gleixner #define ISTG(_vector, _addr, _ist) INTG(_vector, _addr)
491dcc917aSThomas Gleixner #endif
503318e974SThomas Gleixner
513318e974SThomas Gleixner /* Task gate */
523318e974SThomas Gleixner #define TSKG(_vector, _gdt) \
533318e974SThomas Gleixner G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3)
543318e974SThomas Gleixner
555a2bafcaSThomas Gleixner #define IDT_TABLE_SIZE (IDT_ENTRIES * sizeof(gate_desc))
5606184325SVitaly Kuznetsov
5706184325SVitaly Kuznetsov static bool idt_setup_done __initdata;
5806184325SVitaly Kuznetsov
59433f8924SThomas Gleixner /*
60433f8924SThomas Gleixner * Early traps running on the DEFAULT_STACK because the other interrupt
61433f8924SThomas Gleixner * stacks work only after cpu_init().
62433f8924SThomas Gleixner */
63327867faSAndi Kleen static const __initconst struct idt_data early_idts[] = {
642bbc68f8SThomas Gleixner INTG(X86_TRAP_DB, asm_exc_debug),
658edd7e37SThomas Gleixner SYSG(X86_TRAP_BP, asm_exc_int3),
6694438af4SThomas Gleixner
67433f8924SThomas Gleixner #ifdef CONFIG_X86_32
6894438af4SThomas Gleixner /*
6994438af4SThomas Gleixner * Not possible on 64-bit. See idt_setup_early_pf() for details.
7094438af4SThomas Gleixner */
7191eeafeaSThomas Gleixner INTG(X86_TRAP_PF, asm_exc_page_fault),
72433f8924SThomas Gleixner #endif
739a22bf6dSKirill A. Shutemov #ifdef CONFIG_INTEL_TDX_GUEST
749a22bf6dSKirill A. Shutemov INTG(X86_TRAP_VE, asm_exc_virtualization_exception),
759a22bf6dSKirill A. Shutemov #endif
76433f8924SThomas Gleixner };
77433f8924SThomas Gleixner
78b70543a0SThomas Gleixner /*
79b70543a0SThomas Gleixner * The default IDT entries which are set up in trap_init() before
80b70543a0SThomas Gleixner * cpu_init() is invoked. Interrupt stacks cannot be used at that point and
81b70543a0SThomas Gleixner * the traps which use them are reinitialized with IST after cpu_init() has
82b70543a0SThomas Gleixner * set up TSS.
83b70543a0SThomas Gleixner */
84327867faSAndi Kleen static const __initconst struct idt_data def_idts[] = {
859d06c402SThomas Gleixner INTG(X86_TRAP_DE, asm_exc_divide_error),
861dcc917aSThomas Gleixner ISTG(X86_TRAP_NMI, asm_exc_nmi, IST_INDEX_NMI),
8758d9c81fSThomas Gleixner INTG(X86_TRAP_BR, asm_exc_bounds),
8849893c5cSThomas Gleixner INTG(X86_TRAP_UD, asm_exc_invalid_op),
89866ae2ccSThomas Gleixner INTG(X86_TRAP_NM, asm_exc_device_not_available),
90f95658fdSThomas Gleixner INTG(X86_TRAP_OLD_MF, asm_exc_coproc_segment_overrun),
9197b3d290SThomas Gleixner INTG(X86_TRAP_TS, asm_exc_invalid_tss),
9299a3fb8dSThomas Gleixner INTG(X86_TRAP_NP, asm_exc_segment_not_present),
93fd9689bfSThomas Gleixner INTG(X86_TRAP_SS, asm_exc_stack_segment),
94be4c11afSThomas Gleixner INTG(X86_TRAP_GP, asm_exc_general_protection),
95dad7106fSThomas Gleixner INTG(X86_TRAP_SPURIOUS, asm_exc_spurious_interrupt_bug),
9614a8bd2aSThomas Gleixner INTG(X86_TRAP_MF, asm_exc_coprocessor_error),
97436608bbSThomas Gleixner INTG(X86_TRAP_AC, asm_exc_alignment_check),
9848227e21SThomas Gleixner INTG(X86_TRAP_XF, asm_exc_simd_coprocessor_error),
99b70543a0SThomas Gleixner
100b70543a0SThomas Gleixner #ifdef CONFIG_X86_32
101b70543a0SThomas Gleixner TSKG(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS),
102b70543a0SThomas Gleixner #else
1031dcc917aSThomas Gleixner ISTG(X86_TRAP_DF, asm_exc_double_fault, IST_INDEX_DF),
104b70543a0SThomas Gleixner #endif
1051dcc917aSThomas Gleixner ISTG(X86_TRAP_DB, asm_exc_debug, IST_INDEX_DB),
106b70543a0SThomas Gleixner
107b70543a0SThomas Gleixner #ifdef CONFIG_X86_MCE
1081dcc917aSThomas Gleixner ISTG(X86_TRAP_MC, asm_exc_machine_check, IST_INDEX_MCE),
1091dcc917aSThomas Gleixner #endif
1101dcc917aSThomas Gleixner
111a5f6c2acSRick Edgecombe #ifdef CONFIG_X86_CET
112991625f3SPeter Zijlstra INTG(X86_TRAP_CP, asm_exc_control_protection),
113991625f3SPeter Zijlstra #endif
114991625f3SPeter Zijlstra
1151dcc917aSThomas Gleixner #ifdef CONFIG_AMD_MEM_ENCRYPT
1161dcc917aSThomas Gleixner ISTG(X86_TRAP_VC, asm_exc_vmm_communication, IST_INDEX_VC),
117b70543a0SThomas Gleixner #endif
118b70543a0SThomas Gleixner
1194b6b9111SThomas Gleixner SYSG(X86_TRAP_OF, asm_exc_overflow),
12061382281SNikolay Borisov };
12161382281SNikolay Borisov
12261382281SNikolay Borisov static const struct idt_data ia32_idt[] __initconst = {
123b70543a0SThomas Gleixner #if defined(CONFIG_IA32_EMULATION)
124be5341ebSThomas Gleixner SYSG(IA32_SYSCALL_VECTOR, asm_int80_emulation),
125b70543a0SThomas Gleixner #elif defined(CONFIG_X86_32)
126b70543a0SThomas Gleixner SYSG(IA32_SYSCALL_VECTOR, entry_INT80_32),
127b70543a0SThomas Gleixner #endif
128b70543a0SThomas Gleixner };
129b70543a0SThomas Gleixner
130636a7598SThomas Gleixner /*
131636a7598SThomas Gleixner * The APIC and SMP idt entries
132636a7598SThomas Gleixner */
133327867faSAndi Kleen static const __initconst struct idt_data apic_idts[] = {
134636a7598SThomas Gleixner #ifdef CONFIG_SMP
13513cad985SThomas Gleixner INTG(RESCHEDULE_VECTOR, asm_sysvec_reschedule_ipi),
136582f9191SThomas Gleixner INTG(CALL_FUNCTION_VECTOR, asm_sysvec_call_function),
137582f9191SThomas Gleixner INTG(CALL_FUNCTION_SINGLE_VECTOR, asm_sysvec_call_function_single),
138582f9191SThomas Gleixner INTG(REBOOT_VECTOR, asm_sysvec_reboot),
139636a7598SThomas Gleixner #endif
140636a7598SThomas Gleixner
141636a7598SThomas Gleixner #ifdef CONFIG_X86_THERMAL_VECTOR
142720909a7SThomas Gleixner INTG(THERMAL_APIC_VECTOR, asm_sysvec_thermal),
143636a7598SThomas Gleixner #endif
144636a7598SThomas Gleixner
145636a7598SThomas Gleixner #ifdef CONFIG_X86_MCE_THRESHOLD
146720909a7SThomas Gleixner INTG(THRESHOLD_APIC_VECTOR, asm_sysvec_threshold),
147636a7598SThomas Gleixner #endif
148636a7598SThomas Gleixner
149636a7598SThomas Gleixner #ifdef CONFIG_X86_MCE_AMD
150720909a7SThomas Gleixner INTG(DEFERRED_ERROR_VECTOR, asm_sysvec_deferred_error),
151636a7598SThomas Gleixner #endif
152636a7598SThomas Gleixner
153636a7598SThomas Gleixner #ifdef CONFIG_X86_LOCAL_APIC
154db0338eeSThomas Gleixner INTG(LOCAL_TIMER_VECTOR, asm_sysvec_apic_timer_interrupt),
155db0338eeSThomas Gleixner INTG(X86_PLATFORM_IPI_VECTOR, asm_sysvec_x86_platform_ipi),
156dcf0926eSPaolo Bonzini # if IS_ENABLED(CONFIG_KVM)
1579c3b1f49SThomas Gleixner INTG(POSTED_INTR_VECTOR, asm_sysvec_kvm_posted_intr_ipi),
1589c3b1f49SThomas Gleixner INTG(POSTED_INTR_WAKEUP_VECTOR, asm_sysvec_kvm_posted_intr_wakeup_ipi),
1599c3b1f49SThomas Gleixner INTG(POSTED_INTR_NESTED_VECTOR, asm_sysvec_kvm_posted_intr_nested_ipi),
160636a7598SThomas Gleixner # endif
161636a7598SThomas Gleixner # ifdef CONFIG_IRQ_WORK
162720909a7SThomas Gleixner INTG(IRQ_WORK_VECTOR, asm_sysvec_irq_work),
163636a7598SThomas Gleixner # endif
164db0338eeSThomas Gleixner INTG(SPURIOUS_APIC_VECTOR, asm_sysvec_spurious_apic_interrupt),
165db0338eeSThomas Gleixner INTG(ERROR_APIC_VECTOR, asm_sysvec_error_interrupt),
166*1b03d82bSJacob Pan # ifdef CONFIG_X86_POSTED_MSI
167*1b03d82bSJacob Pan INTG(POSTED_MSI_NOTIFICATION_VECTOR, asm_sysvec_posted_msi_notification),
168*1b03d82bSJacob Pan # endif
169636a7598SThomas Gleixner #endif
170636a7598SThomas Gleixner };
171636a7598SThomas Gleixner
1723e77abdaSThomas Gleixner /* Must be page-aligned because the real IDT is used in the cpu entry area */
1733e77abdaSThomas Gleixner static gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss;
174d8ed9d48SThomas Gleixner
175286d966bSJason Andryuk static struct desc_ptr idt_descr __ro_after_init = {
1765a2bafcaSThomas Gleixner .size = IDT_TABLE_SIZE - 1,
17716bc18d8SThomas Gleixner .address = (unsigned long) idt_table,
17816bc18d8SThomas Gleixner };
17916bc18d8SThomas Gleixner
load_current_idt(void)1803e77abdaSThomas Gleixner void load_current_idt(void)
1813e77abdaSThomas Gleixner {
1823e77abdaSThomas Gleixner lockdep_assert_irqs_disabled();
1833e77abdaSThomas Gleixner load_idt(&idt_descr);
1843e77abdaSThomas Gleixner }
1853e77abdaSThomas Gleixner
1863e77abdaSThomas Gleixner #ifdef CONFIG_X86_F00F_BUG
idt_is_f00f_address(unsigned long address)1873e77abdaSThomas Gleixner bool idt_is_f00f_address(unsigned long address)
1883e77abdaSThomas Gleixner {
1893e77abdaSThomas Gleixner return ((address - idt_descr.address) >> 3) == 6;
1903e77abdaSThomas Gleixner }
191d8ed9d48SThomas Gleixner #endif
192e802a51eSThomas Gleixner
193bdf5bde8SThomas Gleixner static __init void
idt_setup_from_table(gate_desc * idt,const struct idt_data * t,int size,bool sys)194db18da78SThomas Gleixner idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys)
1953318e974SThomas Gleixner {
1963318e974SThomas Gleixner gate_desc desc;
1973318e974SThomas Gleixner
1983318e974SThomas Gleixner for (; size > 0; t++, size--) {
1993318e974SThomas Gleixner idt_init_desc(&desc, t);
2003318e974SThomas Gleixner write_idt_entry(idt, t->vector, &desc);
201db18da78SThomas Gleixner if (sys)
2027854f822SThomas Gleixner set_bit(t->vector, system_vectors);
2033318e974SThomas Gleixner }
2043318e974SThomas Gleixner }
2053318e974SThomas Gleixner
set_intr_gate(unsigned int n,const void * addr)206bdf5bde8SThomas Gleixner static __init void set_intr_gate(unsigned int n, const void *addr)
207facaa3e3SThomas Gleixner {
208facaa3e3SThomas Gleixner struct idt_data data;
209facaa3e3SThomas Gleixner
2104bed2266SJoerg Roedel init_idt_data(&data, n, addr);
211facaa3e3SThomas Gleixner
212facaa3e3SThomas Gleixner idt_setup_from_table(idt_table, &data, 1, false);
213facaa3e3SThomas Gleixner }
214facaa3e3SThomas Gleixner
215e802a51eSThomas Gleixner /**
216433f8924SThomas Gleixner * idt_setup_early_traps - Initialize the idt table with early traps
217433f8924SThomas Gleixner *
218433f8924SThomas Gleixner * On X8664 these traps do not use interrupt stacks as they can't work
219433f8924SThomas Gleixner * before cpu_init() is invoked and sets up TSS. The IST variants are
220433f8924SThomas Gleixner * installed after that.
221433f8924SThomas Gleixner */
idt_setup_early_traps(void)222433f8924SThomas Gleixner void __init idt_setup_early_traps(void)
223433f8924SThomas Gleixner {
224db18da78SThomas Gleixner idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts),
225db18da78SThomas Gleixner true);
226433f8924SThomas Gleixner load_idt(&idt_descr);
227433f8924SThomas Gleixner }
228433f8924SThomas Gleixner
229b70543a0SThomas Gleixner /**
230b70543a0SThomas Gleixner * idt_setup_traps - Initialize the idt table with default traps
231b70543a0SThomas Gleixner */
idt_setup_traps(void)232b70543a0SThomas Gleixner void __init idt_setup_traps(void)
233b70543a0SThomas Gleixner {
234db18da78SThomas Gleixner idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts), true);
23561382281SNikolay Borisov
23661382281SNikolay Borisov if (ia32_enabled())
23761382281SNikolay Borisov idt_setup_from_table(idt_table, ia32_idt, ARRAY_SIZE(ia32_idt), true);
238b70543a0SThomas Gleixner }
239b70543a0SThomas Gleixner
240433f8924SThomas Gleixner #ifdef CONFIG_X86_64
2413e77abdaSThomas Gleixner /*
2423e77abdaSThomas Gleixner * Early traps running on the DEFAULT_STACK because the other interrupt
2433e77abdaSThomas Gleixner * stacks work only after cpu_init().
2443e77abdaSThomas Gleixner */
2453e77abdaSThomas Gleixner static const __initconst struct idt_data early_pf_idts[] = {
2463e77abdaSThomas Gleixner INTG(X86_TRAP_PF, asm_exc_page_fault),
2473e77abdaSThomas Gleixner };
2483e77abdaSThomas Gleixner
249433f8924SThomas Gleixner /**
250433f8924SThomas Gleixner * idt_setup_early_pf - Initialize the idt table with early pagefault handler
251433f8924SThomas Gleixner *
252433f8924SThomas Gleixner * On X8664 this does not use interrupt stacks as they can't work before
253433f8924SThomas Gleixner * cpu_init() is invoked and sets up TSS. The IST variant is installed
254433f8924SThomas Gleixner * after that.
255433f8924SThomas Gleixner *
25694438af4SThomas Gleixner * Note, that X86_64 cannot install the real #PF handler in
257d9f6e12fSIngo Molnar * idt_setup_early_traps() because the memory initialization needs the #PF
25894438af4SThomas Gleixner * handler from the early_idt_handler_array to initialize the early page
25994438af4SThomas Gleixner * tables.
260433f8924SThomas Gleixner */
idt_setup_early_pf(void)261433f8924SThomas Gleixner void __init idt_setup_early_pf(void)
262433f8924SThomas Gleixner {
263433f8924SThomas Gleixner idt_setup_from_table(idt_table, early_pf_idts,
264db18da78SThomas Gleixner ARRAY_SIZE(early_pf_idts), true);
265433f8924SThomas Gleixner }
266433f8924SThomas Gleixner #endif
267433f8924SThomas Gleixner
idt_map_in_cea(void)26800229a54SThomas Gleixner static void __init idt_map_in_cea(void)
26900229a54SThomas Gleixner {
27000229a54SThomas Gleixner /*
27100229a54SThomas Gleixner * Set the IDT descriptor to a fixed read-only location in the cpu
27200229a54SThomas Gleixner * entry area, so that the "sidt" instruction will not leak the
27300229a54SThomas Gleixner * location of the kernel, and to defend the IDT against arbitrary
27400229a54SThomas Gleixner * memory write vulnerabilities.
27500229a54SThomas Gleixner */
27600229a54SThomas Gleixner cea_set_pte(CPU_ENTRY_AREA_RO_IDT_VADDR, __pa_symbol(idt_table),
27700229a54SThomas Gleixner PAGE_KERNEL_RO);
27800229a54SThomas Gleixner idt_descr.address = CPU_ENTRY_AREA_RO_IDT;
27900229a54SThomas Gleixner }
28000229a54SThomas Gleixner
281433f8924SThomas Gleixner /**
282636a7598SThomas Gleixner * idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates
283636a7598SThomas Gleixner */
idt_setup_apic_and_irq_gates(void)284636a7598SThomas Gleixner void __init idt_setup_apic_and_irq_gates(void)
285636a7598SThomas Gleixner {
286dc20b2d5SThomas Gleixner int i = FIRST_EXTERNAL_VECTOR;
287dc20b2d5SThomas Gleixner void *entry;
288dc20b2d5SThomas Gleixner
289db18da78SThomas Gleixner idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true);
290dc20b2d5SThomas Gleixner
2917854f822SThomas Gleixner for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) {
2928f93402bSPeter Zijlstra entry = irq_entries_start + IDT_ALIGN * (i - FIRST_EXTERNAL_VECTOR);
293dc20b2d5SThomas Gleixner set_intr_gate(i, entry);
294dc20b2d5SThomas Gleixner }
295dc20b2d5SThomas Gleixner
296dc20b2d5SThomas Gleixner #ifdef CONFIG_X86_LOCAL_APIC
29733662812SDou Liyang for_each_clear_bit_from(i, system_vectors, NR_VECTORS) {
2981f1fbc70SVitaly Kuznetsov /*
2991f1fbc70SVitaly Kuznetsov * Don't set the non assigned system vectors in the
3001f1fbc70SVitaly Kuznetsov * system_vectors bitmap. Otherwise they show up in
3011f1fbc70SVitaly Kuznetsov * /proc/interrupts.
3021f1fbc70SVitaly Kuznetsov */
3038f93402bSPeter Zijlstra entry = spurious_entries_start + IDT_ALIGN * (i - FIRST_SYSTEM_VECTOR);
304f8a8fe61SThomas Gleixner set_intr_gate(i, entry);
305dc20b2d5SThomas Gleixner }
30633662812SDou Liyang #endif
30700229a54SThomas Gleixner /* Map IDT into CPU entry area and reload it. */
30800229a54SThomas Gleixner idt_map_in_cea();
30900229a54SThomas Gleixner load_idt(&idt_descr);
31000229a54SThomas Gleixner
3113e77abdaSThomas Gleixner /* Make the IDT table read only */
3123e77abdaSThomas Gleixner set_memory_ro((unsigned long)&idt_table, 1);
3133e77abdaSThomas Gleixner
31406184325SVitaly Kuznetsov idt_setup_done = true;
315636a7598SThomas Gleixner }
316636a7598SThomas Gleixner
317636a7598SThomas Gleixner /**
318588787fdSThomas Gleixner * idt_setup_early_handler - Initializes the idt table with early handlers
319588787fdSThomas Gleixner */
idt_setup_early_handler(void)320588787fdSThomas Gleixner void __init idt_setup_early_handler(void)
321588787fdSThomas Gleixner {
322588787fdSThomas Gleixner int i;
323588787fdSThomas Gleixner
324588787fdSThomas Gleixner for (i = 0; i < NUM_EXCEPTION_VECTORS; i++)
325588787fdSThomas Gleixner set_intr_gate(i, early_idt_handler_array[i]);
32687e81786SThomas Gleixner #ifdef CONFIG_X86_32
32787e81786SThomas Gleixner for ( ; i < NR_VECTORS; i++)
32887e81786SThomas Gleixner set_intr_gate(i, early_ignore_irq);
32987e81786SThomas Gleixner #endif
330588787fdSThomas Gleixner load_idt(&idt_descr);
331588787fdSThomas Gleixner }
332588787fdSThomas Gleixner
333588787fdSThomas Gleixner /**
334e802a51eSThomas Gleixner * idt_invalidate - Invalidate interrupt descriptor table
335e802a51eSThomas Gleixner */
idt_invalidate(void)3368ec9069aSH. Peter Anvin (Intel) void idt_invalidate(void)
337e802a51eSThomas Gleixner {
3388ec9069aSH. Peter Anvin (Intel) static const struct desc_ptr idt = { .address = 0, .size = 0 };
339e802a51eSThomas Gleixner
340e802a51eSThomas Gleixner load_idt(&idt);
341e802a51eSThomas Gleixner }
342db18da78SThomas Gleixner
idt_install_sysvec(unsigned int n,const void * function)3438f4a29b0SXin Li void __init idt_install_sysvec(unsigned int n, const void *function)
344db18da78SThomas Gleixner {
34506184325SVitaly Kuznetsov if (WARN_ON(n < FIRST_SYSTEM_VECTOR))
34606184325SVitaly Kuznetsov return;
34706184325SVitaly Kuznetsov
34806184325SVitaly Kuznetsov if (WARN_ON(idt_setup_done))
34906184325SVitaly Kuznetsov return;
35006184325SVitaly Kuznetsov
35106184325SVitaly Kuznetsov if (!WARN_ON(test_and_set_bit(n, system_vectors)))
3528f4a29b0SXin Li set_intr_gate(n, function);
353db18da78SThomas Gleixner }
354