1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 21965aae3SH. Peter Anvin #ifndef _ASM_X86_IRQ_VECTORS_H 31965aae3SH. Peter Anvin #define _ASM_X86_IRQ_VECTORS_H 4bb898558SAl Viro 560f6e65dSShaohua Li #include <linux/threads.h> 69fc2e79dSIngo Molnar /* 79fc2e79dSIngo Molnar * Linux IRQ vector layout. 89fc2e79dSIngo Molnar * 99fc2e79dSIngo Molnar * There are 256 IDT entries (per CPU - each entry is 8 bytes) which can 109fc2e79dSIngo Molnar * be defined by Linux. They are used as a jump table by the CPU when a 119fc2e79dSIngo Molnar * given vector is triggered - by a CPU-external, CPU-internal or 129fc2e79dSIngo Molnar * software-triggered event. 139fc2e79dSIngo Molnar * 149fc2e79dSIngo Molnar * Linux sets the kernel code address each entry jumps to early during 159fc2e79dSIngo Molnar * bootup, and never changes them. This is the general layout of the 169fc2e79dSIngo Molnar * IDT entries: 179fc2e79dSIngo Molnar * 189fc2e79dSIngo Molnar * Vectors 0 ... 31 : system traps and exceptions - hardcoded events 199fc2e79dSIngo Molnar * Vectors 32 ... 127 : device interrupts 209fc2e79dSIngo Molnar * Vector 128 : legacy int80 syscall interface 215cec93c2SAndy Lutomirski * Vectors 129 ... INVALIDATE_TLB_VECTOR_START-1 except 204 : device interrupts 2270e4a369SShaohua Li * Vectors INVALIDATE_TLB_VECTOR_START ... 255 : special interrupts 239fc2e79dSIngo Molnar * 249fc2e79dSIngo Molnar * 64-bit x86 has per CPU IDT tables, 32-bit has one shared IDT table. 259fc2e79dSIngo Molnar * 269fc2e79dSIngo Molnar * This file enumerates the exact layout of them: 279fc2e79dSIngo Molnar */ 289fc2e79dSIngo Molnar 29bb898558SAl Viro #define NMI_VECTOR 0x02 308fa8dd9eSAndi Kleen #define MCE_VECTOR 0x12 31bb898558SAl Viro 32bb898558SAl Viro /* 336579b474SSuresh Siddha * IDT vectors usable for external interrupt sources start at 0x20. 346579b474SSuresh Siddha * (0x80 is the syscall vector, 0x30-0x3f are for ISA) 35bb898558SAl Viro */ 366579b474SSuresh Siddha #define FIRST_EXTERNAL_VECTOR 0x20 376579b474SSuresh Siddha /* 386579b474SSuresh Siddha * We start allocating at 0x21 to spread out vectors evenly between 396579b474SSuresh Siddha * priority levels. (0x80 is the syscall vector) 406579b474SSuresh Siddha */ 416579b474SSuresh Siddha #define VECTOR_OFFSET_START 1 426579b474SSuresh Siddha 436579b474SSuresh Siddha /* 446579b474SSuresh Siddha * Reserve the lowest usable vector (and hence lowest priority) 0x20 for 456579b474SSuresh Siddha * triggering cleanup after irq migration. 0x21-0x2f will still be used 466579b474SSuresh Siddha * for device interrupts. 476579b474SSuresh Siddha */ 486579b474SSuresh Siddha #define IRQ_MOVE_CLEANUP_VECTOR FIRST_EXTERNAL_VECTOR 49bb898558SAl Viro 5099d113b1SH. Peter Anvin #define IA32_SYSCALL_VECTOR 0x80 51bb898558SAl Viro 52bb898558SAl Viro /* 536579b474SSuresh Siddha * Vectors 0x30-0x3f are used for ISA interrupts. 5499d113b1SH. Peter Anvin * round up to the next 16-vector boundary 55bb898558SAl Viro */ 568b455e65SBrian Gerst #define ISA_IRQ_VECTOR(irq) (((FIRST_EXTERNAL_VECTOR + 16) & ~15) + irq) 57bb898558SAl Viro 58bb898558SAl Viro /* 59bb898558SAl Viro * Special IRQ vectors used by the SMP architecture, 0xf0-0xff 60bb898558SAl Viro * 61bb898558SAl Viro * some of the following vectors are 'rare', they are merged 62bb898558SAl Viro * into a single vector (CALL_FUNCTION_VECTOR) to save vector space. 63bb898558SAl Viro * TLB, reschedule and local APIC vectors are performance-critical. 64bb898558SAl Viro */ 655da690d2SIngo Molnar 665da690d2SIngo Molnar #define SPURIOUS_APIC_VECTOR 0xff 67647ad94fSIngo Molnar /* 68647ad94fSIngo Molnar * Sanity check 69647ad94fSIngo Molnar */ 70647ad94fSIngo Molnar #if ((SPURIOUS_APIC_VECTOR & 0x0F) != 0x0F) 71647ad94fSIngo Molnar # error SPURIOUS_APIC_VECTOR definition error 72647ad94fSIngo Molnar #endif 73647ad94fSIngo Molnar 745da690d2SIngo Molnar #define ERROR_APIC_VECTOR 0xfe 755da690d2SIngo Molnar #define RESCHEDULE_VECTOR 0xfd 765da690d2SIngo Molnar #define CALL_FUNCTION_VECTOR 0xfc 775da690d2SIngo Molnar #define CALL_FUNCTION_SINGLE_VECTOR 0xfb 785da690d2SIngo Molnar #define THERMAL_APIC_VECTOR 0xfa 79bb898558SAl Viro #define THRESHOLD_APIC_VECTOR 0xf9 804ef702c1SAndi Kleen #define REBOOT_VECTOR 0xf8 81bb898558SAl Viro 8260f6e65dSShaohua Li /* 8360f6e65dSShaohua Li * Generic system vector for platform specific use 8460f6e65dSShaohua Li */ 8560f6e65dSShaohua Li #define X86_PLATFORM_IPI_VECTOR 0xf7 8660f6e65dSShaohua Li 8760f6e65dSShaohua Li /* 8860f6e65dSShaohua Li * IRQ work vector: 8960f6e65dSShaohua Li */ 9060f6e65dSShaohua Li #define IRQ_WORK_VECTOR 0xf6 9160f6e65dSShaohua Li 9260f6e65dSShaohua Li #define UV_BAU_MESSAGE 0xf5 9324fd78a8SAravind Gopalakrishnan #define DEFERRED_ERROR_VECTOR 0xf4 9460f6e65dSShaohua Li 95bc2b0331SK. Y. Srinivasan /* Vector on which hypervisor callbacks will be delivered */ 96bc2b0331SK. Y. Srinivasan #define HYPERVISOR_CALLBACK_VECTOR 0xf3 975da690d2SIngo Molnar 985c0d728eSAravind Gopalakrishnan /* Vector for KVM to deliver posted interrupt IPI */ 995c0d728eSAravind Gopalakrishnan #ifdef CONFIG_HAVE_KVM 1005c0d728eSAravind Gopalakrishnan #define POSTED_INTR_VECTOR 0xf2 101210f84b0SWincy Van #define POSTED_INTR_WAKEUP_VECTOR 0xf1 102210f84b0SWincy Van #define POSTED_INTR_NESTED_VECTOR 0xf0 1035c0d728eSAravind Gopalakrishnan #endif 1045c0d728eSAravind Gopalakrishnan 105bb898558SAl Viro /* 106bb898558SAl Viro * Local APIC timer IRQ vector is on a different priority level, 107bb898558SAl Viro * to work around the 'lost local interrupt if more than 2 IRQ 108bb898558SAl Viro * sources per level' errata. 109bb898558SAl Viro */ 110bb898558SAl Viro #define LOCAL_TIMER_VECTOR 0xef 111bb898558SAl Viro 112bb898558SAl Viro #define NR_VECTORS 256 113bb898558SAl Viro 1142414e021SJan Beulich #ifdef CONFIG_X86_LOCAL_APIC 1152414e021SJan Beulich #define FIRST_SYSTEM_VECTOR LOCAL_TIMER_VECTOR 1162414e021SJan Beulich #else 1172414e021SJan Beulich #define FIRST_SYSTEM_VECTOR NR_VECTORS 1182414e021SJan Beulich #endif 1192414e021SJan Beulich 120bb898558SAl Viro #define FPU_IRQ 13 121bb898558SAl Viro 122009eb3feSIngo Molnar /* 123009eb3feSIngo Molnar * Size the maximum number of interrupts. 124009eb3feSIngo Molnar * 125009eb3feSIngo Molnar * If the irq_desc[] array has a sparse layout, we can size things 126009eb3feSIngo Molnar * generously - it scales up linearly with the maximum number of CPUs, 127009eb3feSIngo Molnar * and the maximum number of IO-APICs, whichever is higher. 128009eb3feSIngo Molnar * 129009eb3feSIngo Molnar * In other cases we size more conservatively, to not create too large 130009eb3feSIngo Molnar * static arrays. 131009eb3feSIngo Molnar */ 132009eb3feSIngo Molnar 13399d093d1SYinghai Lu #define NR_IRQS_LEGACY 16 13499d093d1SYinghai Lu 1354399b14fSJiang Liu #define CPU_VECTOR_LIMIT (64 * NR_CPUS) 136009eb3feSIngo Molnar #define IO_APIC_VECTOR_LIMIT (32 * MAX_IO_APICS) 137009eb3feSIngo Molnar 1384399b14fSJiang Liu #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_PCI_MSI) 1394a046d17SYinghai Lu #define NR_IRQS \ 140009eb3feSIngo Molnar (CPU_VECTOR_LIMIT > IO_APIC_VECTOR_LIMIT ? \ 141009eb3feSIngo Molnar (NR_VECTORS + CPU_VECTOR_LIMIT) : \ 142009eb3feSIngo Molnar (NR_VECTORS + IO_APIC_VECTOR_LIMIT)) 1434399b14fSJiang Liu #elif defined(CONFIG_X86_IO_APIC) 1444399b14fSJiang Liu #define NR_IRQS (NR_VECTORS + IO_APIC_VECTOR_LIMIT) 1454399b14fSJiang Liu #elif defined(CONFIG_PCI_MSI) 1464399b14fSJiang Liu #define NR_IRQS (NR_VECTORS + CPU_VECTOR_LIMIT) 1474399b14fSJiang Liu #else 148009eb3feSIngo Molnar #define NR_IRQS NR_IRQS_LEGACY 149bb898558SAl Viro #endif 150bb898558SAl Viro 1511965aae3SH. Peter Anvin #endif /* _ASM_X86_IRQ_VECTORS_H */ 152