如何解讀Linux Kernel OOPS資訊

2022-11-01 06:00:36

OOPS資訊解讀

root@firefly:~/mnt/module# insmod oops_module.ko 
[  867.140514] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[  867.141279] pgd = ffffffc0f0a65000
[  867.141582] [00000000] *pgd=0000000000000000, *pud=0000000000000000
[  867.142164] Internal error: Oops: 96000045 [#1] SMP
[  867.142592] Modules linked in: oops_module(O+)
[  867.143006] CPU: 4 PID: 1163 Comm: insmod Tainted: G           O    4.4.194+ #7
[  867.143649] Hardware name: Firefly-RK3399 Board (Linux Opensource) (DT)
[  867.144236] task: ffffffc0cdc44380 task.stack: ffffffc00a4fc000
[  867.144761] PC is at init_oopsdemo+0x24/0x38 [oops_module]
[  867.145247] LR is at init_oopsdemo+0x18/0x38 [oops_module]
[  867.145732] pc : [<ffffff8000ef0024>] lr : [<ffffff8000ef0018>] pstate: 40000145
[  867.146386] sp : ffffffc00a4ffc40
[  867.146688] x29: ffffffc00a4ffc40 x28: ffffff80081376d0 
[  867.147178] x27: 0000000000000001 x26: ffffffc0cde6e880 
[  867.147491] x25: 0000000000000001 x24: ffffff8000ef2050 
[  867.147495] x23: 0000000000000000 x22: ffffff80095b7860 
[  867.147498] x21: ffffffc0cdce10c0 x20: ffffff80095b7860 
[  867.147501] x19: ffffff8000ef0000 x18: ffffff80897bfa97 
[  867.147504] x17: 0000007fb096c8a0 x16: ffffff800813b204 Segmentation fau
lt
[  867.147508] x15: 0000000000000000 root@firefly:~/mx14: 00000000000224d6 nt/module# 
[  867.147511] x13: 000000000000000a x12: 0000000000000030 
[  867.147515] x11: 00000000fffffffe x10: ffffff80097bfa9f 
[  867.147518] x9 : 0000000005f5e0ff x8 : ffffff8008463c3c 
[  867.147522] x7 : ffffff80096280b0 x6 : 0000000000000022 
[  867.147525] x5 : ffffffc0f7f24b38 x4 : 0000000000000001 
[  867.147528] x3 : 0000000000000007 x2 : 0000000000000007 
[  867.147534] x1 : 0000000019760817 x0 : 0000000000000000 
[  867.147536] 
[  867.147536] PC: 0xffffff8000eeffa4:
[  867.147550] ffa4  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147561] ffc4  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147572] ffe4  ******** ******** ******** ******** ******** ******** ******** a9bf7bfd
[  867.147581] 0004  910003fd aa1e03e0 d503201f 58000100 95ca7426 d2800000 528102e1 72a32ec1
[  867.147590] 0024  b9000001 a8c17bfd d65f03c0 00ef1024 ffffff80 a9bf7bfd 910003fd aa1e03e0
[  867.147599] 0044  d503201f 58000080 95ca7418 a8c17bfd d65f03c0 00ef1038 ffffff80 00000000
[  867.147607] 0064  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147616] 0084  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147618] 
[  867.147618] LR: 0xffffff8000eeff98:
[  867.147629] ff98  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147639] ffb8  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147650] ffd8  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147659] fff8  ******** ******** a9bf7bfd 910003fd aa1e03e0 d503201f 58000100 95ca7426
[  867.147668] 0018  d2800000 528102e1 72a32ec1 b9000001 a8c17bfd d65f03c0 00ef1024 ffffff80
[  867.147677] 0038  a9bf7bfd 910003fd aa1e03e0 d503201f 58000080 95ca7418 a8c17bfd d65f03c0
[  867.147685] 0058  00ef1038 ffffff80 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147693] 0078  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147695] 
[  867.147695] SP: 0xffffffc00a4ffbc0:
[  867.147705] fbc0  095b7860 ffffff80 00000000 00000000 00ef2050 ffffff80 00000001 00000000
[  867.147713] fbe0  cde6e880 ffffffc0 00000001 00000000 081376d0 ffffff80 0a4ffc40 ffffffc0
[  867.147726] fc00  00ef0018 ffffff80 0a4ffc40 ffffffc0 00ef0024 ffffff80 40000145 00000000
[  867.147734] fc20  ee9ae000 00000040 00012ffb 00000000 00000000 00000080 00000000 00000000
[  867.147743] fc40  0a4ffc50 ffffffc0 080830f8 ffffff80 0a4ffcd0 ffffffc0 0818d2d0 ffffff80
[  867.147765] fc60  00ef2000 ffffff80 095cd000 ffffff80 cde6e8c8 ffffffc0 cdce1140 ffffffc0
[  867.147774] fc80  00000000 00000000 0818d2a4 ffffff80 00ef2000 ffffff80 095cd000 ffffff80
[  867.147782] fca0  cde6e8c8 ffffffc0 095cd000 ffffff80 00000000 00000000 00ef2050 ffffff80
[  867.147785] 
[  867.147785] X5: 0xffffffc0f7f24ab8:
[  867.147794] 4ab8  0000003f 00000000 0000003f 00000000 00000000 00000000 00000000 00000000
[  867.147803] 4ad8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147811] 4af8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147819] 4b18  afbe5356 00000001 00000000 00000000 0810d62c ffffff80 00000001 00000000
[  867.147828] 4b38  00000007 00000000 00000000 00000000 0810dd18 ffffff80 00000000 00000000
[  867.147836] 4b58  00000000 01400000 00000000 0000e293 00000000 00000000 00000000 00000000
[  867.147845] 4b78  00000000 00000000 d591d591 dead4ead ffffffff 00000000 ffffffff ffffffff
[  867.147853] 4b98  00000000 00000000 0008a70b 00000001 0008a701 00000001 0000000d 00000000
[  867.147855] 
[  867.147855] X7: 0xffffff8009628030:
[  867.147863] 8030  f26a3900 ffffffc0 00000000 00000000 00000000 00000000 00110000 00000000
[  867.147872] 8050  000f0000 00000000 00000000 00000000 00040000 00000000 00080000 00000000
[  867.147880] 8070  00000000 00000000 00000000 00000000 00000001 00000000 00000000 00000000
[  867.147889] 8090  00000000 00000001 00000000 00000001 00000002 00000001 00000001 00000000
[  867.147897] 80b0  00000000 00000000 0927e623 ffffff80 04e804e8 dead4ead ffffffff 00000000
[  867.147905] 80d0  ffffffff ffffffff f2000000 ffffffc0 00040000 00000000 00000001 00000000
[  867.147914] 80f0  00000000 dead4ead ffffffff 00000000 ffffffff ffffffff 09628108 ffffff80
[  867.147922] 8110  09628108 ffffff80 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147924] 
[  867.147924] X8: 0xffffff8008463bbc:
[  867.147933] 3bbc  9400054a aa1303e0 94000554 52800000 a94153f3 f94013f5 a8c37bfd d65f03c0
[  867.147942] 3bdc  f9400413 17fffff6 f9400813 17fffff4 f9400c13 17fffff2 128002a0 17fffff5
[  867.147950] 3bfc  71001c1f 54000161 f9405ce0 f9400c00 b4000140 a9bf7bfd aa0603e2 aa0403e1
[  867.147959] 3c1c  910003fd 940004ce a8c17bfd d65f03c0 128002a0 d65f03c0 12800160 d65f03c0
[  867.147967] 3c3c  a9bb7bfd 7100081f 910003fd a9025bf5 aa0403f6 a90153f3 aa0603f5 a90363f7
[  867.147975] 3c5c  f9405cf3 54000181 f9400660 b4000a20 2a1503e2 aa1603e1 9400047d 52800000
[  867.147984] 3c7c  a94153f3 a9425bf5 a94363f7 a8c57bfd d65f03c0 71000c1f 54000061 f9400a60
[  867.147992] 3c9c  17fffff3 71001c1f 54000061 f9400e60 17ffffef 35000820 51000420 7100041f
[  867.147994] 
[  867.147994] X10: 0xffffff80097bfa1f:
[  867.148003] fa1c  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148011] fa3c  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148020] fa5c  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148028] fa7c  00000000 00000000 00000000 00000000 00000000 00000001 00000000 3820205b
[  867.148037] fa9c  312e3736 39343734 78205d31 203a3532 30303030 30303030 30303030 31303030
[  867.148045] fabc  5d3e3420 20726c20 3c5b203a 66666666 30386666 66653030 38313030 70205d3e
[  867.148054] fadc  74617473 34203a65 30303030 0a353431 30303030 0a303030 742f0a67 296d0a78
[  867.148062] fafc  3028202c 0a297320 3331200a 3a34353a 76203334 69737265 37206e6f 2e35332e
[  867.148071] fb1c  2e343831 35722e31 32412820 61745320 6e6f6974 5032502f 57462029 30204449
[  867.148074] 
[  867.148074] X16: 0xffffff800813b184:
[  867.148083] b184  fa413002 9a9f87e2 b4000202 aa1303e2 aa1403e1 aa1503e0 940e73e9 b5000220
[  867.148093] b1a4  943672e0 8b1302b5 8b130294 eb1302f7 54fffde1 52800002 aa1603e1 910163a0
[  867.148101] b1c4  97fff7ff 17ffffc6 aa1303e2 52800001 aa1503e0 940e775a aa1303e0 17fffff0
[  867.148110] b1e4  f9402fa0 94021fc6 128001a0 17ffffbc 128000e0 17ffffba 12800160 17ffffb8
[  867.148118] b204  a9b67bfd 910003fd a90153f3 f90013f5 aa0003f5 aa1e03e0 aa0103f4 aa0203f3
[  867.148127] b224  d503201f a903ffbf a904ffbf a905ffbf a906ffbf a907ffbf a908ffbf f9004fbf
[  867.148135] b244  97ffefb2 340000c0 93407c00 a94153f3 f94013f5 a8ca7bfd d65f03c0 f000b220
[  867.148143] b264  913d0000 910aa000 79404401 361000e1 d00088a1 2a1303e4 aa1403e3 2a1503e2
[  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] 0000  a9bf7bfd 910003fd aa1e03e0 d503201f 58000100 95ca7426 d2800000 528102e1
[  867.148311] 0020  72a32ec1 b9000001 a8c17bfd d65f03c0 00ef1024 ffffff80 a9bf7bfd 910003fd
[  867.148320] 0040  aa1e03e0 d503201f 58000080 95ca7418 a8c17bfd d65f03c0 00ef1038 ffffff80
[  867.148328] 0060  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148330] 
[  867.148330] X20: 0xffffff80095b77e0:
[  867.148338] 77e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148346] 7800  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148355] 7820  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148363] 7840  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148372] 7860  095b7860 ffffff80 095b7860 ffffff80 00000001 00000000 00005dc0 00000000
[  867.148380] 7880  00000009 756e694c 00000078 00000000 00000000 00000000 00000000 00000000
[  867.148388] 78a0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148397] 78c0  00000000 72696600 796c6665 00000000 00000000 00000000 00000000 00000000
[  867.148398] 
[  867.148398] X21: 0xffffffc0cdce1040:
[  867.148407] 1040  746f6e2e 6e672e65 75622e75 2d646c69 00006469 dead0000 00000200 dead0000
[  867.148415] 1060  00000001 00000000 00000000 00000000 00000000 00000000 055aab56 00000000
[  867.148424] 1080  cdce1bc0 ffffffc0 cde6d909 ffffffc0 cde6d888 ffffffc0 cdce1bc8 ffffffc0
[  867.148433] 10a0  00000000 00000000 000003dd 6c62010e 6c6b6361 2e747369 666e6f63 00000000
[  867.148441] 10c0  cdce1080 ffffffc0 6d656473 6f5b206f 5f73706f 75646f6d 005d656c 00000000
[  867.148449] 10e0  00000000 00000000 0000000f 2e2e0202 00000000 00000000 00000000 00000000
[  867.148458] 1100  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148466] 1120  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148468] 
[  867.148468] X22: 0xffffff80095b77e0:
[  867.148476] 77e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148484] 7800  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148493] 7820  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148501] 7840  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148510] 7860  095b7860 ffffff80 095b7860 ffffff80 00000001 00000000 00005dc0 00000000
[  867.148518] 7880  00000009 756e694c 00000078 00000000 00000000 00000000 00000000 00000000
[  867.148526] 78a0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148535] 78c0  00000000 72696600 796c6665 00000000 00000000 00000000 00000000 00000000
[  867.148536] 
[  867.148536] X24: 0xffffff8000ef1fd0:
[  867.148545] 1fd0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148553] 1ff0  00000000 00000000 00000000 00000000 00000001 00000000 095cd3a0 ffffff80
[  867.148562] 2010  095cd3a0 ffffff80 73706f6f 646f6d5f 00656c75 00000000 00000000 00000000
[  867.148570] 2030  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148578] 2050  f089a080 ffffffc0 f26add00 ffffffc0 f2117e88 ffffffc0 f26add28 ffffffc0
[  867.148588] 2070  f26add00 ffffffc0 095c4c08 ffffff80 dbb66f78 ffffffc0 00000003 00000007
[  867.148596] 2090  00ef2000 ffffff80 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148605] 20b0  f2f99c00 ffffffc0 00000000 00000000 00000000 00000000 f089ab40 ffffffc0
[  867.148606] 
[  867.148606] X26: 0xffffffc0cde6e800:
[  867.148615] e800  00000001 00000000 d11d71a8 ffffffc0 00000000 00000000 00000000 00000000
[  867.148623] e820  cf2e6030 ffffffc0 00000000 00000000 0000046d 00000000 095c42c8 ffffff80
[  867.148632] e840  00000000 00000000 f7ec5e68 ffffffc0 00000000 00000000 00000000 00000000
[  867.148640] e860  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148649] e880  f106a880 ffffffc0 00000001 00000000 f089aa40 ffffffc0 00000124 00000000
[  867.148657] e8a0  00000024 00000000 00ef1000 ffffff80 081375b0 ffffff80 00000000 00000000
[  867.148665] e8c0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148674] e8e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148675] 
[  867.148675] X28: 0xffffff8008137650:
[  867.148684] 7650  a90153f3 aa0103f4 aa0203f3 aa1e03e0 d503201f f0008f21 913a1c21 f9402280
[  867.148693] 7670  b941d802 aa1303e0 940eb71d 93407c00 a94153f3 a8c27bfd d65f03c0 a9be7bfd
[  867.148701] 7690  910003fd a90153f3 aa0103f4 aa0203f3 aa1e03e0 d503201f f0008f21 913a1c21
[  867.148710] 76b0  f9402280 b9418802 aa1303e0 940eb70c 93407c00 a94153f3 a8c27bfd d65f03c0
[  867.148718] 76d0  a9be7bfd 910003fd a90153f3 aa0003f4 aa0203f3 aa1e03e0 d503201f aa1303e0
[  867.148727] 76f0  b0008b61 f9402282 91068021 940eb6fc 93407c00 a94153f3 a8c27bfd d65f03c0
[  867.148735] 7710  a9be7bfd 910003fd a90153f3 aa0003f3 aa0103f4 aa1e03e0 d503201f 52801801
[  867.148743] 7730  aa1403e0 72a04801 9401c11a f9006260 a94153f3 a8c27bfd d65f03c0 a9be7bfd
[  867.148745] 
[  867.148745] X29: 0xffffffc00a4ffbc0:
[  867.148754] fbc0  095b7860 ffffff80 00000000 00000000 00ef2050 ffffff80 00000001 00000000
[  867.148763] fbe0  cde6e880 ffffffc0 00000001 00000000 081376d0 ffffff80 0a4ffc40 ffffffc0
[  867.148771] fc00  00ef0018 ffffff80 0a4ffc40 ffffffc0 00ef0024 ffffff80 40000145 00000000
[  867.148780] fc20  ee9ae000 00000040 00012ffb 00000000 00000000 00000080 00000000 00000000
[  867.148790] fc40  0a4ffc50 ffffffc0 080830f8 ffffff80 0a4ffcd0 ffffffc0 0818d2d0 ffffff80
[  867.148798] fc60  00ef2000 ffffff80 095cd000 ffffff80 cde6e8c8 ffffffc0 cdce1140 ffffffc0
[  867.148807] fc80  00000000 00000000 0818d2a4 ffffff80 00ef2000 ffffff80 095cd000 ffffff80
[  867.148815] fca0  cde6e8c8 ffffffc0 095cd000 ffffff80 00000000 00000000 00ef2050 ffffff80
[  867.148816] 
[  867.148820] Process insmod (pid: 1163, stack limit = 0xffffffc00a4fc000)
[  867.148822] Stack: (0xffffffc00a4ffc40 to 0xffffffc00a500000)
[  867.148826] fc40: ffffffc00a4ffc50 ffffff80080830f8 ffffffc00a4ffcd0 ffffff800818d2d0
[  867.148829] fc60: ffffff8000ef2000 ffffff80095cd000 ffffffc0cde6e8c8 ffffffc0cdce1140
[  867.148832] fc80: 0000000000000000 ffffff800818d2a4 ffffff8000ef2000 ffffff80095cd000
[  867.148834] fca0: ffffffc0cde6e8c8 ffffff80095cd000 0000000000000000 ffffff8000ef2050
[  867.148837] fcc0: 0000000000000001 ffffffc0cde6e880 ffffffc00a4ffd00 ffffff800813ab5c
[  867.148840] fce0: ffffff8000ef2000 ffffffc00a4ffe58 ffffffc0cde6e8c8 ffffff80095cd000
[  867.148843] fd00: ffffffc00a4ffe20 ffffff800813b2b4 0000000000000000 00000055736b60f0
[  867.148846] fd20: 0000000000000003 0000007fb096c8c4 0000000040000000 0000000000000015
[  867.148849] fd40: 000000000000011d 0000000000000111 ffffff8008ef2000 ffffffc0cdc44380
[  867.148851] fd60: 0000000000000000 000000000002c098 ffffffc00a4ffe20 ffffff8008f00000
[  867.148854] fd80: 0000000000000000 00000055736b60f0 ffffffc000000064 ffffff8000000072
[  867.148857] fda0: ffffff800000006e ffffff800000003f ffffff8000000124 00000000024000c0
[  867.148860] fdc0: ffff81b400000030 000003e800000001 00000000000003e8 000000000002c098
[  867.148862] fde0: 00000000633eccfc 0000000000000000 0000000000000000 0000000000000000
[  867.148865] fe00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
[  867.148868] fe20: 0000000000000000 ffffff8008082f70 0000000000000000 00000040ee9ae000
[  867.148871] fe40: ffffffffffffffff 0000000000000001 0000000000000002 ffffff800bea0000
[  867.148874] fe60: 000000000002c098 ffffff800becb9d8 ffffff800becb8d0 ffffff800beb7748
[  867.148876] fe80: 0000000000003000 00000000000030d8 0000000000000000 0000000000000000
[  867.148879] fea0: 0000000000000478 0000001a00000019 0000000000000009 0000000000000004
[  867.148882] fec0: 0000000000000003 00000055736b60f0 0000000000000000 0000000000000003
[  867.148884] fee0: 0000000000000000 0000000000000218 0000000000000001 0000000000000001
[  867.148887] ff00: 0000000000000111 0000000000000003 0000000200000002 0000000000000000
[  867.148890] ff20: 00000000000010f0 0000000000000000 0000000000000000 0000000000000040
[  867.148892] ff40: 00000055736cddb0 0000007fb096c8a0 0000000000000000 0000005585e6b600
[  867.148895] ff60: 00000055736b60f0 0000000000000000 0000000000000000 0000005585e6b5d0
[  867.148898] ff80: 00000055736b2ef8 0000000000000000 0000000000000000 0000000000000000
[  867.148901] ffa0: 0000000000000000 0000007fdbea3bd0 00000055736abdc0 0000007fdbea3bd0
[  867.148903] ffc0: 0000007fb096c8c4 0000000040000000 0000000000000003 0000000000000111
[  867.148906] ffe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
[  867.148907] Call trace:
[  867.148911] Exception stack(0xffffffc00a4ffa70 to 0xffffffc00a4ffba0)
[  867.148913] fa60:                                   ffffff8000ef0000 0000008000000000
[  867.148916] fa80: ffffffc00a4ffc40 ffffff8000ef0024 ffffff80097c02f8 0000000000000002
[  867.148918] faa0: ffffffc00a4ffac0 000000020001b57c 0000000000000000 0000000100000000
[  867.148921] fac0: ffffffc00a4ffb60 ffffff800810d674 ffffffc00a4ffbc0 ffffff8000ef1024
[  867.148924] fae0: ffffffc0cdce10c0 ffffff80095b7860 0000000000000000 ffffff8000ef2050
[  867.148927] fb00: 0000000000000001 ffffffc0cde6e880 0000000000000000 0000000019760817
[  867.148929] fb20: 0000000000000007 0000000000000007 0000000000000001 ffffffc0f7f24b38
[  867.148932] fb40: 0000000000000022 ffffff80096280b0 ffffff8008463c3c 0000000005f5e0ff
[  867.148935] fb60: ffffff80097bfa9f 00000000fffffffe 0000000000000030 000000000000000a
[  867.148937] fb80: 00000000000224d6 0000000000000000 ffffff800813b204 0000007fb096c8a0
[  867.148944] [<ffffff8000ef0024>] init_oopsdemo+0x24/0x38 [oops_module]
[  867.148953] [<ffffff80080830f8>] do_one_initcall+0x78/0x194
[  867.148958] [<ffffff800818d2d0>] do_init_module+0x64/0x1c0
[  867.148962] [<ffffff800813ab5c>] load_module+0x199c/0x1ed0
[  867.148964] [<ffffff800813b2b4>] SyS_finit_module+0xb0/0xbc
[  867.148968] [<ffffff8008082f70>] el0_svc_naked+0x24/0x28
[  867.148972] Code: 95ca7426 d2800000 528102e1 72a32ec1 (b9000001) 
[  867.148975] ---[ end trace 1983a52768236533 ]---
[  867.140514] Unable to handle kernel NULL pointer dereference at virtual address 00000000

