Skip to content
Advertisement

How do I get the interrupt vector number on Linux?

When I run “cat /proc/interrupts”, I can get the following:

JavaScript

How can I get the interrupt number of “NMI” “LOC” “SPU” “PMI”, etc.

Advertisement

Answer

On x86 NMIs are always on interrupt vector 2. The number is hard-coded just as common exceptions (division by 0, page fault, etc). You can find this in the CPU documentation from Intel/AMD.

If the APIC is enabled (as is the case in the dump presented in the question), Spurious Interrupt’s interrupt vector number can be obtained from APIC’s SVR register. Again, see the same CPU documentation on that.

If the APIC isn’t enabled and instead the PIC is being used, then Spurious Interrupts are delivered as IRQ7 (see the 8259A PIC chip spec for that). The BIOS programs the PIC in such a way that IRQ7 is interrupt vector 0Fh, but Windows and Linux change this mapping to avoid sharing the same interrupt vectors for IRQs and CPU exceptions. It seems like this mapping can’t be queried from the PIC, but it’s established via sending the Initialization Control Word 2 (ICW2) to the PIC. Here’s the relevant piece of Linux code in init_8259A():

JavaScript

That should answer the Spurious Interrupt vector part.

As for LOC and PMI, I think, these are local APIC’s interrupts and you can find their interrupt vectors from the APIC just like with the Spurious Interrupt above.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement