On 18-11-07 12:44, Wenhua Zhao wrote:
The macro local_irq_save(x) is defined as the following three
instructions:
1: pushfl 2: popl x 3: cli
It should be possible that a interrupt happens before instruction 3 but
after instruction 1. If the interrupt handler change the EFLAGS
register, the local_irq_save(x) will save the old value to x. How this
problem is avoided in the kernel?
The interrupt handler does not change the flags. Upon handling an interrupt,
the x86 pushes EFLAGS before calling the handler. On an iret, the CPU then
restores them again.
Note that this would ofcourse be a completely generic problem -- if handlers
change flags not _any_ code can rely on them:
or eax, eax
je eax_is_zero_or_some_interrupt_handler_ran_and_did_something
Ofcourse, it's possible to change the stack-copy of the flags from within
the interrupt handler and thereby cause a different value to be reloaded
upon iret, but well, gun, foot, and all that...
Rene.
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