Interrupt Flag - Privilege Level

Privilege Level

In all three cases, only privileged applications (usually the OS kernel) may modify IF. Note that this only applies to protected mode code (real mode code may always modify IF).

CLI and STI are privileged instructions, which trigger a general protection fault if an unprivileged application attempts to execute it, while POPF will simply not modify the IF flag if the application is unprivileged.

The privilege level required to execute a CLI or STI instruction, or set IF using POPF, is not determined by the IOPL (I/O Privilege Level) in EFLAGS. If the IOPL is set to 2 for example, any program running only in ring 0 can execute a CLI. Most modern operating systems set the IOPL to be 0 so only the kernel can execute CLI/STI. The reason for this is that since clearing IF will force the processor to ignore ALL interrupts, the kernel may never get control back if it is not set to 1 again.

Read more about this topic:  Interrupt Flag

Famous quotes containing the words privilege and/or level:

    “Had it not been for you, I should have remained what I was when we first met, a prejudiced, narrow-minded being, with contracted sympathies and false knowledge, wasting my life on obsolete trifles, and utterly insensible to the privilege of living in this wondrous age of change and progress.”
    —Benjamin Disraeli (1804–1881)

    “... when you do get a job everybody says, “Well, they wanted a black woman,” which necessarily puts you on a level where you have to prove yourself above being a woman and being black.... Now, I would say, in certain situations, it helped me simply because I was mildly attractive, not because I was black or a woman. That gets you more mileage than anything else.... God help you if you’re not an attractive woman.”
    —Theresa Brown (b. 1957)