這裡能夠簡要的告訴是什麼問題觸發了oops,顯然是由於存取非法地址00000000異常。如果是由程式碼直接呼叫BUG()/BUG_ON()一類的,還能給出原始碼中觸發的行號。

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

pgd,pud試圖存取的地址的頁表資訊,本例中為0。

[  867.142164] Internal error: 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] Modules linked in: oops_module(O+) [last unloaded: hello_module]

Modules linked in為載入了的模組列表,hello_module為上次載入的模組。

[  867.143006] CPU: 4 PID: 1163 Comm: insmod Tainted: G           O    4.4.194+ #7
[  867.143649] Hardware name: Firefly-RK3399 Board (Linux Opensource) (DT)
[  867.144236] task: ffffffc0cdc44380 task.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] PC is at init_oopsdemo+0x24/0x38 [oops_module]
[  867.145247] LR is at init_oopsdemo+0x18/0x38 [oops_module]
[  867.145732] pc : [<ffffff8000ef0024>] lr : [<ffffff8000ef0018>] 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: ffffffc00a4ffc40 x28: ffffff80081376d0 
[  867.147178] x27: 0000000000000001 x26: ffffffc0cde6e880 
[  867.147491] x25: 0000000000000001 x24: ffffff8000ef2050 
[  867.147495] x23: 0000000000000000 x22: ffffff80095b7860 
[  867.147498] x21: ffffffc0cdce10c0 x20: ffffff80095b7860 
[  867.147501] x19: ffffff8000ef0000 x18: ffffff80897bfa97 
[  867.147504] x17: 0000007fb096c8a0 x16: ffffff800813b204 Segmentation fau
lt
[  867.147508] x15: 0000000000000000 root@firefly:~/mx14: 00000000000224d6 nt/module# 
[  867.147511] x13: 000000000000000a x12: 0000000000000030 
[  867.147515] x11: 00000000fffffffe x10: ffffff80097bfa9f 
[  867.147518] x9 : 0000000005f5e0ff x8 : ffffff8008463c3c 
[  867.147522] x7 : ffffff80096280b0 x6 : 0000000000000022 
[  867.147525] x5 : ffffffc0f7f24b38 x4 : 0000000000000001 
[  867.147528] x3 : 0000000000000007 x2 : 0000000000000007 
[  867.147534] x1 : 0000000019760817 x0 : 0000000000000000 
[  867.147536] 
[  867.147536] PC: 0xffffff8000eeffa4:
[  867.147550] ffa4  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147561] ffc4  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147572] ffe4  ******** ******** ******** ******** ******** ******** ******** a9bf7bfd
[  867.147581] 0004  910003fd aa1e03e0 d503201f 58000100 95ca7426 d2800000 528102e1 72a32ec1
[  867.147590] 0024  b9000001 a8c17bfd d65f03c0 00ef1024 ffffff80 a9bf7bfd 910003fd aa1e03e0
[  867.147599] 0044  d503201f 58000080 95ca7418 a8c17bfd d65f03c0 00ef1038 ffffff80 00000000
[  867.147607] 0064  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147616] 0084  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147618] 
[  867.147618] LR: 0xffffff8000eeff98:
[  867.147629] ff98  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147639] ffb8  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147650] ffd8  ******** ******** ******** ******** ******** ******** ******** ********
[  867.147659] fff8  ******** ******** a9bf7bfd 910003fd aa1e03e0 d503201f 58000100 95ca7426
[  867.147668] 0018  d2800000 528102e1 72a32ec1 b9000001 a8c17bfd d65f03c0 00ef1024 ffffff80
[  867.147677] 0038  a9bf7bfd 910003fd aa1e03e0 d503201f 58000080 95ca7418 a8c17bfd d65f03c0
[  867.147685] 0058  00ef1038 ffffff80 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147693] 0078  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147695] 
[  867.147695] SP: 0xffffffc00a4ffbc0:
[  867.147705] fbc0  095b7860 ffffff80 00000000 00000000 00ef2050 ffffff80 00000001 00000000
[  867.147713] fbe0  cde6e880 ffffffc0 00000001 00000000 081376d0 ffffff80 0a4ffc40 ffffffc0
[  867.147726] fc00  00ef0018 ffffff80 0a4ffc40 ffffffc0 00ef0024 ffffff80 40000145 00000000
[  867.147734] fc20  ee9ae000 00000040 00012ffb 00000000 00000000 00000080 00000000 00000000
[  867.147743] fc40  0a4ffc50 ffffffc0 080830f8 ffffff80 0a4ffcd0 ffffffc0 0818d2d0 ffffff80
[  867.147765] fc60  00ef2000 ffffff80 095cd000 ffffff80 cde6e8c8 ffffffc0 cdce1140 ffffffc0
[  867.147774] fc80  00000000 00000000 0818d2a4 ffffff80 00ef2000 ffffff80 095cd000 ffffff80
[  867.147782] fca0  cde6e8c8 ffffffc0 095cd000 ffffff80 00000000 00000000 00ef2050 ffffff80
[  867.147785] 
[  867.147785] X5: 0xffffffc0f7f24ab8:
[  867.147794] 4ab8  0000003f 00000000 0000003f 00000000 00000000 00000000 00000000 00000000
[  867.147803] 4ad8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147811] 4af8  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147819] 4b18  afbe5356 00000001 00000000 00000000 0810d62c ffffff80 00000001 00000000
[  867.147828] 4b38  00000007 00000000 00000000 00000000 0810dd18 ffffff80 00000000 00000000
[  867.147836] 4b58  00000000 01400000 00000000 0000e293 00000000 00000000 00000000 00000000
[  867.147845] 4b78  00000000 00000000 d591d591 dead4ead ffffffff 00000000 ffffffff ffffffff
[  867.147853] 4b98  00000000 00000000 0008a70b 00000001 0008a701 00000001 0000000d 00000000
[  867.147855] 
[  867.147855] X7: 0xffffff8009628030:
[  867.147863] 8030  f26a3900 ffffffc0 00000000 00000000 00000000 00000000 00110000 00000000
[  867.147872] 8050  000f0000 00000000 00000000 00000000 00040000 00000000 00080000 00000000
[  867.147880] 8070  00000000 00000000 00000000 00000000 00000001 00000000 00000000 00000000
[  867.147889] 8090  00000000 00000001 00000000 00000001 00000002 00000001 00000001 00000000
[  867.147897] 80b0  00000000 00000000 0927e623 ffffff80 04e804e8 dead4ead ffffffff 00000000
[  867.147905] 80d0  ffffffff ffffffff f2000000 ffffffc0 00040000 00000000 00000001 00000000
[  867.147914] 80f0  00000000 dead4ead ffffffff 00000000 ffffffff ffffffff 09628108 ffffff80
[  867.147922] 8110  09628108 ffffff80 00000000 00000000 00000000 00000000 00000000 00000000
[  867.147924] 
[  867.147924] X8: 0xffffff8008463bbc:
[  867.147933] 3bbc  9400054a aa1303e0 94000554 52800000 a94153f3 f94013f5 a8c37bfd d65f03c0
[  867.147942] 3bdc  f9400413 17fffff6 f9400813 17fffff4 f9400c13 17fffff2 128002a0 17fffff5
[  867.147950] 3bfc  71001c1f 54000161 f9405ce0 f9400c00 b4000140 a9bf7bfd aa0603e2 aa0403e1
[  867.147959] 3c1c  910003fd 940004ce a8c17bfd d65f03c0 128002a0 d65f03c0 12800160 d65f03c0
[  867.147967] 3c3c  a9bb7bfd 7100081f 910003fd a9025bf5 aa0403f6 a90153f3 aa0603f5 a90363f7
[  867.147975] 3c5c  f9405cf3 54000181 f9400660 b4000a20 2a1503e2 aa1603e1 9400047d 52800000
[  867.147984] 3c7c  a94153f3 a9425bf5 a94363f7 a8c57bfd d65f03c0 71000c1f 54000061 f9400a60
[  867.147992] 3c9c  17fffff3 71001c1f 54000061 f9400e60 17ffffef 35000820 51000420 7100041f
[  867.147994] 
[  867.147994] X10: 0xffffff80097bfa1f:
[  867.148003] fa1c  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148011] fa3c  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148020] fa5c  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148028] fa7c  00000000 00000000 00000000 00000000 00000000 00000001 00000000 3820205b
[  867.148037] fa9c  312e3736 39343734 78205d31 203a3532 30303030 30303030 30303030 31303030
[  867.148045] fabc  5d3e3420 20726c20 3c5b203a 66666666 30386666 66653030 38313030 70205d3e
[  867.148054] fadc  74617473 34203a65 30303030 0a353431 30303030 0a303030 742f0a67 296d0a78
[  867.148062] fafc  3028202c 0a297320 3331200a 3a34353a 76203334 69737265 37206e6f 2e35332e
[  867.148071] fb1c  2e343831 35722e31 32412820 61745320 6e6f6974 5032502f 57462029 30204449
[  867.148074] 
[  867.148074] X16: 0xffffff800813b184:
[  867.148083] b184  fa413002 9a9f87e2 b4000202 aa1303e2 aa1403e1 aa1503e0 940e73e9 b5000220
[  867.148093] b1a4  943672e0 8b1302b5 8b130294 eb1302f7 54fffde1 52800002 aa1603e1 910163a0
[  867.148101] b1c4  97fff7ff 17ffffc6 aa1303e2 52800001 aa1503e0 940e775a aa1303e0 17fffff0
[  867.148110] b1e4  f9402fa0 94021fc6 128001a0 17ffffbc 128000e0 17ffffba 12800160 17ffffb8
[  867.148118] b204  a9b67bfd 910003fd a90153f3 f90013f5 aa0003f5 aa1e03e0 aa0103f4 aa0203f3
[  867.148127] b224  d503201f a903ffbf a904ffbf a905ffbf a906ffbf a907ffbf a908ffbf f9004fbf
[  867.148135] b244  97ffefb2 340000c0 93407c00 a94153f3 f94013f5 a8ca7bfd d65f03c0 f000b220
[  867.148143] b264  913d0000 910aa000 79404401 361000e1 d00088a1 2a1303e4 aa1403e3 2a1503e2
[  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] 0000  a9bf7bfd 910003fd aa1e03e0 d503201f 58000100 95ca7426 d2800000 528102e1
[  867.148311] 0020  72a32ec1 b9000001 a8c17bfd d65f03c0 00ef1024 ffffff80 a9bf7bfd 910003fd
[  867.148320] 0040  aa1e03e0 d503201f 58000080 95ca7418 a8c17bfd d65f03c0 00ef1038 ffffff80
[  867.148328] 0060  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148330] 
[  867.148330] X20: 0xffffff80095b77e0:
[  867.148338] 77e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148346] 7800  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148355] 7820  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148363] 7840  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148372] 7860  095b7860 ffffff80 095b7860 ffffff80 00000001 00000000 00005dc0 00000000
[  867.148380] 7880  00000009 756e694c 00000078 00000000 00000000 00000000 00000000 00000000
[  867.148388] 78a0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148397] 78c0  00000000 72696600 796c6665 00000000 00000000 00000000 00000000 00000000
[  867.148398] 
[  867.148398] X21: 0xffffffc0cdce1040:
[  867.148407] 1040  746f6e2e 6e672e65 75622e75 2d646c69 00006469 dead0000 00000200 dead0000
[  867.148415] 1060  00000001 00000000 00000000 00000000 00000000 00000000 055aab56 00000000
[  867.148424] 1080  cdce1bc0 ffffffc0 cde6d909 ffffffc0 cde6d888 ffffffc0 cdce1bc8 ffffffc0
[  867.148433] 10a0  00000000 00000000 000003dd 6c62010e 6c6b6361 2e747369 666e6f63 00000000
[  867.148441] 10c0  cdce1080 ffffffc0 6d656473 6f5b206f 5f73706f 75646f6d 005d656c 00000000
[  867.148449] 10e0  00000000 00000000 0000000f 2e2e0202 00000000 00000000 00000000 00000000
[  867.148458] 1100  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148466] 1120  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148468] 
[  867.148468] X22: 0xffffff80095b77e0:
[  867.148476] 77e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148484] 7800  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148493] 7820  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148501] 7840  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148510] 7860  095b7860 ffffff80 095b7860 ffffff80 00000001 00000000 00005dc0 00000000
[  867.148518] 7880  00000009 756e694c 00000078 00000000 00000000 00000000 00000000 00000000
[  867.148526] 78a0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148535] 78c0  00000000 72696600 796c6665 00000000 00000000 00000000 00000000 00000000
[  867.148536] 
[  867.148536] X24: 0xffffff8000ef1fd0:
[  867.148545] 1fd0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148553] 1ff0  00000000 00000000 00000000 00000000 00000001 00000000 095cd3a0 ffffff80
[  867.148562] 2010  095cd3a0 ffffff80 73706f6f 646f6d5f 00656c75 00000000 00000000 00000000
[  867.148570] 2030  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148578] 2050  f089a080 ffffffc0 f26add00 ffffffc0 f2117e88 ffffffc0 f26add28 ffffffc0
[  867.148588] 2070  f26add00 ffffffc0 095c4c08 ffffff80 dbb66f78 ffffffc0 00000003 00000007
[  867.148596] 2090  00ef2000 ffffff80 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148605] 20b0  f2f99c00 ffffffc0 00000000 00000000 00000000 00000000 f089ab40 ffffffc0
[  867.148606] 
[  867.148606] X26: 0xffffffc0cde6e800:
[  867.148615] e800  00000001 00000000 d11d71a8 ffffffc0 00000000 00000000 00000000 00000000
[  867.148623] e820  cf2e6030 ffffffc0 00000000 00000000 0000046d 00000000 095c42c8 ffffff80
[  867.148632] e840  00000000 00000000 f7ec5e68 ffffffc0 00000000 00000000 00000000 00000000
[  867.148640] e860  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148649] e880  f106a880 ffffffc0 00000001 00000000 f089aa40 ffffffc0 00000124 00000000
[  867.148657] e8a0  00000024 00000000 00ef1000 ffffff80 081375b0 ffffff80 00000000 00000000
[  867.148665] e8c0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148674] e8e0  00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  867.148675] 
[  867.148675] X28: 0xffffff8008137650:
[  867.148684] 7650  a90153f3 aa0103f4 aa0203f3 aa1e03e0 d503201f f0008f21 913a1c21 f9402280
[  867.148693] 7670  b941d802 aa1303e0 940eb71d 93407c00 a94153f3 a8c27bfd d65f03c0 a9be7bfd
[  867.148701] 7690  910003fd a90153f3 aa0103f4 aa0203f3 aa1e03e0 d503201f f0008f21 913a1c21
[  867.148710] 76b0  f9402280 b9418802 aa1303e0 940eb70c 93407c00 a94153f3 a8c27bfd d65f03c0
[  867.148718] 76d0  a9be7bfd 910003fd a90153f3 aa0003f4 aa0203f3 aa1e03e0 d503201f aa1303e0
[  867.148727] 76f0  b0008b61 f9402282 91068021 940eb6fc 93407c00 a94153f3 a8c27bfd d65f03c0
[  867.148735] 7710  a9be7bfd 910003fd a90153f3 aa0003f3 aa0103f4 aa1e03e0 d503201f 52801801
[  867.148743] 7730  aa1403e0 72a04801 9401c11a f9006260 a94153f3 a8c27bfd d65f03c0 a9be7bfd
[  867.148745] 
[  867.148745] X29: 0xffffffc00a4ffbc0:
[  867.148754] fbc0  095b7860 ffffff80 00000000 00000000 00ef2050 ffffff80 00000001 00000000
[  867.148763] fbe0  cde6e880 ffffffc0 00000001 00000000 081376d0 ffffff80 0a4ffc40 ffffffc0
[  867.148771] fc00  00ef0018 ffffff80 0a4ffc40 ffffffc0 00ef0024 ffffff80 40000145 00000000
[  867.148780] fc20  ee9ae000 00000040 00012ffb 00000000 00000000 00000080 00000000 00000000
[  867.148790] fc40  0a4ffc50 ffffffc0 080830f8 ffffff80 0a4ffcd0 ffffffc0 0818d2d0 ffffff80
[  867.148798] fc60  00ef2000 ffffff80 095cd000 ffffff80 cde6e8c8 ffffffc0 cdce1140 ffffffc0
[  867.148807] fc80  00000000 00000000 0818d2a4 ffffff80 00ef2000 ffffff80 095cd000 ffffff80
[  867.148815] fca0  cde6e8c8 ffffffc0 095cd000 ffffff80 00000000 00000000 00ef2050 ffffff80
[  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] Process insmod (pid: 1163, stack limit = 0xffffffc00a4fc000)
[  867.148822] Stack: (0xffffffc00a4ffc40 to 0xffffffc00a500000)
[  867.148826] fc40: ffffffc00a4ffc50 ffffff80080830f8 ffffffc00a4ffcd0 ffffff800818d2d0
[  867.148829] fc60: ffffff8000ef2000 ffffff80095cd000 ffffffc0cde6e8c8 ffffffc0cdce1140
[  867.148832] fc80: 0000000000000000 ffffff800818d2a4 ffffff8000ef2000 ffffff80095cd000
[  867.148834] fca0: ffffffc0cde6e8c8 ffffff80095cd000 0000000000000000 ffffff8000ef2050
[  867.148837] fcc0: 0000000000000001 ffffffc0cde6e880 ffffffc00a4ffd00 ffffff800813ab5c
[  867.148840] fce0: ffffff8000ef2000 ffffffc00a4ffe58 ffffffc0cde6e8c8 ffffff80095cd000
[  867.148843] fd00: ffffffc00a4ffe20 ffffff800813b2b4 0000000000000000 00000055736b60f0
[  867.148846] fd20: 0000000000000003 0000007fb096c8c4 0000000040000000 0000000000000015
[  867.148849] fd40: 000000000000011d 0000000000000111 ffffff8008ef2000 ffffffc0cdc44380
[  867.148851] fd60: 0000000000000000 000000000002c098 ffffffc00a4ffe20 ffffff8008f00000
[  867.148854] fd80: 0000000000000000 00000055736b60f0 ffffffc000000064 ffffff8000000072
[  867.148857] fda0: ffffff800000006e ffffff800000003f ffffff8000000124 00000000024000c0
[  867.148860] fdc0: ffff81b400000030 000003e800000001 00000000000003e8 000000000002c098
[  867.148862] fde0: 00000000633eccfc 0000000000000000 0000000000000000 0000000000000000
[  867.148865] fe00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
[  867.148868] fe20: 0000000000000000 ffffff8008082f70 0000000000000000 00000040ee9ae000
[  867.148871] fe40: ffffffffffffffff 0000000000000001 0000000000000002 ffffff800bea0000
[  867.148874] fe60: 000000000002c098 ffffff800becb9d8 ffffff800becb8d0 ffffff800beb7748
[  867.148876] fe80: 0000000000003000 00000000000030d8 0000000000000000 0000000000000000
[  867.148879] fea0: 0000000000000478 0000001a00000019 0000000000000009 0000000000000004
[  867.148882] fec0: 0000000000000003 00000055736b60f0 0000000000000000 0000000000000003
[  867.148884] fee0: 0000000000000000 0000000000000218 0000000000000001 0000000000000001
[  867.148887] ff00: 0000000000000111 0000000000000003 0000000200000002 0000000000000000
[  867.148890] ff20: 00000000000010f0 0000000000000000 0000000000000000 0000000000000040
[  867.148892] ff40: 00000055736cddb0 0000007fb096c8a0 0000000000000000 0000005585e6b600
[  867.148895] ff60: 00000055736b60f0 0000000000000000 0000000000000000 0000005585e6b5d0
[  867.148898] ff80: 00000055736b2ef8 0000000000000000 0000000000000000 0000000000000000
[  867.148901] ffa0: 0000000000000000 0000007fdbea3bd0 00000055736abdc0 0000007fdbea3bd0
[  867.148903] ffc0: 0000007fb096c8c4 0000000040000000 0000000000000003 0000000000000111
[  867.148906] ffe0: 0000000000000000 0000000000000000 0000000000000000 0000000000000000

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

