Non-maskable interrupts

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Non-maskable interrupts

Post 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?
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Non-maskable interrupts

Post 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.
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Non-maskable interrupts

Post 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!)
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Non-maskable interrupts

Post 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.
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: Non-maskable interrupts

Post 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?
Octocontrabass
Member
Member
Posts: 5572
Joined: Mon Mar 25, 2013 7:01 pm

Re: Non-maskable interrupts

Post 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.
Post Reply