追__raw_spin_lock_irqsave 代码时,发现了arch_local_irq_save 这个函数,顺便看了下这个函数
static inline unsigned long arch_local_irq_save(void)
{
unsigned long flags;
asm volatile(
"mrs %0, daif // arch_local_irq_save\n"
"msr daifset, #2"
: "=r" (flags)
:
: "memory");
return flags;
}
函数比较简单,汇编代码中,先把原来的daif (DAIF)寄存器值保存到flags,然后把2写入了daifset 寄存器,也就是屏蔽了除了debug 外所有的exception。
DAIF, Exception mask bits
- D Debug exceptions mask.
- A SError interrupt Process state mask, for example, asynchronous External Abort.
- I IRQ interrupt Process state mask.
- F FIQ interrupt Process state mask.
详见《Programmer’s Guide for ARMv8》
翻了下arm 手册,debug exception 的相关描述如下:
Debug events cause a debug exception if debug logic is configured for self-hosted debug. Debug exception is a synchronous exception that is programmed by the debugger, which is part of the high-level software or operating system. The debugger is also called a self-hosted debugger. ——《Armv8-A self-hosted debug》
简单来说,debug exception 是可以通过指令来产生,用来self-hosted debug 的。所谓self-hosted debug 就是
The self-hosted debug model is used when the debugger is hosted on the Processing Element (PE) that is being debugged. Debug exceptions are the basis of the self-hosted debug model. The debugger programs the debug logic to generate debug events. These debug events then generate debug exceptions.
|