[  867.148907] Call trace:
[  867.148911] Exception stack(0xffffffc00a4ffa70 to 0xffffffc00a4ffba0)
[  867.148913] fa60:                                   ffffff8000ef0000 0000008000000000
[  867.148916] fa80: ffffffc00a4ffc40 ffffff8000ef0024 ffffff80097c02f8 0000000000000002
[  867.148918] faa0: ffffffc00a4ffac0 000000020001b57c 0000000000000000 0000000100000000
[  867.148921] fac0: ffffffc00a4ffb60 ffffff800810d674 ffffffc00a4ffbc0 ffffff8000ef1024
[  867.148924] fae0: ffffffc0cdce10c0 ffffff80095b7860 0000000000000000 ffffff8000ef2050
[  867.148927] fb00: 0000000000000001 ffffffc0cde6e880 0000000000000000 0000000019760817
[  867.148929] fb20: 0000000000000007 0000000000000007 0000000000000001 ffffffc0f7f24b38
[  867.148932] fb40: 0000000000000022 ffffff80096280b0 ffffff8008463c3c 0000000005f5e0ff
[  867.148935] fb60: ffffff80097bfa9f 00000000fffffffe 0000000000000030 000000000000000a
[  867.148937] fb80: 00000000000224d6 0000000000000000 ffffff800813b204 0000007fb096c8a0
[  867.148944] [<ffffff8000ef0024>] init_oopsdemo+0x24/0x38 [oops_module]
[  867.148953] [<ffffff80080830f8>] do_one_initcall+0x78/0x194
[  867.148958] [<ffffff800818d2d0>] do_init_module+0x64/0x1c0
[  867.148962] [<ffffff800813ab5c>] load_module+0x199c/0x1ed0
[  867.148964] [<ffffff800813b2b4>] SyS_finit_module+0xb0/0xbc
[  867.148968] [<ffffff8008082f70>] el0_svc_naked+0x24/0x28

