色哟哟视频在线观看-色哟哟视频在线-色哟哟欧美15最新在线-色哟哟免费在线观看-国产l精品国产亚洲区在线观看-国产l精品国产亚洲区久久

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何解讀內核的oops

嵌入式與Linux那些事 ? 來源:嵌入式與Linux那些事 ? 作者: 仲一 ? 2022-10-21 12:39 ? 次閱讀

OOPS信息解讀

root@firefly:~/mnt/module#insmodoops_module.ko
[867.140514]UnabletohandlekernelNULLpointerdereferenceatvirtualaddress00000000
[867.141279]pgd=ffffffc0f0a65000
[867.141582][00000000]*pgd=0000000000000000,*pud=0000000000000000
[867.142164]Internalerror:Oops:96000045[#1]SMP
[867.142592]Moduleslinkedin:oops_module(O+)
[867.143006]CPU:4PID:1163Comm:insmodTainted:GO4.4.194+#7
[867.143649]Hardwarename:Firefly-RK3399Board(LinuxOpensource)(DT)
[867.144236]task:ffffffc0cdc44380task.stack:ffffffc00a4fc000
[867.144761]PCisatinit_oopsdemo+0x24/0x38[oops_module]
[867.145247]LRisatinit_oopsdemo+0x18/0x38[oops_module]
[867.145732]pc:[]lr:[]pstate:40000145
[867.146386]sp:ffffffc00a4ffc40
[867.146688]x29:ffffffc00a4ffc40x28:ffffff80081376d0
[867.147178]x27:0000000000000001x26:ffffffc0cde6e880
[867.147491]x25:0000000000000001x24:ffffff8000ef2050
[867.147495]x23:0000000000000000x22:ffffff80095b7860
[867.147498]x21:ffffffc0cdce10c0x20:ffffff80095b7860
[867.147501]x19:ffffff8000ef0000x18:ffffff80897bfa97
[867.147504]x17:0000007fb096c8a0x16:ffffff800813b204Segmentationfau
lt
[867.147508]x15:0000000000000000root@firefly:~/mx14:00000000000224d6nt/module#
[867.147511]x13:000000000000000ax12:0000000000000030
[867.147515]x11:00000000fffffffex10:ffffff80097bfa9f
[867.147518]x9:0000000005f5e0ffx8:ffffff8008463c3c
[867.147522]x7:ffffff80096280b0x6:0000000000000022
[867.147525]x5:ffffffc0f7f24b38x4:0000000000000001
[867.147528]x3:0000000000000007x2:0000000000000007
[867.147534]x1:0000000019760817x0:0000000000000000
[867.147536]
[867.147536]PC:0xffffff8000eeffa4:
[867.147550]ffa4****************************************************************
[867.147561]ffc4****************************************************************
[867.147572]ffe4********************************************************a9bf7bfd
[867.147581]0004910003fdaa1e03e0d503201f5800010095ca7426d2800000528102e172a32ec1
[867.147590]0024b9000001a8c17bfdd65f03c000ef1024ffffff80a9bf7bfd910003fdaa1e03e0
[867.147599]0044d503201f5800008095ca7418a8c17bfdd65f03c000ef1038ffffff8000000000
[867.147607]00640000000000000000000000000000000000000000000000000000000000000000
[867.147616]00840000000000000000000000000000000000000000000000000000000000000000
[867.147618]
[867.147618]LR:0xffffff8000eeff98:
[867.147629]ff98****************************************************************
[867.147639]ffb8****************************************************************
[867.147650]ffd8****************************************************************
[867.147659]fff8****************a9bf7bfd910003fdaa1e03e0d503201f5800010095ca7426
[867.147668]0018d2800000528102e172a32ec1b9000001a8c17bfdd65f03c000ef1024ffffff80
[867.147677]0038a9bf7bfd910003fdaa1e03e0d503201f5800008095ca7418a8c17bfdd65f03c0
[867.147685]005800ef1038ffffff80000000000000000000000000000000000000000000000000
[867.147693]00780000000000000000000000000000000000000000000000000000000000000000
[867.147695]
[867.147695]SP:0xffffffc00a4ffbc0:
[867.147705]fbc0095b7860ffffff80000000000000000000ef2050ffffff800000000100000000
[867.147713]fbe0cde6e880ffffffc00000000100000000081376d0ffffff800a4ffc40ffffffc0
[867.147726]fc0000ef0018ffffff800a4ffc40ffffffc000ef0024ffffff804000014500000000
[867.147734]fc20ee9ae0000000004000012ffb0000000000000000000000800000000000000000
[867.147743]fc400a4ffc50ffffffc0080830f8ffffff800a4ffcd0ffffffc00818d2d0ffffff80
[867.147765]fc6000ef2000ffffff80095cd000ffffff80cde6e8c8ffffffc0cdce1140ffffffc0
[867.147774]fc8000000000000000000818d2a4ffffff8000ef2000ffffff80095cd000ffffff80
[867.147782]fca0cde6e8c8ffffffc0095cd000ffffff80000000000000000000ef2050ffffff80
[867.147785]
[867.147785]X5:0xffffffc0f7f24ab8:
[867.147794]4ab80000003f000000000000003f0000000000000000000000000000000000000000
[867.147803]4ad80000000000000000000000000000000000000000000000000000000000000000
[867.147811]4af80000000000000000000000000000000000000000000000000000000000000000
[867.147819]4b18afbe53560000000100000000000000000810d62cffffff800000000100000000
[867.147828]4b38000000070000000000000000000000000810dd18ffffff800000000000000000
[867.147836]4b580000000001400000000000000000e29300000000000000000000000000000000
[867.147845]4b780000000000000000d591d591dead4eadffffffff00000000ffffffffffffffff
[867.147853]4b9800000000000000000008a70b000000010008a701000000010000000d00000000
[867.147855]
[867.147855]X7:0xffffff8009628030:
[867.147863]8030f26a3900ffffffc0000000000000000000000000000000000011000000000000
[867.147872]8050000f000000000000000000000000000000040000000000000008000000000000
[867.147880]80700000000000000000000000000000000000000001000000000000000000000000
[867.147889]80900000000000000001000000000000000100000002000000010000000100000000
[867.147897]80b000000000000000000927e623ffffff8004e804e8dead4eadffffffff00000000
[867.147905]80d0fffffffffffffffff2000000ffffffc000040000000000000000000100000000
[867.147914]80f000000000dead4eadffffffff00000000ffffffffffffffff09628108ffffff80
[867.147922]811009628108ffffff80000000000000000000000000000000000000000000000000
[867.147924]
[867.147924]X8:0xffffff8008463bbc:
[867.147933]3bbc9400054aaa1303e09400055452800000a94153f3f94013f5a8c37bfdd65f03c0
[867.147942]3bdcf940041317fffff6f940081317fffff4f9400c1317fffff2128002a017fffff5
[867.147950]3bfc71001c1f54000161f9405ce0f9400c00b4000140a9bf7bfdaa0603e2aa0403e1
[867.147959]3c1c910003fd940004cea8c17bfdd65f03c0128002a0d65f03c012800160d65f03c0
[867.147967]3c3ca9bb7bfd7100081f910003fda9025bf5aa0403f6a90153f3aa0603f5a90363f7
[867.147975]3c5cf9405cf354000181f9400660b4000a202a1503e2aa1603e19400047d52800000
[867.147984]3c7ca94153f3a9425bf5a94363f7a8c57bfdd65f03c071000c1f54000061f9400a60
[867.147992]3c9c17fffff371001c1f54000061f9400e6017ffffef35000820510004207100041f
[867.147994]
[867.147994]X10:0xffffff80097bfa1f:
[867.148003]fa1c0000000000000000000000000000000000000000000000000000000000000000
[867.148011]fa3c0000000000000000000000000000000000000000000000000000000000000000
[867.148020]fa5c0000000000000000000000000000000000000000000000000000000000000000
[867.148028]fa7c000000000000000000000000000000000000000000000001000000003820205b
[867.148037]fa9c312e37363934373478205d31203a353230303030303030303030303031303030
[867.148045]fabc5d3e342020726c203c5b203a6666666630386666666530303831303070205d3e
[867.148054]fadc7461747334203a65303030300a353431303030300a303030742f0a67296d0a78
[867.148062]fafc3028202c0a2973203331200a3a34353a762033346973726537206e6f2e35332e
[867.148071]fb1c2e34383135722e3132412820617453206e6f69745032502f5746202930204449
[867.148074]
[867.148074]X16:0xffffff800813b184:
[867.148083]b184fa4130029a9f87e2b4000202aa1303e2aa1403e1aa1503e0940e73e9b5000220
[867.148093]b1a4943672e08b1302b58b130294eb1302f754fffde152800002aa1603e1910163a0
[867.148101]b1c497fff7ff17ffffc6aa1303e252800001aa1503e0940e775aaa1303e017fffff0
[867.148110]b1e4f9402fa094021fc6128001a017ffffbc128000e017ffffba1280016017ffffb8
[867.148118]b204a9b67bfd910003fda90153f3f90013f5aa0003f5aa1e03e0aa0103f4aa0203f3
[867.148127]b224d503201fa903ffbfa904ffbfa905ffbfa906ffbfa907ffbfa908ffbff9004fbf
[867.148135]b24497ffefb2340000c093407c00a94153f3f94013f5a8ca7bfdd65f03c0f000b220
[867.148143]b264913d0000910aa00079404401361000e1d00088a12a1303e4aa1403e32a1503e2
[867.148146]
[867.148146]X18:0xffffff80897bfa17:
[867.148157]fa14****************************************************************
[867.148167]fa34****************************************************************
[867.148178]fa54****************************************************************
[867.148189]fa74****************************************************************
[867.148199]fa94****************************************************************
[867.148210]fab4****************************************************************
[867.148221]fad4****************************************************************
[867.148232]faf4****************************************************************
[867.148243]fb14****************************************************************
[867.148244]
[867.148244]X19:0xffffff8000eeff80:
[867.148256]ff80****************************************************************
[867.148271]ffa0****************************************************************
[867.148282]ffc0****************************************************************
[867.148293]ffe0****************************************************************
[867.148303]0000a9bf7bfd910003fdaa1e03e0d503201f5800010095ca7426d2800000528102e1
[867.148311]002072a32ec1b9000001a8c17bfdd65f03c000ef1024ffffff80a9bf7bfd910003fd
[867.148320]0040aa1e03e0d503201f5800008095ca7418a8c17bfdd65f03c000ef1038ffffff80
[867.148328]00600000000000000000000000000000000000000000000000000000000000000000
[867.148330]
[867.148330]X20:0xffffff80095b77e0:
[867.148338]77e00000000000000000000000000000000000000000000000000000000000000000
[867.148346]78000000000000000000000000000000000000000000000000000000000000000000
[867.148355]78200000000000000000000000000000000000000000000000000000000000000000
[867.148363]78400000000000000000000000000000000000000000000000000000000000000000
[867.148372]7860095b7860ffffff80095b7860ffffff80000000010000000000005dc000000000
[867.148380]788000000009756e694c000000780000000000000000000000000000000000000000
[867.148388]78a00000000000000000000000000000000000000000000000000000000000000000
[867.148397]78c00000000072696600796c66650000000000000000000000000000000000000000
[867.148398]
[867.148398]X21:0xffffffc0cdce1040:
[867.148407]1040746f6e2e6e672e6575622e752d646c6900006469dead000000000200dead0000
[867.148415]1060000000010000000000000000000000000000000000000000055aab5600000000
[867.148424]1080cdce1bc0ffffffc0cde6d909ffffffc0cde6d888ffffffc0cdce1bc8ffffffc0
[867.148433]10a00000000000000000000003dd6c62010e6c6b63612e747369666e6f6300000000
[867.148441]10c0cdce1080ffffffc06d6564736f5b206f5f73706f75646f6d005d656c00000000
[867.148449]10e000000000000000000000000f2e2e020200000000000000000000000000000000
[867.148458]11000000000000000000000000000000000000000000000000000000000000000000
[867.148466]11200000000000000000000000000000000000000000000000000000000000000000
[867.148468]
[867.148468]X22:0xffffff80095b77e0:
[867.148476]77e00000000000000000000000000000000000000000000000000000000000000000
[867.148484]78000000000000000000000000000000000000000000000000000000000000000000
[867.148493]78200000000000000000000000000000000000000000000000000000000000000000
[867.148501]78400000000000000000000000000000000000000000000000000000000000000000
[867.148510]7860095b7860ffffff80095b7860ffffff80000000010000000000005dc000000000
[867.148518]788000000009756e694c000000780000000000000000000000000000000000000000
[867.148526]78a00000000000000000000000000000000000000000000000000000000000000000
[867.148535]78c00000000072696600796c66650000000000000000000000000000000000000000
[867.148536]
[867.148536]X24:0xffffff8000ef1fd0:
[867.148545]1fd00000000000000000000000000000000000000000000000000000000000000000
[867.148553]1ff0000000000000000000000000000000000000000100000000095cd3a0ffffff80
[867.148562]2010095cd3a0ffffff8073706f6f646f6d5f00656c75000000000000000000000000
[867.148570]20300000000000000000000000000000000000000000000000000000000000000000
[867.148578]2050f089a080ffffffc0f26add00ffffffc0f2117e88ffffffc0f26add28ffffffc0
[867.148588]2070f26add00ffffffc0095c4c08ffffff80dbb66f78ffffffc00000000300000007
[867.148596]209000ef2000ffffff80000000000000000000000000000000000000000000000000
[867.148605]20b0f2f99c00ffffffc000000000000000000000000000000000f089ab40ffffffc0
[867.148606]
[867.148606]X26:0xffffffc0cde6e800:
[867.148615]e8000000000100000000d11d71a8ffffffc000000000000000000000000000000000
[867.148623]e820cf2e6030ffffffc000000000000000000000046d00000000095c42c8ffffff80
[867.148632]e8400000000000000000f7ec5e68ffffffc000000000000000000000000000000000
[867.148640]e8600000000000000000000000000000000000000000000000000000000000000000
[867.148649]e880f106a880ffffffc00000000100000000f089aa40ffffffc00000012400000000
[867.148657]e8a0000000240000000000ef1000ffffff80081375b0ffffff800000000000000000
[867.148665]e8c00000000000000000000000000000000000000000000000000000000000000000
[867.148674]e8e00000000000000000000000000000000000000000000000000000000000000000
[867.148675]
[867.148675]X28:0xffffff8008137650:
[867.148684]7650a90153f3aa0103f4aa0203f3aa1e03e0d503201ff0008f21913a1c21f9402280
[867.148693]7670b941d802aa1303e0940eb71d93407c00a94153f3a8c27bfdd65f03c0a9be7bfd
[867.148701]7690910003fda90153f3aa0103f4aa0203f3aa1e03e0d503201ff0008f21913a1c21
[867.148710]76b0f9402280b9418802aa1303e0940eb70c93407c00a94153f3a8c27bfdd65f03c0
[867.148718]76d0a9be7bfd910003fda90153f3aa0003f4aa0203f3aa1e03e0d503201faa1303e0
[867.148727]76f0b0008b61f940228291068021940eb6fc93407c00a94153f3a8c27bfdd65f03c0
[867.148735]7710a9be7bfd910003fda90153f3aa0003f3aa0103f4aa1e03e0d503201f52801801
[867.148743]7730aa1403e072a048019401c11af9006260a94153f3a8c27bfdd65f03c0a9be7bfd
[867.148745]
[867.148745]X29:0xffffffc00a4ffbc0:
[867.148754]fbc0095b7860ffffff80000000000000000000ef2050ffffff800000000100000000
[867.148763]fbe0cde6e880ffffffc00000000100000000081376d0ffffff800a4ffc40ffffffc0
[867.148771]fc0000ef0018ffffff800a4ffc40ffffffc000ef0024ffffff804000014500000000
[867.148780]fc20ee9ae0000000004000012ffb0000000000000000000000800000000000000000
[867.148790]fc400a4ffc50ffffffc0080830f8ffffff800a4ffcd0ffffffc00818d2d0ffffff80
[867.148798]fc6000ef2000ffffff80095cd000ffffff80cde6e8c8ffffffc0cdce1140ffffffc0
[867.148807]fc8000000000000000000818d2a4ffffff8000ef2000ffffff80095cd000ffffff80
[867.148815]fca0cde6e8c8ffffffc0095cd000ffffff80000000000000000000ef2050ffffff80
[867.148816]
[867.148820]Processinsmod(pid:1163,stacklimit=0xffffffc00a4fc000)
[867.148822]Stack:(0xffffffc00a4ffc40to0xffffffc00a500000)
[867.148826]fc40:ffffffc00a4ffc50ffffff80080830f8ffffffc00a4ffcd0ffffff800818d2d0
[867.148829]fc60:ffffff8000ef2000ffffff80095cd000ffffffc0cde6e8c8ffffffc0cdce1140
[867.148832]fc80:0000000000000000ffffff800818d2a4ffffff8000ef2000ffffff80095cd000
[867.148834]fca0:ffffffc0cde6e8c8ffffff80095cd0000000000000000000ffffff8000ef2050
[867.148837]fcc0:0000000000000001ffffffc0cde6e880ffffffc00a4ffd00ffffff800813ab5c
[867.148840]fce0:ffffff8000ef2000ffffffc00a4ffe58ffffffc0cde6e8c8ffffff80095cd000
[867.148843]fd00:ffffffc00a4ffe20ffffff800813b2b4000000000000000000000055736b60f0
[867.148846]fd20:00000000000000030000007fb096c8c400000000400000000000000000000015
[867.148849]fd40:000000000000011d0000000000000111ffffff8008ef2000ffffffc0cdc44380
[867.148851]fd60:0000000000000000000000000002c098ffffffc00a4ffe20ffffff8008f00000
[867.148854]fd80:000000000000000000000055736b60f0ffffffc000000064ffffff8000000072
[867.148857]fda0:ffffff800000006effffff800000003fffffff800000012400000000024000c0
[867.148860]fdc0:ffff81b400000030000003e80000000100000000000003e8000000000002c098
[867.148862]fde0:00000000633eccfc000000000000000000000000000000000000000000000000
[867.148865]fe00:0000000000000000000000000000000000000000000000000000000000000000
[867.148868]fe20:0000000000000000ffffff8008082f70000000000000000000000040ee9ae000
[867.148871]fe40:ffffffffffffffff00000000000000010000000000000002ffffff800bea0000
[867.148874]fe60:000000000002c098ffffff800becb9d8ffffff800becb8d0ffffff800beb7748
[867.148876]fe80:000000000000300000000000000030d800000000000000000000000000000000
[867.148879]fea0:00000000000004780000001a0000001900000000000000090000000000000004
[867.148882]fec0:000000000000000300000055736b60f000000000000000000000000000000003
[867.148884]fee0:0000000000000000000000000000021800000000000000010000000000000001
[867.148887]ff00:0000000000000111000000000000000300000002000000020000000000000000
[867.148890]ff20:00000000000010f0000000000000000000000000000000000000000000000040
[867.148892]ff40:00000055736cddb00000007fb096c8a000000000000000000000005585e6b600
[867.148895]ff60:00000055736b60f0000000000000000000000000000000000000005585e6b5d0
[867.148898]ff80:00000055736b2ef8000000000000000000000000000000000000000000000000
[867.148901]ffa0:00000000000000000000007fdbea3bd000000055736abdc00000007fdbea3bd0
[867.148903]ffc0:0000007fb096c8c4000000004000000000000000000000030000000000000111
[867.148906]ffe0:0000000000000000000000000000000000000000000000000000000000000000
[867.148907]Calltrace:
[867.148911]Exceptionstack(0xffffffc00a4ffa70to0xffffffc00a4ffba0)
[867.148913]fa60:ffffff8000ef00000000008000000000
[867.148916]fa80:ffffffc00a4ffc40ffffff8000ef0024ffffff80097c02f80000000000000002
[867.148918]faa0:ffffffc00a4ffac0000000020001b57c00000000000000000000000100000000
[867.148921]fac0:ffffffc00a4ffb60ffffff800810d674ffffffc00a4ffbc0ffffff8000ef1024
[867.148924]fae0:ffffffc0cdce10c0ffffff80095b78600000000000000000ffffff8000ef2050
[867.148927]fb00:0000000000000001ffffffc0cde6e88000000000000000000000000019760817
[867.148929]fb20:000000000000000700000000000000070000000000000001ffffffc0f7f24b38
[867.148932]fb40:0000000000000022ffffff80096280b0ffffff8008463c3c0000000005f5e0ff
[867.148935]fb60:ffffff80097bfa9f00000000fffffffe0000000000000030000000000000000a
[867.148937]fb80:00000000000224d60000000000000000ffffff800813b2040000007fb096c8a0
[867.148944][]init_oopsdemo+0x24/0x38[oops_module]
[867.148953][]do_one_initcall+0x78/0x194
[867.148958][]do_init_module+0x64/0x1c0
[867.148962][]load_module+0x199c/0x1ed0
[867.148964][]SyS_finit_module+0xb0/0xbc
[867.148968][]el0_svc_naked+0x24/0x28
[867.148972]Code:95ca7426d2800000528102e172a32ec1(b9000001)
[867.148975]---[endtrace1983a52768236533]---
[867.140514]UnabletohandlekernelNULLpointerdereferenceatvirtualaddress00000000

這里能夠簡要的告訴是什么問題觸發了oops,顯然是由于訪問非法地址00000000異常。如果是由代碼直接調用BUG()/BUG_ON()一類的,還能給出源代碼中觸發的行號。

[867.141279]pgd=ffffffc0f0a65000
[867.141582][00000000]*pgd=0000000000000000,*pud=0000000000000000

pgd,pud試圖訪問的地址的頁表信息,本例中為0。

[867.142164]Internalerror:Oops:96000045[#1]SMP

96000045表示錯誤碼。后面[]內的數值是與頁面有關的oops信息被顯示的次數。之后顯示內核的重要特性SMP和PREEMPT被顯示的配置情況。這條信息所在的內核啟用了SMP支持,所以只顯示SMP。

96000045這種錯誤碼我也是第一次見,內核中也沒找到。一般見的最多的就是001,002這種形式的?有大佬知道原因的可以評論下。

Oops的錯誤代碼根據錯誤的原因會有不同的定義,如果發現自己遇到的Oops和下面無法對應的話,最好去內核代碼里查找:

* error_code:* bit 0 == 0 means no page found, 1 means protection fault* bit 1 == 0 means read, 1 means write* bit 2 == 0 means kernel, 1 means user-mode* bit 3 == 0 means data, 1 means instruction

[867.142592]Moduleslinkedin:oops_module(O+)[lastunloaded:hello_module]

Modules linked in為加載了的模塊列表,hello_module為上次加載的模塊。

[867.143006]CPU:4PID:1163Comm:insmodTainted:GO4.4.194+#7
[867.143649]Hardwarename:Firefly-RK3399Board(LinuxOpensource)(DT)
[867.144236]task:ffffffc0cdc44380task.stack:ffffffc00a4fc000

CPU后的數字是錯誤所在邏輯CPU的編號,PID表示正在運行的進程ID1511,內核污染原因(G),內核版本( 4.4.194)。

內核污染原因包括私有驅動加載(P),模塊強制加載(F),模塊強制卸載(R),機器檢查異常發生(M),檢測到錯誤頁(B)等。

如果涉及到了某項原因,就會顯示為Tainted: G PF R這樣。如果不存在問題,就會顯示為Not Tainted。

其中Tainted的表示可以從內核中 kernel/panic.c 中找到:

Tainted 描述
‘G’ if all modules loaded have a GPL or compatible license
‘P’ if any proprietary module has been loaded. Modules without a MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by insmod as GPL compatible are assumed to be proprietary.
‘F’ if any module was force loaded by “insmod -f”.
‘S’ if the Oops occurred on an SMP kernel running on hardware that hasn’t been certified as safe to run multiprocessor. Currently this occurs only on various Athlons that are not SMP capable.
‘R’ if a module was force unloaded by “rmmod -f”.
‘M’ if any processor has reported a Machine Check Exception.
‘B’ if a page-release function has found a bad page reference or some unexpected page flags.
‘U’ if a user or user application specifically requested that the Tainted flag be set.
‘D’ if the kernel has died recently, i.e. there was an OOPS or BUG.
‘W’ if a warning has previously been issued by the kernel.
‘C’ if a staging module / driver has been loaded.
‘I’ if the kernel is working around a sever bug in the platform’s firmware (BIOS or similar).

Hardware name表示硬件平臺的名稱。

task表示當前進程的地址, task.stack表示當前進程棧的地址。

[867.144761]PCisatinit_oopsdemo+0x24/0x38[oops_module]
[867.145247]LRisatinit_oopsdemo+0x18/0x38[oops_module]
[867.145732]pc:[]lr:[]pstate:40000145
[867.146386]sp:ffffffc00a4ffc40

init_oopsdemo+0x24/0x38[oops_module]表示錯誤發生的地址是oops_module中的init_oopsdemo函數的第44個字節,0x38表示init_oopsdemo函數的大小。

第3行,第4行分別是PC,LR,SP寄存器的具體地址。

[867.146688]x29:ffffffc00a4ffc40x28:ffffff80081376d0
[867.147178]x27:0000000000000001x26:ffffffc0cde6e880
[867.147491]x25:0000000000000001x24:ffffff8000ef2050
[867.147495]x23:0000000000000000x22:ffffff80095b7860
[867.147498]x21:ffffffc0cdce10c0x20:ffffff80095b7860
[867.147501]x19:ffffff8000ef0000x18:ffffff80897bfa97
[867.147504]x17:0000007fb096c8a0x16:ffffff800813b204Segmentationfau
lt
[867.147508]x15:0000000000000000root@firefly:~/mx14:00000000000224d6nt/module#
[867.147511]x13:000000000000000ax12:0000000000000030
[867.147515]x11:00000000fffffffex10:ffffff80097bfa9f
[867.147518]x9:0000000005f5e0ffx8:ffffff8008463c3c
[867.147522]x7:ffffff80096280b0x6:0000000000000022
[867.147525]x5:ffffffc0f7f24b38x4:0000000000000001
[867.147528]x3:0000000000000007x2:0000000000000007
[867.147534]x1:0000000019760817x0:0000000000000000
[867.147536]
[867.147536]PC:0xffffff8000eeffa4:
[867.147550]ffa4****************************************************************
[867.147561]ffc4****************************************************************
[867.147572]ffe4********************************************************a9bf7bfd
[867.147581]0004910003fdaa1e03e0d503201f5800010095ca7426d2800000528102e172a32ec1
[867.147590]0024b9000001a8c17bfdd65f03c000ef1024ffffff80a9bf7bfd910003fdaa1e03e0
[867.147599]0044d503201f5800008095ca7418a8c17bfdd65f03c000ef1038ffffff8000000000
[867.147607]00640000000000000000000000000000000000000000000000000000000000000000
[867.147616]00840000000000000000000000000000000000000000000000000000000000000000
[867.147618]
[867.147618]LR:0xffffff8000eeff98:
[867.147629]ff98****************************************************************
[867.147639]ffb8****************************************************************
[867.147650]ffd8****************************************************************
[867.147659]fff8****************a9bf7bfd910003fdaa1e03e0d503201f5800010095ca7426
[867.147668]0018d2800000528102e172a32ec1b9000001a8c17bfdd65f03c000ef1024ffffff80
[867.147677]0038a9bf7bfd910003fdaa1e03e0d503201f5800008095ca7418a8c17bfdd65f03c0
[867.147685]005800ef1038ffffff80000000000000000000000000000000000000000000000000
[867.147693]00780000000000000000000000000000000000000000000000000000000000000000
[867.147695]
[867.147695]SP:0xffffffc00a4ffbc0:
[867.147705]fbc0095b7860ffffff80000000000000000000ef2050ffffff800000000100000000
[867.147713]fbe0cde6e880ffffffc00000000100000000081376d0ffffff800a4ffc40ffffffc0
[867.147726]fc0000ef0018ffffff800a4ffc40ffffffc000ef0024ffffff804000014500000000
[867.147734]fc20ee9ae0000000004000012ffb0000000000000000000000800000000000000000
[867.147743]fc400a4ffc50ffffffc0080830f8ffffff800a4ffcd0ffffffc00818d2d0ffffff80
[867.147765]fc6000ef2000ffffff80095cd000ffffff80cde6e8c8ffffffc0cdce1140ffffffc0
[867.147774]fc8000000000000000000818d2a4ffffff8000ef2000ffffff80095cd000ffffff80
[867.147782]fca0cde6e8c8ffffffc0095cd000ffffff80000000000000000000ef2050ffffff80
[867.147785]
[867.147785]X5:0xffffffc0f7f24ab8:
[867.147794]4ab80000003f000000000000003f0000000000000000000000000000000000000000
[867.147803]4ad80000000000000000000000000000000000000000000000000000000000000000
[867.147811]4af80000000000000000000000000000000000000000000000000000000000000000
[867.147819]4b18afbe53560000000100000000000000000810d62cffffff800000000100000000
[867.147828]4b38000000070000000000000000000000000810dd18ffffff800000000000000000
[867.147836]4b580000000001400000000000000000e29300000000000000000000000000000000
[867.147845]4b780000000000000000d591d591dead4eadffffffff00000000ffffffffffffffff
[867.147853]4b9800000000000000000008a70b000000010008a701000000010000000d00000000
[867.147855]
[867.147855]X7:0xffffff8009628030:
[867.147863]8030f26a3900ffffffc0000000000000000000000000000000000011000000000000
[867.147872]8050000f000000000000000000000000000000040000000000000008000000000000
[867.147880]80700000000000000000000000000000000000000001000000000000000000000000
[867.147889]80900000000000000001000000000000000100000002000000010000000100000000
[867.147897]80b000000000000000000927e623ffffff8004e804e8dead4eadffffffff00000000
[867.147905]80d0fffffffffffffffff2000000ffffffc000040000000000000000000100000000
[867.147914]80f000000000dead4eadffffffff00000000ffffffffffffffff09628108ffffff80
[867.147922]811009628108ffffff80000000000000000000000000000000000000000000000000
[867.147924]
[867.147924]X8:0xffffff8008463bbc:
[867.147933]3bbc9400054aaa1303e09400055452800000a94153f3f94013f5a8c37bfdd65f03c0
[867.147942]3bdcf940041317fffff6f940081317fffff4f9400c1317fffff2128002a017fffff5
[867.147950]3bfc71001c1f54000161f9405ce0f9400c00b4000140a9bf7bfdaa0603e2aa0403e1
[867.147959]3c1c910003fd940004cea8c17bfdd65f03c0128002a0d65f03c012800160d65f03c0
[867.147967]3c3ca9bb7bfd7100081f910003fda9025bf5aa0403f6a90153f3aa0603f5a90363f7
[867.147975]3c5cf9405cf354000181f9400660b4000a202a1503e2aa1603e19400047d52800000
[867.147984]3c7ca94153f3a9425bf5a94363f7a8c57bfdd65f03c071000c1f54000061f9400a60
[867.147992]3c9c17fffff371001c1f54000061f9400e6017ffffef35000820510004207100041f
[867.147994]
[867.147994]X10:0xffffff80097bfa1f:
[867.148003]fa1c0000000000000000000000000000000000000000000000000000000000000000
[867.148011]fa3c0000000000000000000000000000000000000000000000000000000000000000
[867.148020]fa5c0000000000000000000000000000000000000000000000000000000000000000
[867.148028]fa7c000000000000000000000000000000000000000000000001000000003820205b
[867.148037]fa9c312e37363934373478205d31203a353230303030303030303030303031303030
[867.148045]fabc5d3e342020726c203c5b203a6666666630386666666530303831303070205d3e
[867.148054]fadc7461747334203a65303030300a353431303030300a303030742f0a67296d0a78
[867.148062]fafc3028202c0a2973203331200a3a34353a762033346973726537206e6f2e35332e
[867.148071]fb1c2e34383135722e3132412820617453206e6f69745032502f5746202930204449
[867.148074]
[867.148074]X16:0xffffff800813b184:
[867.148083]b184fa4130029a9f87e2b4000202aa1303e2aa1403e1aa1503e0940e73e9b5000220
[867.148093]b1a4943672e08b1302b58b130294eb1302f754fffde152800002aa1603e1910163a0
[867.148101]b1c497fff7ff17ffffc6aa1303e252800001aa1503e0940e775aaa1303e017fffff0
[867.148110]b1e4f9402fa094021fc6128001a017ffffbc128000e017ffffba1280016017ffffb8
[867.148118]b204a9b67bfd910003fda90153f3f90013f5aa0003f5aa1e03e0aa0103f4aa0203f3
[867.148127]b224d503201fa903ffbfa904ffbfa905ffbfa906ffbfa907ffbfa908ffbff9004fbf
[867.148135]b24497ffefb2340000c093407c00a94153f3f94013f5a8ca7bfdd65f03c0f000b220
[867.148143]b264913d0000910aa00079404401361000e1d00088a12a1303e4aa1403e32a1503e2
[867.148146]
[867.148146]X18:0xffffff80897bfa17:
[867.148157]fa14****************************************************************
[867.148167]fa34****************************************************************
[867.148178]fa54****************************************************************
[867.148189]fa74****************************************************************
[867.148199]fa94****************************************************************
[867.148210]fab4****************************************************************
[867.148221]fad4****************************************************************
[867.148232]faf4****************************************************************
[867.148243]fb14****************************************************************
[867.148244]
[867.148244]X19:0xffffff8000eeff80:
[867.148256]ff80****************************************************************
[867.148271]ffa0****************************************************************
[867.148282]ffc0****************************************************************
[867.148293]ffe0****************************************************************
[867.148303]0000a9bf7bfd910003fdaa1e03e0d503201f5800010095ca7426d2800000528102e1
[867.148311]002072a32ec1b9000001a8c17bfdd65f03c000ef1024ffffff80a9bf7bfd910003fd
[867.148320]0040aa1e03e0d503201f5800008095ca7418a8c17bfdd65f03c000ef1038ffffff80
[867.148328]00600000000000000000000000000000000000000000000000000000000000000000
[867.148330]
[867.148330]X20:0xffffff80095b77e0:
[867.148338]77e00000000000000000000000000000000000000000000000000000000000000000
[867.148346]78000000000000000000000000000000000000000000000000000000000000000000
[867.148355]78200000000000000000000000000000000000000000000000000000000000000000
[867.148363]78400000000000000000000000000000000000000000000000000000000000000000
[867.148372]7860095b7860ffffff80095b7860ffffff80000000010000000000005dc000000000
[867.148380]788000000009756e694c000000780000000000000000000000000000000000000000
[867.148388]78a00000000000000000000000000000000000000000000000000000000000000000
[867.148397]78c00000000072696600796c66650000000000000000000000000000000000000000
[867.148398]
[867.148398]X21:0xffffffc0cdce1040:
[867.148407]1040746f6e2e6e672e6575622e752d646c6900006469dead000000000200dead0000
[867.148415]1060000000010000000000000000000000000000000000000000055aab5600000000
[867.148424]1080cdce1bc0ffffffc0cde6d909ffffffc0cde6d888ffffffc0cdce1bc8ffffffc0
[867.148433]10a00000000000000000000003dd6c62010e6c6b63612e747369666e6f6300000000
[867.148441]10c0cdce1080ffffffc06d6564736f5b206f5f73706f75646f6d005d656c00000000
[867.148449]10e000000000000000000000000f2e2e020200000000000000000000000000000000
[867.148458]11000000000000000000000000000000000000000000000000000000000000000000
[867.148466]11200000000000000000000000000000000000000000000000000000000000000000
[867.148468]
[867.148468]X22:0xffffff80095b77e0:
[867.148476]77e00000000000000000000000000000000000000000000000000000000000000000
[867.148484]78000000000000000000000000000000000000000000000000000000000000000000
[867.148493]78200000000000000000000000000000000000000000000000000000000000000000
[867.148501]78400000000000000000000000000000000000000000000000000000000000000000
[867.148510]7860095b7860ffffff80095b7860ffffff80000000010000000000005dc000000000
[867.148518]788000000009756e694c000000780000000000000000000000000000000000000000
[867.148526]78a00000000000000000000000000000000000000000000000000000000000000000
[867.148535]78c00000000072696600796c66650000000000000000000000000000000000000000
[867.148536]
[867.148536]X24:0xffffff8000ef1fd0:
[867.148545]1fd00000000000000000000000000000000000000000000000000000000000000000
[867.148553]1ff0000000000000000000000000000000000000000100000000095cd3a0ffffff80
[867.148562]2010095cd3a0ffffff8073706f6f646f6d5f00656c75000000000000000000000000
[867.148570]20300000000000000000000000000000000000000000000000000000000000000000
[867.148578]2050f089a080ffffffc0f26add00ffffffc0f2117e88ffffffc0f26add28ffffffc0
[867.148588]2070f26add00ffffffc0095c4c08ffffff80dbb66f78ffffffc00000000300000007
[867.148596]209000ef2000ffffff80000000000000000000000000000000000000000000000000
[867.148605]20b0f2f99c00ffffffc000000000000000000000000000000000f089ab40ffffffc0
[867.148606]
[867.148606]X26:0xffffffc0cde6e800:
[867.148615]e8000000000100000000d11d71a8ffffffc000000000000000000000000000000000
[867.148623]e820cf2e6030ffffffc000000000000000000000046d00000000095c42c8ffffff80
[867.148632]e8400000000000000000f7ec5e68ffffffc000000000000000000000000000000000
[867.148640]e8600000000000000000000000000000000000000000000000000000000000000000
[867.148649]e880f106a880ffffffc00000000100000000f089aa40ffffffc00000012400000000
[867.148657]e8a0000000240000000000ef1000ffffff80081375b0ffffff800000000000000000
[867.148665]e8c00000000000000000000000000000000000000000000000000000000000000000
[867.148674]e8e00000000000000000000000000000000000000000000000000000000000000000
[867.148675]
[867.148675]X28:0xffffff8008137650:
[867.148684]7650a90153f3aa0103f4aa0203f3aa1e03e0d503201ff0008f21913a1c21f9402280
[867.148693]7670b941d802aa1303e0940eb71d93407c00a94153f3a8c27bfdd65f03c0a9be7bfd
[867.148701]7690910003fda90153f3aa0103f4aa0203f3aa1e03e0d503201ff0008f21913a1c21
[867.148710]76b0f9402280b9418802aa1303e0940eb70c93407c00a94153f3a8c27bfdd65f03c0
[867.148718]76d0a9be7bfd910003fda90153f3aa0003f4aa0203f3aa1e03e0d503201faa1303e0
[867.148727]76f0b0008b61f940228291068021940eb6fc93407c00a94153f3a8c27bfdd65f03c0
[867.148735]7710a9be7bfd910003fda90153f3aa0003f3aa0103f4aa1e03e0d503201f52801801
[867.148743]7730aa1403e072a048019401c11af9006260a94153f3a8c27bfdd65f03c0a9be7bfd
[867.148745]
[867.148745]X29:0xffffffc00a4ffbc0:
[867.148754]fbc0095b7860ffffff80000000000000000000ef2050ffffff800000000100000000
[867.148763]fbe0cde6e880ffffffc00000000100000000081376d0ffffff800a4ffc40ffffffc0
[867.148771]fc0000ef0018ffffff800a4ffc40ffffffc000ef0024ffffff804000014500000000
[867.148780]fc20ee9ae0000000004000012ffb0000000000000000000000800000000000000000
[867.148790]fc400a4ffc50ffffffc0080830f8ffffff800a4ffcd0ffffffc00818d2d0ffffff80
[867.148798]fc6000ef2000ffffff80095cd000ffffff80cde6e8c8ffffffc0cdce1140ffffffc0
[867.148807]fc8000000000000000000818d2a4ffffff8000ef2000ffffff80095cd000ffffff80
[867.148815]fca0cde6e8c8ffffffc0095cd000ffffff80000000000000000000ef2050ffffff80
[867.148816]

上面打印出的這些都是異常發生時寄存器的值。

PC:PC也叫計數寄存器,用于存放下一條要執行的指令的地址,因此在子程序返回后,要將LR中的地址存入PC,即mov PC LR。

LR:子程序的返回地址:從子程序返回后,主程序繼續執行的指令的地址稱為子程序的返回地址.LR也叫鏈接寄存器,用于存放子程序的返回地址。在要進入子程序之前,先將子程序的返回地址存入LR

SP:SP也叫堆棧寄存器,用于存放要執行的數據。

X0~X7:傳遞子程序的參數和返回值,使用時不需要保存,多余的參數用堆棧傳遞,64位的返回結果保存在x0中。

X8:用于保存子程序的返回地址,使用時不需要保存。

X9~X15:臨時寄存器,也叫可變寄存器,子程序使用時不需要保存。

X16~X17:子程序內部調用寄存器(IPx),使用時不需要保存,盡量不要使用。

X18:平臺寄存器,它的使用與平臺相關,盡量不要使用。

X19~X28:臨時寄存器,子程序使用時必須保存。

X29:幀指針寄存器(FP),用于連接棧幀,使用時必須保存。

X30:鏈接寄存器(LR),用于保存子程序的返回地址。

X31:堆棧指針寄存器(SP),用于指向每個函數的棧頂。

[867.148820]Processinsmod(pid:1163,stacklimit=0xffffffc00a4fc000)
[867.148822]Stack:(0xffffffc00a4ffc40to0xffffffc00a500000)
[867.148826]fc40:ffffffc00a4ffc50ffffff80080830f8ffffffc00a4ffcd0ffffff800818d2d0
[867.148829]fc60:ffffff8000ef2000ffffff80095cd000ffffffc0cde6e8c8ffffffc0cdce1140
[867.148832]fc80:0000000000000000ffffff800818d2a4ffffff8000ef2000ffffff80095cd000
[867.148834]fca0:ffffffc0cde6e8c8ffffff80095cd0000000000000000000ffffff8000ef2050
[867.148837]fcc0:0000000000000001ffffffc0cde6e880ffffffc00a4ffd00ffffff800813ab5c
[867.148840]fce0:ffffff8000ef2000ffffffc00a4ffe58ffffffc0cde6e8c8ffffff80095cd000
[867.148843]fd00:ffffffc00a4ffe20ffffff800813b2b4000000000000000000000055736b60f0
[867.148846]fd20:00000000000000030000007fb096c8c400000000400000000000000000000015
[867.148849]fd40:000000000000011d0000000000000111ffffff8008ef2000ffffffc0cdc44380
[867.148851]fd60:0000000000000000000000000002c098ffffffc00a4ffe20ffffff8008f00000
[867.148854]fd80:000000000000000000000055736b60f0ffffffc000000064ffffff8000000072
[867.148857]fda0:ffffff800000006effffff800000003fffffff800000012400000000024000c0
[867.148860]fdc0:ffff81b400000030000003e80000000100000000000003e8000000000002c098
[867.148862]fde0:00000000633eccfc000000000000000000000000000000000000000000000000
[867.148865]fe00:0000000000000000000000000000000000000000000000000000000000000000
[867.148868]fe20:0000000000000000ffffff8008082f70000000000000000000000040ee9ae000
[867.148871]fe40:ffffffffffffffff00000000000000010000000000000002ffffff800bea0000
[867.148874]fe60:000000000002c098ffffff800becb9d8ffffff800becb8d0ffffff800beb7748
[867.148876]fe80:000000000000300000000000000030d800000000000000000000000000000000
[867.148879]fea0:00000000000004780000001a0000001900000000000000090000000000000004
[867.148882]fec0:000000000000000300000055736b60f000000000000000000000000000000003
[867.148884]fee0:0000000000000000000000000000021800000000000000010000000000000001
[867.148887]ff00:0000000000000111000000000000000300000002000000020000000000000000
[867.148890]ff20:00000000000010f0000000000000000000000000000000000000000000000040
[867.148892]ff40:00000055736cddb00000007fb096c8a000000000000000000000005585e6b600
[867.148895]ff60:00000055736b60f0000000000000000000000000000000000000005585e6b5d0
[867.148898]ff80:00000055736b2ef8000000000000000000000000000000000000000000000000
[867.148901]ffa0:00000000000000000000007fdbea3bd000000055736abdc00000007fdbea3bd0
[867.148903]ffc0:0000007fb096c8c4000000004000000000000000000000030000000000000111
[867.148906]ffe0:0000000000000000000000000000000000000000000000000000000000000000

stack limit顯示的大小為kstack內核選項指定的大小。Stack 是棧開頭部分的值。

[867.148907]Calltrace:
[867.148911]Exceptionstack(0xffffffc00a4ffa70to0xffffffc00a4ffba0)
[867.148913]fa60:ffffff8000ef00000000008000000000
[867.148916]fa80:ffffffc00a4ffc40ffffff8000ef0024ffffff80097c02f80000000000000002
[867.148918]faa0:ffffffc00a4ffac0000000020001b57c00000000000000000000000100000000
[867.148921]fac0:ffffffc00a4ffb60ffffff800810d674ffffffc00a4ffbc0ffffff8000ef1024
[867.148924]fae0:ffffffc0cdce10c0ffffff80095b78600000000000000000ffffff8000ef2050
[867.148927]fb00:0000000000000001ffffffc0cde6e88000000000000000000000000019760817
[867.148929]fb20:000000000000000700000000000000070000000000000001ffffffc0f7f24b38
[867.148932]fb40:0000000000000022ffffff80096280b0ffffff8008463c3c0000000005f5e0ff
[867.148935]fb60:ffffff80097bfa9f00000000fffffffe0000000000000030000000000000000a
[867.148937]fb80:00000000000224d60000000000000000ffffff800813b2040000007fb096c8a0
[867.148944][]init_oopsdemo+0x24/0x38[oops_module]
[867.148953][]do_one_initcall+0x78/0x194
[867.148958][]do_init_module+0x64/0x1c0
[867.148962][]load_module+0x199c/0x1ed0
[867.148964][]SyS_finit_module+0xb0/0xbc
[867.148968][]el0_svc_naked+0x24/0x28

棧回溯信息,可以從中看出函數調用關系

[867.148972]Code:95ca7426d2800000528102e172a32ec1(b9000001)
[867.148975]---[endtrace1983a52768236533]---
Segmentationfault

code是錯誤發生時PC指向的地址處的開頭20字節的代碼,括號里的是出錯的具體指令。

如何根據OOPS找出bug

確定出錯位置在內核函數還是驅動

System.map文件記錄了所有符號的運行地址,這里的符號可以理解成函數名和變量。

System.map一般在內核編譯完成后,根目錄下生成。

0000000000000000A__rela_size
0000000000000000A_kernel_flags_le_hi32
0000000000000000A_kernel_offset_le_hi32
0000000000000000A_kernel_size_le_hi32
000000000000000aA_kernel_flags_le_lo32
0000000000000200APECOFF_FILE_ALIGNMENT
0000000000080000A_kernel_offset_le_lo32
000000000159e638A__rela_offset
0000000001800000A_kernel_size_le_lo32
ffffff8008080000t_head
ffffff8008080000T_text
ffffff8008080800T__exception_text_start
ffffff8008080800T_stext
ffffff8008080800Tdo_undefinstr
ffffff8008080a18Tdo_sysinstr
ffffff8008080ab4Tdo_mem_abort
ffffff8008080b60Tdo_sp_pc_abort
ffffff8008080c34Tdo_debug_exceptio
.............
ffffff8009879a48b__key.30413
ffffff8009879a48b__key.30416
ffffff8009879a48b__key.48814
ffffff8009879a48b__key.48818
ffffff8009879a48b__key.48819
ffffff8009879a48b__key.48820
ffffff8009879a48b__key.48821
ffffff800987a000Bidmap_pg_dir
ffffff800987d000Bswapper_pg_dir
ffffff800987f000Btramp_pg_dir
ffffff8009880000B_end

System.map中內核函數的范圍是:ffffff8008080000 ~ ffffff8009880000。而PC出錯的位置是ffffff8000ef0024。

所以,可以判定不是內核函數出錯引起的,而是某個驅動模塊。

如果把oops_module.ko直接編譯進ko中,就是內核引起的錯誤了。PC出錯時的地址也會剛好在System.map中。

匯編驅動文件

而OOPS信息也告訴我們,錯誤是出在了init_oopsdemo。

[17981.657899]PCisatinit_oopsdemo+0x24/0x38[oops_module]
[17981.658385]LRisatinit_oopsdemo+0x18/0x38[oops_module]

那如果OOPS沒有打印出出錯驅動的名字呢?

我們可以使用 cat /proc/kallsyms > kallsyms.txt命令,在kallsyms.txt中找出與PC值接近的符號。kallsyms.txt內容如下。

ffffff8008080800Tdo_undefinstr
ffffff8008080800T_stext
ffffff8008080800T__exception_text_start
ffffff8008080a18Tdo_sysinstr
ffffff8008080ab4Tdo_mem_abort
ffffff8008080b60Tdo_sp_pc_abort
ffffff8008080c34Tdo_debug_exception
.........
ffffff80094cfc0cTsparse_mem_map_populate
ffffff80094cfc64T_einittext
0000000000000000aoops_module.c[oops_module]
ffffff8000ef0000t$x[oops_module]
ffffff8000ef0000tinit_oopsdemo[oops_module]
ffffff8000ef0030t$d[oops_module]
ffffff8000ef0038t$x[oops_module]
ffffff8000ef0038tcleanup_oopsdemo[oops_module]
ffffff8000ef0058t$d[oops_module]
ffffff800bee40c8?__UNIQUE_ID_license2[oops_module]
ffffff800bee40d4?__UNIQUE_ID_author1[oops_module]
ffffff800bee40e3?__UNIQUE_ID_license0[oops_module]
ffffff800befb368n$d[oops_module]
0000000000000000aoops_module.mod.c[oops_module]
ffffff8000ef2000d$d[oops_module]
ffffff800bee40f8?$d[oops_module]
ffffff800bee40f8?__module_depends[oops_module]
ffffff800bee4101?__UNIQUE_ID_vermagic0[oops_module]
ffffff8000ef2000d__this_module[oops_module]
ffffff8000ef0038tcleanup_module[oops_module]
ffffff8000ef0000tinit_module[oops_module]
ffffff800818d0acuprintk[oops_module]
ffffff800808e770u_mcount[oops_module]

從上面可以看出,PC的值和ffffff8000ef0058很接近。所以,基本可以確定出錯的模塊是oops_module。而這個模塊正是我自己寫的例程。

接下來,我們就要準備反匯編oops_module.ko了,根據反匯編可以進一步確認出錯的行數。

aarch64-linux-gnu-objdump-Doops_module.ko>oops_module.dis

oops_module.dis 內容如下

oops_module.ko:fileformatelf64-littleaarch64


Disassemblyofsection.note.gnu.build-id:

0000000000000000<.note.gnu.build-id>:
0:00000004.inst0x00000004;undefined
4:00000014.inst0x00000014;undefined
8:00000003.inst0x00000003;undefined
c:00554e47.inst0x00554e47;undefined
10:70d55614adrx20,fffffffffffaaad3<__UNIQUE_ID_vermagic0+0xfffffffffffaaa9a>
14:56a7eb64.inst0x56a7eb64;undefined
18:a66fbdf8.inst0xa66fbdf8;undefined
1c:2b31c03fcmnw1,w17,sxtw
20:bd9e1ffe.inst0xbd9e1ffe;undefined

Disassemblyofsection.text:

0000000000000000:
0:a9bf7bfdstpx29,x30,[sp,#-16]!
4:910003fdmovx29,sp
8:aa1e03e0movx0,x30
c:94000000bl0<_mcount>
10:58000100ldrx0,30
14:94000000bl0
18:d2800000movx0,#0x0//#0
1c:528102e1movw1,#0x817//#2071
20:72a32ec1movkw1,#0x1976,lsl#16
24:b9000001strw1,[x0]
28:a8c17bfdldpx29,x30,[sp],#16
2c:d65f03c0ret
...

0000000000000038:
38:a9bf7bfdstpx29,x30,[sp,#-16]!
3c:910003fdmovx29,sp
40:aa1e03e0movx0,x30
44:94000000bl0<_mcount>
48:58000080ldrx0,58
4c:94000000bl0
50:a8c17bfdldpx29,x30,[sp],#16
54:d65f03c0ret
...

Disassemblyofsection.modinfo:

0000000000000000<__UNIQUE_ID_license2>:
0:6563696cfnmlsz12.h,p2/m,z11.h,z3.h
4:3d65736eldrb14,[x27,#2396]
8:004c5047.inst0x004c5047;undefined

根據反匯編和之前 PC is at init_oopsdemo+0x24/0x38 [oops_module],可以確定發生錯誤的是0x24的位置。

24:b9000001strw1,[x0]#將w1寄存器的值,傳送到地址值為x0的(存儲器)內存中

而根據18: d2800000 mov x0, #0x0 // #0 可以確定x0 為0。

到這里也基本可以確定,是w1的值賦值給0地址時出錯了。

其他方法

gdb

?oops_moduleaarch64-linux-gnu-gdb-q./oops_module.ko
Readingsymbolsfrom./oops_module.ko...done.
(gdb)list*init_oopsdemo+0x24
0x4cisininit_oopsdemo(/home/zhongyi/code/module/oops_module/oops_module.c:10).
5MODULE_AUTHOR("ZHONGYI");
6
7staticintinit_oopsdemo(void)
8{
9printk("oopsmoduleinit!
");
10*((int*)0x00)=0x19760817;
11return0;
12}
13
14module_init(init_oopsdemo);
(gdb)

addr2line

Linux下addr2line命令用于將程序指令地址轉換為所對應的函數名、以及函數所在的源文件名和行號。當含有調試信息(-g)的執行程序出現crash時(core dumped),可使用addr2line命令快速定位出錯的位置。

如果無法確定文件名或函數名,addr2line將在它們的位置打印兩個問號;如果無法確定行號,addr2line將打印0或一個問號。

參數說明:

-a:在函數名、文件名和行號信息之前,以十六進制形式顯示地址。

-b:指定目標文件的格式為bfdname。

-C:將低級別的符號名解碼為用戶級別的名字。

-e:指定需要轉換地址的可執行文件名,默認文件是a.out。

-f:在顯示文件名、行號信息的同時顯示函數名。

-s:僅顯示每個文件名(the base of each file name)去除目錄名。

-i:如果需要轉換的地址是一個內聯函數,則還將打印返回第一個非內聯函數的信息。

-j:讀取指定section的偏移而不是絕對地址。

-p:使打印更加人性化:每個地址(location)的信息都打印在一行上。

-r:啟用或禁用遞歸量限制。

--help:打印幫助信息。

--version:打印版本號。

?oops_moduleaarch64-linux-gnu-addr2line-e./oops_module.ko-p-f0x24
init_oopsdemoat/home/zhongyi/code/module/oops_module/oops_module.c:10
?oops_modulecat/home/zhongyi/code/module/oops_module/oops_module.c|tail-n+5|head-n10
MODULE_AUTHOR("ZHONGYI");

staticintinit_oopsdemo(void)
{
printk("oopsmoduleinit!
");
*((int*)0x00)=0x19760817;
return0;
}

module_init(init_oopsdemo);

decodecode

在linux內核里面有很多腳本工具,位于linux/scripts/,里面有一個decodecode工具可以用來轉換機器碼,decodecode腳本可以在沒有源代碼或符號表的情況下,將oops異常的log作為輸入就可以解析出錯誤位置的匯編代碼。

oops_log.txt內容如下

calltrace:
[867.148911]Exceptionstack(0xffffffc00a4ffa70to0xffffffc00a4ffba0)
[867.148913]fa60:ffffff8000ef00000000008000000000
[867.148916]fa80:ffffffc00a4ffc40ffffff8000ef0024ffffff80097c02f80000000000000002
[867.148918]faa0:ffffffc00a4ffac0000000020001b57c00000000000000000000000100000000
[867.148921]fac0:ffffffc00a4ffb60ffffff800810d674ffffffc00a4ffbc0ffffff8000ef1024
[867.148924]fae0:ffffffc0cdce10c0ffffff80095b78600000000000000000ffffff8000ef2050
[867.148927]fb00:0000000000000001ffffffc0cde6e88000000000000000000000000019760817
[867.148929]fb20:000000000000000700000000000000070000000000000001ffffffc0f7f24b38
[867.148932]fb40:0000000000000022ffffff80096280b0ffffff8008463c3c0000000005f5e0ff
[867.148935]fb60:ffffff80097bfa9f00000000fffffffe0000000000000030000000000000000a
[867.148937]fb80:00000000000224d60000000000000000ffffff800813b2040000007fb096c8a0
[867.148944][]init_oopsdemo+0x24/0x38[oops_module]
[867.148953][]do_one_initcall+0x78/0x194
[867.148958][]do_init_module+0x64/0x1c0
[867.148962][]load_module+0x199c/0x1ed0
[867.148964][]SyS_finit_module+0xb0/0xbc
[867.148968][]el0_svc_naked+0x24/0x2
$ARCH=arm64CROSS_COMPILE=/home/zhongyi/code/rk3399_linux_release_v2.5.1_20210301/prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-./scripts/decodecode

執行腳本后,就可以得到出錯的匯編代碼。trapping instruction指出了出錯的地址。根據oop_module.ko的反匯編可以知道出錯的位置24: b9000001 str w1, [x0]。

注意:腳本認為該機器碼是跟host結構相同的原生機器碼,想要跨架構翻譯要指定架構和交叉工具鏈。

faddr2line

內核開發者為了方便問題的排查,也經常需要根據內核棧,快速定位導致問題發生的代碼位置。所以,Linux 內核維護了一個 faddr2line 腳本,根據函數名+偏移量輸出源碼文件名和行號。

在使用這個腳本之前,還需要注意兩個前提條件:

第一,帶有調試信息的內核文件,一般名字為 vmlinux(注意,/boot 目錄下面的 vmlinz 是壓縮后的內核,不可以直接拿來使用)。

第二,系統中需要安裝 awk、readelf、addr2line、size、nm 等命令。

對于第二個條件,這些命令都包含在 binutils 軟件包中,只需要執行 apt 或者 dnf 命令安裝即可。

而對第一個條件中的內核調試信息,各個主要的發行版也都提供了相應的軟件倉庫,你可以根據文檔進行安裝。比如,對于 Ubuntu 來說,你可以執行下面的命令安裝調試信息:

codename=$(lsb_release-cs)
sudotee/etc/apt/sources.list.d/ddebs.list<

由于我們這里的oops 是發生在ko中,而不是內核。因此,使用faddr2line指定oops_module.ko 即可。

?kernelgit:(firefly)?scripts/faddr2line/home/zhongyi/code/module/oops_module/oops_module.koinit_oopsdemo+0x24
init_oopsdemo+0x24/0x30:
init_oopsdemoat/home/zhongyi/code/module/oops_module/oops_module.c:18

如果oops發生在內核中,將oops_module.ko 換成對應的vmlinux即可。

最后,貼下oops_module.c的源代碼,感興趣的大家可以自己寫一個分析下。

#include
#include

MODULE_LICENSE("BSD/GPL");
MODULE_AUTHOR("ZHONGYI");

staticintinit_oopsdemo(void)
{
printk("oopsmoduleinit!
");
*((int*)0x00)=0x19760817;
return0;
}

module_init(init_oopsdemo);

staticvoidcleanup_oopsdemo(void)
{
printk("oopsmoduleexit!
");
}

module_exit(cleanup_oopsdemo);
MODULE_LICENSE("GPL");

審核編輯:湯梓紅

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 內核
    +關注

    關注

    3

    文章

    1372

    瀏覽量

    40281
  • cpu
    cpu
    +關注

    關注

    68

    文章

    10855

    瀏覽量

    211595
  • Oops
    +關注

    關注

    0

    文章

    4

    瀏覽量

    3308

原文標題:如何解讀內核的oops

文章出處:【微信號:嵌入式與Linux那些事,微信公眾號:嵌入式與Linux那些事】歡迎添加關注!文章轉載請注明出處。

收藏 人收藏

    評論

    相關推薦

    Linux編程時遇到Oops提示該如何排查?

    各位工程師在Linux下開發程序時,有沒有遇到由于系統中存在某些小故障而跳出了“Oops”提示的情況,此時你是如何排查故障?一行行的查看代碼嗎?其實不用那么復雜,本文將為你介紹一種高效的Linux編程的故障排除方法。
    的頭像 發表于 11-28 16:52 ?9055次閱讀
    Linux編程時遇到<b class='flag-5'>Oops</b>提示該如何排查?

    何解讀運放數據規格書

    在理解了上面的主要的運放非理想參數后,再讀運放的數據規格書應該就不難了,下面我們以比較常見的LM321集成運放為例,來過一遍如何解讀運放數據規格書。
    發表于 02-02 14:00 ?3525次閱讀
    如<b class='flag-5'>何解讀</b>運放數據規格書

    multisim的靈敏度分析結果如何解讀

    本帖最后由 test753 于 2015-4-7 20:28 編輯 結果如何解讀?教下吧
    發表于 04-07 20:10

    何解決cortex內核hardfault錯誤問題?

    何解決cortex內核hardfault錯誤問題?
    發表于 01-26 06:42

    CH341par Linux端DEMO運行錯誤是什么原因?如何解決?

    測試usb轉i2c功能。Ubuntu16.04,內核版本4.13.我嘗試write data時,內核出現oops.定位到如下代碼:在驅動中:get_user時出現oops:檢查了一下發
    發表于 07-01 06:20

    內核oops的根本原因是什么?我們如何調試內核oops

    Broadcom 交換機設備連接到我們主板上帶有 PCIe 的 T1042。開關工作在 EP 模式。linux內核版本是4.14。在檢測到 pcie 錯誤的現場卡中引發內核 oops。但是這個
    發表于 04-20 06:19

    Linux內核解讀入門

    Linux內核解讀入門關鍵詞:Linux, 內核,源代碼一.核心源程序的文件組織: 1. Linux核心源程序通常都安裝在/usr/src/linux下,而且它有一個非常簡單的編號約定:任何偶數的核
    發表于 01-16 14:40 ?103次下載

    系統設計人員如何解讀產品說明書規范

    作為應用工程師,我遇到過系統設計人員針對如何解讀產品說明書規范提出的大量問題。就在我認為我已經掌握如何確定規范以及它們如何造成設計誤差時,我總會從客戶的 TI E2E 論壇帖子、電話或電子郵件中獲得與我的理解不同的內容。
    發表于 04-08 03:38 ?2123次閱讀
    系統設計人員如<b class='flag-5'>何解讀</b>產品說明書規范

    淺談Linux內核解讀入門

    針對好多Linux 愛好者對內核很有興趣卻無從下口,本文旨在介紹一種解讀linux內核源碼的入門方法,而不是解說linux復雜的內核機制; 一.核心源程序的文件組織: 1.Linux核
    發表于 11-08 10:06 ?2次下載

    你了解Linux內核中的常見符號?

    一些內核調用可以用來方便標記bug,提供斷言并輸出信息。最常用的兩個是BUG()和BUG_ON()。當被調用的時候,它們會引發oops,導致棧的回溯和錯誤信息的打印。
    發表于 05-15 15:47 ?585次閱讀
    你了解Linux<b class='flag-5'>內核</b>中的常見符號?

    linux內核中的Oops

    真不是故意打碎您的杯子的”。看,Oops就是這個意思。在Linux內核開發中的Oops是什么呢?其實,它和上面的解釋也沒什么本質的差別,只不過說話的主角變成了Linux。當某些比較致命的問題出現時,我們
    發表于 04-02 14:31 ?593次閱讀

    內核oops錯誤原因及處理方法

    最近在調試設備時,遇到了一個偶發的開機死機問題。通過查看輸出日志,發現內核報告了oops錯誤,如下所示(中間省略了部分日志,以......代替)。
    的頭像 發表于 05-12 16:20 ?8159次閱讀

    怎么解讀內核oops

    Oops的錯誤代碼根據錯誤的原因會有不同的定義,如果發現自己遇到的Oops和下面無法對應的話,最好去內核代碼里查找
    的頭像 發表于 02-17 16:08 ?967次閱讀

    深入分析內核panic的內核錯誤處理方案

    die函數主要執行oops相關流程,且若異常為中斷流程中觸發或設置了panic_on_oops選項,則進一步通過panic將系統掛起。
    發表于 04-14 15:18 ?3781次閱讀

    Linux內核第一版開源代碼解讀

    《Exploring the internals of Linux v0.01》是一篇解讀 Linux 內核第一版開源代碼的文章。此文今天在 Reddit 和 Hacker News 都沖上了熱門。
    發表于 08-15 09:47 ?706次閱讀
    主站蜘蛛池模板: 亚洲综合AV在线在线播放| 国偷自产视频一区二区久| 欧美成人3d动漫专区| 又黄又湿免费高清视频| 国产一区免费在线观看| 网友自拍成人在线视频| 高H高肉强J短篇NP| 日本精品久久久久中文字幕2| 69精品国产人妻蜜桃国产毛片| 久久国产视频网| 亚洲伊人国产| 精品综合久久久久久8888| 亚洲国产成人私人影院| 国产青青草原| 亚洲AV 中文字幕 国产 欧美 | 国产成人高清视频| 日本边添边摸边做边爱边| www.伊人| 人人艹人人| 春药按摩人妻中文字幕| 日本高清不卡一区久久精品| JizzJizzJizz亚洲成年| 欧美色偷偷亚洲天堂bt| SM调教贱屁股眼哭叫求饶H| 欧美精品v欧洲高清| free18sex性自拍裸舞| 强开乳罩摸双乳吃奶视频| 边摸边吃奶玩乳尖视频| 日韩精品 电影一区 亚洲高清| 草莓视频在线观看完整高清免费 | 国产午夜三区视频在线| 午夜婷婷一夜七次郎| 国产亚洲精品精华液| 亚洲乱码国产乱码精品精98| 精品一区二区三区AV天堂| 一本之道高清在线观看一区| 久久这里的只有是精品23| 97国产视频| 青青青草免费| 国产精品97久久AV色婷婷综合| 午夜精品久久久久久久99蜜桃|