Page 1 of 1

Non-maskable interrupts

Posted: Fri Apr 25, 2014 1:40 pm
by qw
Now that I am working om exception and interrupt handling, I am wondering how you guys are handling NMI's.

NMI's are caused by faulty hardware, in which case the best thing to do is hang the computer.
They are also used for performance monitoring and watchdogs, which are easily controlled by the OS.
However, when searching the net, I found that they are also used by some hardware. Do you take this into account?

What are your thoughts about this?

Re: Non-maskable interrupts

Posted: Fri Apr 25, 2014 4:04 pm
by jnc100
I have a Dell Poweredge server with an NMI button. When you press it, it asserts the CPU's #NMI line and triggers an interrupt. At least in linux this causes a kernel panic and is used for debugging purposes/reset. I'd imagine most OS's handle it this way; a NMI is generally not recoverable.

Regards,
John.

Re: Non-maskable interrupts

Posted: Sat Apr 26, 2014 9:09 am
by onlyonemac
Why would one want an NMI button on a server? Is it to halt the machine in case of viruses? In any case, it certainly sounds cool!

Perhaps I should wire a microswitch up to each CPU interrupt line for testing purposes... (Just kidding!)

Re: Non-maskable interrupts

Posted: Sat Apr 26, 2014 9:31 am
by jnc100
As I said, normally for debugging purposes. A bit more reading reveals that it is used on Windows since 2000 (if a particular registry bit is set) to generate a crash dump on the system drive, useful when the system has become unresponsive.

Personally I use it to drop down into a gdb stub if kernel debug support is enabled, or panic if not. Of note, certain emulators (VirtualBox in debug mode at least) allow you to inject an NMI at run-time and so you can use this for investigating hangs in your own kernel.

Regards,
John.

Re: Non-maskable interrupts

Posted: Sun Apr 27, 2014 1:37 pm
by qw
While searching the net, I found someone who had a foot pedal attached to the NMI line.

Anyway, my problem is when ordinary hardware (like a sound card) is sending NMI's to the CPU. How do you distinguish those from other causes, if you do so at all?

Re: Non-maskable interrupts

Posted: Tue Apr 29, 2014 6:33 am
by Octocontrabass
You don't. (Unless you've set up the watchdog timer.)

If you receive a NMI (and it's not the watchdog), it means your OS should not be running anymore. Either the hardware failed, or the user pressed the "make it crash" foot pedal.


For the sake of completeness, I will mention that really old PCs have the 8087 attached to NMI. However, if you're writing your OS for something that old, you should already know that.