What would happen if I were to divide by 0 when interrupts are disabled?

Viewed 102

When IF flag is cleared, (interrupt table is not ready), all maskable interrupts are disabled.

Questions are:

  1. What happens if I trigger an exception? (eg: div by zero)
  2. What happens if a non-maskable interrupt arrives, (interrupt table is not ready)? What will the cpu do ?
1 Answers

Setting IF to 0 (with cli, popf, iret, etc.) only inhibits external interrupts.

To quote the documentation (Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2A, Chapter 3.2, for the cli instruction):

Clearing the IF flag causes the processor to ignore maskable external interrupts. The IF flag and the CLI and STI instruction have no effect on the generation of exceptions and NMI interrupts.

If your interrupt table (IDT or IVT) is insufficiently configured, you're likely to get a double fault that cascades into a triple fault on an instruction that raises a #DE divide exception (interrupt 0).

NMIs don't normally happen without some prior set up to enable something that will raise one. (e.g. enabling a CPU performance counter event.)

Related