棧回溯資訊,可以從中看出函數呼叫關係

[  867.148972] Code: 95ca7426 d2800000 528102e1 72a32ec1 (b9000001) 
[  867.148975] ---[ end trace 1983a52768236533 ]---
Segmentation fault

code是錯誤發生時PC指向的地址處的開頭20位元組的程式碼,括號裡的是出錯的具體指令。

如何根據OOPS找出bug

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

System.map檔案記錄了所有符號的執行地址,這裡的符號可以理解成函數名和變數。

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

0000000000000000 A __rela_size
0000000000000000 A _kernel_flags_le_hi32
0000000000000000 A _kernel_offset_le_hi32
0000000000000000 A _kernel_size_le_hi32
000000000000000a A _kernel_flags_le_lo32
0000000000000200 A PECOFF_FILE_ALIGNMENT
0000000000080000 A _kernel_offset_le_lo32
000000000159e638 A __rela_offset
0000000001800000 A _kernel_size_le_lo32
ffffff8008080000 t _head
ffffff8008080000 T _text
ffffff8008080800 T __exception_text_start
ffffff8008080800 T _stext
ffffff8008080800 T do_undefinstr
ffffff8008080a18 T do_sysinstr
ffffff8008080ab4 T do_mem_abort
ffffff8008080b60 T do_sp_pc_abort
ffffff8008080c34 T do_debug_exceptio
.............
ffffff8009879a48 b __key.30413
ffffff8009879a48 b __key.30416
ffffff8009879a48 b __key.48814
ffffff8009879a48 b __key.48818
ffffff8009879a48 b __key.48819
ffffff8009879a48 b __key.48820
ffffff8009879a48 b __key.48821
ffffff800987a000 B idmap_pg_dir
ffffff800987d000 B swapper_pg_dir
ffffff800987f000 B tramp_pg_dir
ffffff8009880000 B _end

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

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

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

