Re: Why is flags being backed up before calling cli

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

> I noticed that the flags register is being stored before doing 'cli' and
> then restored after calling 'sti'. - eg. in local_irq_save and
> local_irq_restore
> Can someone tell me the scenario that is being guarded against by backing up
> flags?

There are many functions in the kernel that can be accessed with
interrupts enabled or disabled. A function X has no handy way to know
whether its caller or another function has already disabled
interrupts. However if X unconditionally re-enables interrupts at the
end of its body, a caller that has disabled interrupts prior to
calling it will find that interrupts are enabled once X returns -
something unexpected and unacceptable. local_irq_save and
local_irq_restore ensure that interrupts are re-enabled by the
function of the call stack that actually disabled them.

Alex.

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux