use hwbreakpoint to debug bad pmd issue

7 篇文章 0 订阅

文章目录

Background

Kernel: linux3.10

发生概率性死机:

mm/memory.c:399: bad pmd 15141312
Segmentation fault
BUG: Bad rss-counter state mm:ce964380 idx:0 val:5
BUG: Bad rss-counter state mm:ce964380 idx:1 val:1

Debug

对发生Segmentation fault的user space process注册signal handler, 发现死机时并没有进入到signal handler中。在kernel __do_uesr_fault中判断SIGSEGV时dump register, rebuild出backtrace, 发现每次都不一样,结合汇编code来看,没有发现可疑的地方。
bad pmd的提示比较怀疑该process的地址空间的pgd已经出现问题,然后再发生的SIGSEGV.
因为是烧机问题,所以利用hw breakpoint来监控process的task_struct的mm->pgd.

hw breakpoint config

CONFIG_HAVE_HW_BREAKPOINT=y
CONFIG_PERF_EVENTS=y
# CONFIG_HAVE_PERF_EVENTS is not sest
# CONFIG_DEBUG_PERF_USE_VMALLOC is not set
# CONFIG_HW_PERF_EVENTS is not set

参考samples/hw_breakpoint/data_breakpoint.c的code对出问题的process的mm->pgd添加写监控。

/* init & register hwbp handler*/
hw_break_module_init()
    -> hw_breakpoint_init()
    -> register_wide_hw_breakpoint(&attr, sample_hbp_handler, NULL)
/* exit & unregister hwbp */
hw_break_module_exit()

然后再重新烧机复制,果然发现pgd有被盖写,通过打印的backtrace即可锁定凶手。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值