反組合驅動檔案

而OOPS資訊也告訴我們,錯誤是出在了init_oopsdemo

[17981.657899] PC is at init_oopsdemo+0x24/0x38 [oops_module]
[17981.658385] LR is at init_oopsdemo+0x18/0x38 [oops_module]

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

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

ffffff8008080800 T do_undefinstr
ffffff8008080800 T _stext
ffffff8008080800 T __exception_text_start
ffffff8008080a18 T do_sysinstr
ffffff8008080ab4 T do_mem_abort
ffffff8008080b60 T do_sp_pc_abort
ffffff8008080c34 T do_debug_exception
.........
ffffff80094cfc0c T sparse_mem_map_populate
ffffff80094cfc64 T _einittext
0000000000000000 a oops_module.c        [oops_module]
ffffff8000ef0000 t $x   [oops_module]
ffffff8000ef0000 t init_oopsdemo        [oops_module]
ffffff8000ef0030 t $d   [oops_module]
ffffff8000ef0038 t $x   [oops_module]
ffffff8000ef0038 t cleanup_oopsdemo     [oops_module]
ffffff8000ef0058 t $d   [oops_module]
ffffff800bee40c8 ? __UNIQUE_ID_license2 [oops_module]
ffffff800bee40d4 ? __UNIQUE_ID_author1  [oops_module]
ffffff800bee40e3 ? __UNIQUE_ID_license0 [oops_module]
ffffff800befb368 n $d   [oops_module]
0000000000000000 a oops_module.mod.c    [oops_module]
ffffff8000ef2000 d $d   [oops_module]
ffffff800bee40f8 ? $d   [oops_module]
ffffff800bee40f8 ? __module_depends     [oops_module]
ffffff800bee4101 ? __UNIQUE_ID_vermagic0        [oops_module]
ffffff8000ef2000 d __this_module        [oops_module]
ffffff8000ef0038 t cleanup_module       [oops_module]
ffffff8000ef0000 t init_module  [oops_module]
ffffff800818d0ac u printk       [oops_module]
ffffff800808e770 u _mcount      [oops_module]                                      

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

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

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

