浅谈 arch_local_irq_save 及arm64 debug exceptions

3 篇文章 0 订阅

追__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.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值