1d8ed9d48SThomas Gleixner /* 2d8ed9d48SThomas Gleixner * Interrupt descriptor table related code 3d8ed9d48SThomas Gleixner * 4d8ed9d48SThomas Gleixner * This file is licensed under the GPL V2 5d8ed9d48SThomas Gleixner */ 6d8ed9d48SThomas Gleixner #include <linux/interrupt.h> 7d8ed9d48SThomas Gleixner 83318e974SThomas Gleixner #include <asm/traps.h> 93318e974SThomas Gleixner #include <asm/proto.h> 10d8ed9d48SThomas Gleixner #include <asm/desc.h> 11*447ae316SNicolai Stange #include <asm/hw_irq.h> 12d8ed9d48SThomas Gleixner 133318e974SThomas Gleixner struct idt_data { 143318e974SThomas Gleixner unsigned int vector; 153318e974SThomas Gleixner unsigned int segment; 163318e974SThomas Gleixner struct idt_bits bits; 173318e974SThomas Gleixner const void *addr; 183318e974SThomas Gleixner }; 193318e974SThomas Gleixner 203318e974SThomas Gleixner #define DPL0 0x0 213318e974SThomas Gleixner #define DPL3 0x3 223318e974SThomas Gleixner 233318e974SThomas Gleixner #define DEFAULT_STACK 0 243318e974SThomas Gleixner 253318e974SThomas Gleixner #define G(_vector, _addr, _ist, _type, _dpl, _segment) \ 263318e974SThomas Gleixner { \ 273318e974SThomas Gleixner .vector = _vector, \ 283318e974SThomas Gleixner .bits.ist = _ist, \ 293318e974SThomas Gleixner .bits.type = _type, \ 303318e974SThomas Gleixner .bits.dpl = _dpl, \ 313318e974SThomas Gleixner .bits.p = 1, \ 323318e974SThomas Gleixner .addr = _addr, \ 333318e974SThomas Gleixner .segment = _segment, \ 343318e974SThomas Gleixner } 353318e974SThomas Gleixner 363318e974SThomas Gleixner /* Interrupt gate */ 373318e974SThomas Gleixner #define INTG(_vector, _addr) \ 383318e974SThomas Gleixner G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL0, __KERNEL_CS) 393318e974SThomas Gleixner 403318e974SThomas Gleixner /* System interrupt gate */ 413318e974SThomas Gleixner #define SYSG(_vector, _addr) \ 423318e974SThomas Gleixner G(_vector, _addr, DEFAULT_STACK, GATE_INTERRUPT, DPL3, __KERNEL_CS) 433318e974SThomas Gleixner 443318e974SThomas Gleixner /* Interrupt gate with interrupt stack */ 453318e974SThomas Gleixner #define ISTG(_vector, _addr, _ist) \ 463318e974SThomas Gleixner G(_vector, _addr, _ist, GATE_INTERRUPT, DPL0, __KERNEL_CS) 473318e974SThomas Gleixner 48c6ef8942SIngo Molnar /* System interrupt gate with interrupt stack */ 49c6ef8942SIngo Molnar #define SISTG(_vector, _addr, _ist) \ 50c6ef8942SIngo Molnar G(_vector, _addr, _ist, GATE_INTERRUPT, DPL3, __KERNEL_CS) 51c6ef8942SIngo Molnar 523318e974SThomas Gleixner /* Task gate */ 533318e974SThomas Gleixner #define TSKG(_vector, _gdt) \ 543318e974SThomas Gleixner G(_vector, NULL, DEFAULT_STACK, GATE_TASK, DPL0, _gdt << 3) 553318e974SThomas Gleixner 56433f8924SThomas Gleixner /* 57433f8924SThomas Gleixner * Early traps running on the DEFAULT_STACK because the other interrupt 58433f8924SThomas Gleixner * stacks work only after cpu_init(). 59433f8924SThomas Gleixner */ 60327867faSAndi Kleen static const __initconst struct idt_data early_idts[] = { 61433f8924SThomas Gleixner INTG(X86_TRAP_DB, debug), 62433f8924SThomas Gleixner SYSG(X86_TRAP_BP, int3), 63433f8924SThomas Gleixner #ifdef CONFIG_X86_32 64433f8924SThomas Gleixner INTG(X86_TRAP_PF, page_fault), 65433f8924SThomas Gleixner #endif 66433f8924SThomas Gleixner }; 67433f8924SThomas Gleixner 68b70543a0SThomas Gleixner /* 69b70543a0SThomas Gleixner * The default IDT entries which are set up in trap_init() before 70b70543a0SThomas Gleixner * cpu_init() is invoked. Interrupt stacks cannot be used at that point and 71b70543a0SThomas Gleixner * the traps which use them are reinitialized with IST after cpu_init() has 72b70543a0SThomas Gleixner * set up TSS. 73b70543a0SThomas Gleixner */ 74327867faSAndi Kleen static const __initconst struct idt_data def_idts[] = { 75b70543a0SThomas Gleixner INTG(X86_TRAP_DE, divide_error), 76b70543a0SThomas Gleixner INTG(X86_TRAP_NMI, nmi), 77b70543a0SThomas Gleixner INTG(X86_TRAP_BR, bounds), 78b70543a0SThomas Gleixner INTG(X86_TRAP_UD, invalid_op), 79b70543a0SThomas Gleixner INTG(X86_TRAP_NM, device_not_available), 80b70543a0SThomas Gleixner INTG(X86_TRAP_OLD_MF, coprocessor_segment_overrun), 81b70543a0SThomas Gleixner INTG(X86_TRAP_TS, invalid_TSS), 82b70543a0SThomas Gleixner INTG(X86_TRAP_NP, segment_not_present), 83b70543a0SThomas Gleixner INTG(X86_TRAP_SS, stack_segment), 84b70543a0SThomas Gleixner INTG(X86_TRAP_GP, general_protection), 85b70543a0SThomas Gleixner INTG(X86_TRAP_SPURIOUS, spurious_interrupt_bug), 86b70543a0SThomas Gleixner INTG(X86_TRAP_MF, coprocessor_error), 87b70543a0SThomas Gleixner INTG(X86_TRAP_AC, alignment_check), 88b70543a0SThomas Gleixner INTG(X86_TRAP_XF, simd_coprocessor_error), 89b70543a0SThomas Gleixner 90b70543a0SThomas Gleixner #ifdef CONFIG_X86_32 91b70543a0SThomas Gleixner TSKG(X86_TRAP_DF, GDT_ENTRY_DOUBLEFAULT_TSS), 92b70543a0SThomas Gleixner #else 93b70543a0SThomas Gleixner INTG(X86_TRAP_DF, double_fault), 94b70543a0SThomas Gleixner #endif 95b70543a0SThomas Gleixner INTG(X86_TRAP_DB, debug), 96b70543a0SThomas Gleixner 97b70543a0SThomas Gleixner #ifdef CONFIG_X86_MCE 98b70543a0SThomas Gleixner INTG(X86_TRAP_MC, &machine_check), 99b70543a0SThomas Gleixner #endif 100b70543a0SThomas Gleixner 101b70543a0SThomas Gleixner SYSG(X86_TRAP_OF, overflow), 102b70543a0SThomas Gleixner #if defined(CONFIG_IA32_EMULATION) 103b70543a0SThomas Gleixner SYSG(IA32_SYSCALL_VECTOR, entry_INT80_compat), 104b70543a0SThomas Gleixner #elif defined(CONFIG_X86_32) 105b70543a0SThomas Gleixner SYSG(IA32_SYSCALL_VECTOR, entry_INT80_32), 106b70543a0SThomas Gleixner #endif 107b70543a0SThomas Gleixner }; 108b70543a0SThomas Gleixner 109636a7598SThomas Gleixner /* 110636a7598SThomas Gleixner * The APIC and SMP idt entries 111636a7598SThomas Gleixner */ 112327867faSAndi Kleen static const __initconst struct idt_data apic_idts[] = { 113636a7598SThomas Gleixner #ifdef CONFIG_SMP 114636a7598SThomas Gleixner INTG(RESCHEDULE_VECTOR, reschedule_interrupt), 115636a7598SThomas Gleixner INTG(CALL_FUNCTION_VECTOR, call_function_interrupt), 116636a7598SThomas Gleixner INTG(CALL_FUNCTION_SINGLE_VECTOR, call_function_single_interrupt), 117636a7598SThomas Gleixner INTG(IRQ_MOVE_CLEANUP_VECTOR, irq_move_cleanup_interrupt), 118636a7598SThomas Gleixner INTG(REBOOT_VECTOR, reboot_interrupt), 119636a7598SThomas Gleixner #endif 120636a7598SThomas Gleixner 121636a7598SThomas Gleixner #ifdef CONFIG_X86_THERMAL_VECTOR 122636a7598SThomas Gleixner INTG(THERMAL_APIC_VECTOR, thermal_interrupt), 123636a7598SThomas Gleixner #endif 124636a7598SThomas Gleixner 125636a7598SThomas Gleixner #ifdef CONFIG_X86_MCE_THRESHOLD 126636a7598SThomas Gleixner INTG(THRESHOLD_APIC_VECTOR, threshold_interrupt), 127636a7598SThomas Gleixner #endif 128636a7598SThomas Gleixner 129636a7598SThomas Gleixner #ifdef CONFIG_X86_MCE_AMD 130636a7598SThomas Gleixner INTG(DEFERRED_ERROR_VECTOR, deferred_error_interrupt), 131636a7598SThomas Gleixner #endif 132636a7598SThomas Gleixner 133636a7598SThomas Gleixner #ifdef CONFIG_X86_LOCAL_APIC 134636a7598SThomas Gleixner INTG(LOCAL_TIMER_VECTOR, apic_timer_interrupt), 135636a7598SThomas Gleixner INTG(X86_PLATFORM_IPI_VECTOR, x86_platform_ipi), 136636a7598SThomas Gleixner # ifdef CONFIG_HAVE_KVM 137636a7598SThomas Gleixner INTG(POSTED_INTR_VECTOR, kvm_posted_intr_ipi), 138636a7598SThomas Gleixner INTG(POSTED_INTR_WAKEUP_VECTOR, kvm_posted_intr_wakeup_ipi), 139636a7598SThomas Gleixner INTG(POSTED_INTR_NESTED_VECTOR, kvm_posted_intr_nested_ipi), 140636a7598SThomas Gleixner # endif 141636a7598SThomas Gleixner # ifdef CONFIG_IRQ_WORK 142636a7598SThomas Gleixner INTG(IRQ_WORK_VECTOR, irq_work_interrupt), 143636a7598SThomas Gleixner # endif 144151ad17fSAndrew Banman #ifdef CONFIG_X86_UV 145151ad17fSAndrew Banman INTG(UV_BAU_MESSAGE, uv_bau_message_intr1), 146151ad17fSAndrew Banman #endif 147636a7598SThomas Gleixner INTG(SPURIOUS_APIC_VECTOR, spurious_interrupt), 148636a7598SThomas Gleixner INTG(ERROR_APIC_VECTOR, error_interrupt), 149636a7598SThomas Gleixner #endif 150636a7598SThomas Gleixner }; 151636a7598SThomas Gleixner 152433f8924SThomas Gleixner #ifdef CONFIG_X86_64 153433f8924SThomas Gleixner /* 154433f8924SThomas Gleixner * Early traps running on the DEFAULT_STACK because the other interrupt 155433f8924SThomas Gleixner * stacks work only after cpu_init(). 156433f8924SThomas Gleixner */ 157327867faSAndi Kleen static const __initconst struct idt_data early_pf_idts[] = { 158433f8924SThomas Gleixner INTG(X86_TRAP_PF, page_fault), 159433f8924SThomas Gleixner }; 1600a30908bSThomas Gleixner 1610a30908bSThomas Gleixner /* 1620a30908bSThomas Gleixner * Override for the debug_idt. Same as the default, but with interrupt 1630a30908bSThomas Gleixner * stack set to DEFAULT_STACK (0). Required for NMI trap handling. 1640a30908bSThomas Gleixner */ 165327867faSAndi Kleen static const __initconst struct idt_data dbg_idts[] = { 1660a30908bSThomas Gleixner INTG(X86_TRAP_DB, debug), 1670a30908bSThomas Gleixner }; 168433f8924SThomas Gleixner #endif 169433f8924SThomas Gleixner 170d8ed9d48SThomas Gleixner /* Must be page-aligned because the real IDT is used in a fixmap. */ 171d8ed9d48SThomas Gleixner gate_desc idt_table[IDT_ENTRIES] __page_aligned_bss; 172d8ed9d48SThomas Gleixner 17316bc18d8SThomas Gleixner struct desc_ptr idt_descr __ro_after_init = { 17416bc18d8SThomas Gleixner .size = (IDT_ENTRIES * 2 * sizeof(unsigned long)) - 1, 17516bc18d8SThomas Gleixner .address = (unsigned long) idt_table, 17616bc18d8SThomas Gleixner }; 17716bc18d8SThomas Gleixner 178d8ed9d48SThomas Gleixner #ifdef CONFIG_X86_64 179d8ed9d48SThomas Gleixner /* No need to be aligned, but done to keep all IDTs defined the same way. */ 180d8ed9d48SThomas Gleixner gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss; 181d8ed9d48SThomas Gleixner 1820a30908bSThomas Gleixner /* 18390f6225fSThomas Gleixner * The exceptions which use Interrupt stacks. They are setup after 18490f6225fSThomas Gleixner * cpu_init() when the TSS has been initialized. 18590f6225fSThomas Gleixner */ 186327867faSAndi Kleen static const __initconst struct idt_data ist_idts[] = { 18790f6225fSThomas Gleixner ISTG(X86_TRAP_DB, debug, DEBUG_STACK), 18890f6225fSThomas Gleixner ISTG(X86_TRAP_NMI, nmi, NMI_STACK), 18990f6225fSThomas Gleixner ISTG(X86_TRAP_DF, double_fault, DOUBLEFAULT_STACK), 19090f6225fSThomas Gleixner #ifdef CONFIG_X86_MCE 19190f6225fSThomas Gleixner ISTG(X86_TRAP_MC, &machine_check, MCE_STACK), 19290f6225fSThomas Gleixner #endif 19390f6225fSThomas Gleixner }; 19490f6225fSThomas Gleixner 19590f6225fSThomas Gleixner /* 1960a30908bSThomas Gleixner * Override for the debug_idt. Same as the default, but with interrupt 1970a30908bSThomas Gleixner * stack set to DEFAULT_STACK (0). Required for NMI trap handling. 1980a30908bSThomas Gleixner */ 199d8ed9d48SThomas Gleixner const struct desc_ptr debug_idt_descr = { 200d8ed9d48SThomas Gleixner .size = IDT_ENTRIES * 16 - 1, 201d8ed9d48SThomas Gleixner .address = (unsigned long) debug_idt_table, 202d8ed9d48SThomas Gleixner }; 203d8ed9d48SThomas Gleixner #endif 204e802a51eSThomas Gleixner 2053318e974SThomas Gleixner static inline void idt_init_desc(gate_desc *gate, const struct idt_data *d) 2063318e974SThomas Gleixner { 2073318e974SThomas Gleixner unsigned long addr = (unsigned long) d->addr; 2083318e974SThomas Gleixner 2093318e974SThomas Gleixner gate->offset_low = (u16) addr; 2103318e974SThomas Gleixner gate->segment = (u16) d->segment; 2113318e974SThomas Gleixner gate->bits = d->bits; 2123318e974SThomas Gleixner gate->offset_middle = (u16) (addr >> 16); 2133318e974SThomas Gleixner #ifdef CONFIG_X86_64 2143318e974SThomas Gleixner gate->offset_high = (u32) (addr >> 32); 2153318e974SThomas Gleixner gate->reserved = 0; 2163318e974SThomas Gleixner #endif 2173318e974SThomas Gleixner } 2183318e974SThomas Gleixner 219db18da78SThomas Gleixner static void 220db18da78SThomas Gleixner idt_setup_from_table(gate_desc *idt, const struct idt_data *t, int size, bool sys) 2213318e974SThomas Gleixner { 2223318e974SThomas Gleixner gate_desc desc; 2233318e974SThomas Gleixner 2243318e974SThomas Gleixner for (; size > 0; t++, size--) { 2253318e974SThomas Gleixner idt_init_desc(&desc, t); 2263318e974SThomas Gleixner write_idt_entry(idt, t->vector, &desc); 227db18da78SThomas Gleixner if (sys) 2287854f822SThomas Gleixner set_bit(t->vector, system_vectors); 2293318e974SThomas Gleixner } 2303318e974SThomas Gleixner } 2313318e974SThomas Gleixner 232facaa3e3SThomas Gleixner static void set_intr_gate(unsigned int n, const void *addr) 233facaa3e3SThomas Gleixner { 234facaa3e3SThomas Gleixner struct idt_data data; 235facaa3e3SThomas Gleixner 236facaa3e3SThomas Gleixner BUG_ON(n > 0xFF); 237facaa3e3SThomas Gleixner 238facaa3e3SThomas Gleixner memset(&data, 0, sizeof(data)); 239facaa3e3SThomas Gleixner data.vector = n; 240facaa3e3SThomas Gleixner data.addr = addr; 241facaa3e3SThomas Gleixner data.segment = __KERNEL_CS; 242facaa3e3SThomas Gleixner data.bits.type = GATE_INTERRUPT; 243facaa3e3SThomas Gleixner data.bits.p = 1; 244facaa3e3SThomas Gleixner 245facaa3e3SThomas Gleixner idt_setup_from_table(idt_table, &data, 1, false); 246facaa3e3SThomas Gleixner } 247facaa3e3SThomas Gleixner 248e802a51eSThomas Gleixner /** 249433f8924SThomas Gleixner * idt_setup_early_traps - Initialize the idt table with early traps 250433f8924SThomas Gleixner * 251433f8924SThomas Gleixner * On X8664 these traps do not use interrupt stacks as they can't work 252433f8924SThomas Gleixner * before cpu_init() is invoked and sets up TSS. The IST variants are 253433f8924SThomas Gleixner * installed after that. 254433f8924SThomas Gleixner */ 255433f8924SThomas Gleixner void __init idt_setup_early_traps(void) 256433f8924SThomas Gleixner { 257db18da78SThomas Gleixner idt_setup_from_table(idt_table, early_idts, ARRAY_SIZE(early_idts), 258db18da78SThomas Gleixner true); 259433f8924SThomas Gleixner load_idt(&idt_descr); 260433f8924SThomas Gleixner } 261433f8924SThomas Gleixner 262b70543a0SThomas Gleixner /** 263b70543a0SThomas Gleixner * idt_setup_traps - Initialize the idt table with default traps 264b70543a0SThomas Gleixner */ 265b70543a0SThomas Gleixner void __init idt_setup_traps(void) 266b70543a0SThomas Gleixner { 267db18da78SThomas Gleixner idt_setup_from_table(idt_table, def_idts, ARRAY_SIZE(def_idts), true); 268b70543a0SThomas Gleixner } 269b70543a0SThomas Gleixner 270433f8924SThomas Gleixner #ifdef CONFIG_X86_64 271433f8924SThomas Gleixner /** 272433f8924SThomas Gleixner * idt_setup_early_pf - Initialize the idt table with early pagefault handler 273433f8924SThomas Gleixner * 274433f8924SThomas Gleixner * On X8664 this does not use interrupt stacks as they can't work before 275433f8924SThomas Gleixner * cpu_init() is invoked and sets up TSS. The IST variant is installed 276433f8924SThomas Gleixner * after that. 277433f8924SThomas Gleixner * 278433f8924SThomas Gleixner * FIXME: Why is 32bit and 64bit installing the PF handler at different 279433f8924SThomas Gleixner * places in the early setup code? 280433f8924SThomas Gleixner */ 281433f8924SThomas Gleixner void __init idt_setup_early_pf(void) 282433f8924SThomas Gleixner { 283433f8924SThomas Gleixner idt_setup_from_table(idt_table, early_pf_idts, 284db18da78SThomas Gleixner ARRAY_SIZE(early_pf_idts), true); 285433f8924SThomas Gleixner } 2860a30908bSThomas Gleixner 2870a30908bSThomas Gleixner /** 28890f6225fSThomas Gleixner * idt_setup_ist_traps - Initialize the idt table with traps using IST 28990f6225fSThomas Gleixner */ 29090f6225fSThomas Gleixner void __init idt_setup_ist_traps(void) 29190f6225fSThomas Gleixner { 292db18da78SThomas Gleixner idt_setup_from_table(idt_table, ist_idts, ARRAY_SIZE(ist_idts), true); 29390f6225fSThomas Gleixner } 29490f6225fSThomas Gleixner 29590f6225fSThomas Gleixner /** 2960a30908bSThomas Gleixner * idt_setup_debugidt_traps - Initialize the debug idt table with debug traps 2970a30908bSThomas Gleixner */ 2980a30908bSThomas Gleixner void __init idt_setup_debugidt_traps(void) 2990a30908bSThomas Gleixner { 3000a30908bSThomas Gleixner memcpy(&debug_idt_table, &idt_table, IDT_ENTRIES * 16); 3010a30908bSThomas Gleixner 302db18da78SThomas Gleixner idt_setup_from_table(debug_idt_table, dbg_idts, ARRAY_SIZE(dbg_idts), false); 3030a30908bSThomas Gleixner } 304433f8924SThomas Gleixner #endif 305433f8924SThomas Gleixner 306433f8924SThomas Gleixner /** 307636a7598SThomas Gleixner * idt_setup_apic_and_irq_gates - Setup APIC/SMP and normal interrupt gates 308636a7598SThomas Gleixner */ 309636a7598SThomas Gleixner void __init idt_setup_apic_and_irq_gates(void) 310636a7598SThomas Gleixner { 311dc20b2d5SThomas Gleixner int i = FIRST_EXTERNAL_VECTOR; 312dc20b2d5SThomas Gleixner void *entry; 313dc20b2d5SThomas Gleixner 314db18da78SThomas Gleixner idt_setup_from_table(idt_table, apic_idts, ARRAY_SIZE(apic_idts), true); 315dc20b2d5SThomas Gleixner 3167854f822SThomas Gleixner for_each_clear_bit_from(i, system_vectors, FIRST_SYSTEM_VECTOR) { 317dc20b2d5SThomas Gleixner entry = irq_entries_start + 8 * (i - FIRST_EXTERNAL_VECTOR); 318dc20b2d5SThomas Gleixner set_intr_gate(i, entry); 319dc20b2d5SThomas Gleixner } 320dc20b2d5SThomas Gleixner 321dc20b2d5SThomas Gleixner #ifdef CONFIG_X86_LOCAL_APIC 32233662812SDou Liyang for_each_clear_bit_from(i, system_vectors, NR_VECTORS) { 3237854f822SThomas Gleixner set_bit(i, system_vectors); 324dc20b2d5SThomas Gleixner set_intr_gate(i, spurious_interrupt); 325dc20b2d5SThomas Gleixner } 32633662812SDou Liyang #endif 327636a7598SThomas Gleixner } 328636a7598SThomas Gleixner 329636a7598SThomas Gleixner /** 330588787fdSThomas Gleixner * idt_setup_early_handler - Initializes the idt table with early handlers 331588787fdSThomas Gleixner */ 332588787fdSThomas Gleixner void __init idt_setup_early_handler(void) 333588787fdSThomas Gleixner { 334588787fdSThomas Gleixner int i; 335588787fdSThomas Gleixner 336588787fdSThomas Gleixner for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) 337588787fdSThomas Gleixner set_intr_gate(i, early_idt_handler_array[i]); 33887e81786SThomas Gleixner #ifdef CONFIG_X86_32 33987e81786SThomas Gleixner for ( ; i < NR_VECTORS; i++) 34087e81786SThomas Gleixner set_intr_gate(i, early_ignore_irq); 34187e81786SThomas Gleixner #endif 342588787fdSThomas Gleixner load_idt(&idt_descr); 343588787fdSThomas Gleixner } 344588787fdSThomas Gleixner 345588787fdSThomas Gleixner /** 346e802a51eSThomas Gleixner * idt_invalidate - Invalidate interrupt descriptor table 347e802a51eSThomas Gleixner * @addr: The virtual address of the 'invalid' IDT 348e802a51eSThomas Gleixner */ 349e802a51eSThomas Gleixner void idt_invalidate(void *addr) 350e802a51eSThomas Gleixner { 351e802a51eSThomas Gleixner struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 }; 352e802a51eSThomas Gleixner 353e802a51eSThomas Gleixner load_idt(&idt); 354e802a51eSThomas Gleixner } 355db18da78SThomas Gleixner 356facaa3e3SThomas Gleixner void __init update_intr_gate(unsigned int n, const void *addr) 357db18da78SThomas Gleixner { 3587854f822SThomas Gleixner if (WARN_ON_ONCE(!test_bit(n, system_vectors))) 359facaa3e3SThomas Gleixner return; 360facaa3e3SThomas Gleixner set_intr_gate(n, addr); 361db18da78SThomas Gleixner } 362db18da78SThomas Gleixner 363db18da78SThomas Gleixner void alloc_intr_gate(unsigned int n, const void *addr) 364db18da78SThomas Gleixner { 3654447ac11SThomas Gleixner BUG_ON(n < FIRST_SYSTEM_VECTOR); 3667854f822SThomas Gleixner if (!test_and_set_bit(n, system_vectors)) 367db18da78SThomas Gleixner set_intr_gate(n, addr); 368db18da78SThomas Gleixner } 369