oops_module.dis 內容如下

oops_module.ko:     file format elf64-littleaarch64


Disassembly of section .note.gnu.build-id:

0000000000000000 <.note.gnu.build-id>:
   0:   00000004        .inst   0x00000004 ; undefined
   4:   00000014        .inst   0x00000014 ; undefined
   8:   00000003        .inst   0x00000003 ; undefined
   c:   00554e47        .inst   0x00554e47 ; undefined
  10:   70d55614        adr     x20, fffffffffffaaad3 <__UNIQUE_ID_vermagic0+0xfffffffffffaaa9a>
  14:   56a7eb64        .inst   0x56a7eb64 ; undefined
  18:   a66fbdf8        .inst   0xa66fbdf8 ; undefined
  1c:   2b31c03f        cmn     w1, w17, sxtw
  20:   bd9e1ffe        .inst   0xbd9e1ffe ; undefined

Disassembly of section .text:

0000000000000000 <init_module>:
   0:   a9bf7bfd        stp     x29, x30, [sp, #-16]!
   4:   910003fd        mov     x29, sp
   8:   aa1e03e0        mov     x0, x30
   c:   94000000        bl      0 <_mcount>
  10:   58000100        ldr     x0, 30 <init_module+0x30>
  14:   94000000        bl      0 <printk>
  18:   d2800000        mov     x0, #0x0                        // #0
  1c:   528102e1        mov     w1, #0x817                      // #2071
  20:   72a32ec1        movk    w1, #0x1976, lsl #16
  24:   b9000001        str     w1, [x0]
  28:   a8c17bfd        ldp     x29, x30, [sp], #16
  2c:   d65f03c0        ret
        ...
        
0000000000000038 <cleanup_module>:
  38:   a9bf7bfd        stp     x29, x30, [sp, #-16]!
  3c:   910003fd        mov     x29, sp
  40:   aa1e03e0        mov     x0, x30
  44:   94000000        bl      0 <_mcount>
  48:   58000080        ldr     x0, 58 <cleanup_module+0x20>
  4c:   94000000        bl      0 <printk>
  50:   a8c17bfd        ldp     x29, x30, [sp], #16
  54:   d65f03c0        ret
        ...

Disassembly of section .modinfo:

0000000000000000 <__UNIQUE_ID_license2>:
   0:   6563696c        fnmls   z12.h, p2/m, z11.h, z3.h
   4:   3d65736e        ldr     b14, [x27, #2396]
   8:   004c5047        .inst   0x004c5047 ; undefined
        

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

24:   b9000001        str     w1, [x0] #將w1暫存器的值,傳送到地址值為x0的(記憶體)記憶體中

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

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

其他方法

gdb

➜  oops_module aarch64-linux-gnu-gdb  -q ./oops_module.ko 
Reading symbols from ./oops_module.ko...done.
(gdb) list *init_oopsdemo+0x24
0x4c is in init_oopsdemo (/home/zhongyi/code/module/oops_module/oops_module.c:10).
5       MODULE_AUTHOR("ZHONGYI");
6
7       static  int init_oopsdemo(void)
8       {
9           printk("oops module init! \n");
10          *((int*)0x00) = 0x19760817;
11          return 0;
12      }
13
14      module_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_module aarch64-linux-gnu-addr2line -e ./oops_module.ko -p -f 0x24
init_oopsdemo at /home/zhongyi/code/module/oops_module/oops_module.c:10
➜  oops_module cat /home/zhongyi/code/module/oops_module/oops_module.c | tail -n  +5 | head -n 10 
MODULE_AUTHOR("ZHONGYI");

static  int init_oopsdemo(void)
{
    printk("oops module init! \n");
    *((int*)0x00) = 0x19760817;
    return 0;
}

module_init(init_oopsdemo);

decodecode

在linux核心裡面有很多指令碼工具,位於linux/scripts/,裡面有一個decodecode工具可以用來轉換機器碼,decodecode指令碼可以在沒有原始碼或符號表的情況下,將oops異常的log作為輸入就可以解析出錯誤位置的組合程式碼。

oops_log.txt內容如下

call trace:
[  867.148911] Exception stack(0xffffffc00a4ffa70 to 0xffffffc00a4ffba0)
[  867.148913] fa60:                                   ffffff8000ef0000 0000008000000000
[  867.148916] fa80: ffffffc00a4ffc40 ffffff8000ef0024 ffffff80097c02f8 0000000000000002
[  867.148918] faa0: ffffffc00a4ffac0 000000020001b57c 0000000000000000 0000000100000000
[  867.148921] fac0: ffffffc00a4ffb60 ffffff800810d674 ffffffc00a4ffbc0 ffffff8000ef1024
[  867.148924] fae0: ffffffc0cdce10c0 ffffff80095b7860 0000000000000000 ffffff8000ef2050
[  867.148927] fb00: 0000000000000001 ffffffc0cde6e880 0000000000000000 0000000019760817
[  867.148929] fb20: 0000000000000007 0000000000000007 0000000000000001 ffffffc0f7f24b38
[  867.148932] fb40: 0000000000000022 ffffff80096280b0 ffffff8008463c3c 0000000005f5e0ff
[  867.148935] fb60: ffffff80097bfa9f 00000000fffffffe 0000000000000030 000000000000000a
[  867.148937] fb80: 00000000000224d6 0000000000000000 ffffff800813b204 0000007fb096c8a0
[  867.148944] [<ffffff8000ef0024>] init_oopsdemo+0x24/0x38 [oops_module]
[  867.148953] [<ffffff80080830f8>] do_one_initcall+0x78/0x194
[  867.148958] [<ffffff800818d2d0>] do_init_module+0x64/0x1c0
[  867.148962] [<ffffff800813ab5c>] load_module+0x199c/0x1ed0
[  867.148964] [<ffffff800813b2b4>] SyS_finit_module+0xb0/0xbc
[  867.148968] [<ffffff8008082f70>] el0_svc_naked+0x24/0x2
$ ARCH=arm64 CROSS_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 < /home/zhongyi/code/module/oops_module/oops_log.txt

Code: 95ca7426 d2800000 528102e1 72a32ec1 (b9000001)
All code
========
   0:   95ca7426        .word   0x95ca7426
   4:   d2800000        .word   0xd2800000
   8:   528102e1        .word   0x528102e1
   c:   72a32ec1        .word   0x72a32ec1
  10:*  b9000001        .word   0xb9000001              <-- trapping instruction

Code starting with the faulting instruction
===========================================
   0:   b9000001        .word   0xb9000001

執行指令碼後,就可以得到出錯的組合程式碼。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)
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ ${codename}      main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-updates  main restricted universe multiverse
EOF
sudo apt-get install -y ubuntu-dbgsym-keyring
sudo apt-get update
sudo apt-get install -y linux-image-$(uname -r)-dbgsym

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

➜  kernel git:(firefly) ✗ scripts/faddr2line  /home/zhongyi/code/module/oops_module/oops_module.ko init_oopsdemo+0x24
init_oopsdemo+0x24/0x30:
init_oopsdemo at /home/zhongyi/code/module/oops_module/oops_module.c:18

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

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

#include <linux/init.h>
#include <linux/module.h>

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

static  int init_oopsdemo(void)
{
    printk("oops module init! \n");
    *((int*)0x00) = 0x19760817;
    return 0;
}

module_init(init_oopsdemo);

static  void cleanup_oopsdemo(void)
{
    printk("oops module exit! \n");
}

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

本文參考

https://www.cnblogs.com/wwang/archive/2010/11/14/1876735.html

https://www.cnblogs.com/wsg1100/p/16609905.html

https://blog.csdn.net/W1107101310/article/details/80611880

https://zhuanlan.zhihu.com/p/557455268

https://www.jianshu.com/p/53b7cabbf483http://events.jianshu.io/p/e20ee313af0e

https://www.cnblogs.com/wanglouxiaozi/p/14813475.html

https://blog.csdn.net/qq_44710568/article/details/105413270