代码如下图所示,最终操作的是msr daifset, #3
和 msr daifclr, #3
寄存器。
(include/linux/irqflags.h)
#define local_irq_enable() do { raw_local_irq_enable(); } while (0)
#define local_irq_disable() do { raw_local_irq_disable(); } while (0)#define raw_local_irq_disable() arch_local_irq_disable()
#define raw_local_irq_enable() arch_local_irq_enable()static inline void arch_local_irq_disable(void)
{if (__irqflags_uses_pmr()) {__pmr_local_irq_disable();} else {__daif_local_irq_disable();}
}static __always_inline void __daif_local_irq_disable(void)
{barrier();asm volatile("msr daifset, #3");barrier();
}30 static __always_inline void __daif_local_irq_enable(void)
31 {
32 barrier();
33 asm volatile("msr daifclr, #3");
34 barrier();
35 }