如何解读Linux Kernel OOPS信息( 二 )

[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=0000000000000000pgd,pud试图访问的地址的页表信息,本例中为0 。
[867.142164] Internal error: Oops: 96000045 [#1] SMP96000045表示错误码 。后面[]内的数值是与页面有关的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: GO4.4.194+ #7[867.143649] Hardware name: Firefly-RK3399 Board (Linux Opensource) (DT)[867.144236] task: ffffffc0cdc44380 task.stack: ffffffc00a4fc000CPU后的数字是错误所在逻辑CPU的编号,PID表示正在运行的进程ID1511,内核污染原因(G),内核版本( 4.4.194) 。
内核污染原因包括私有驱动加载(P),模块强制加载(F),模块强制卸载(R),机器检查异常发生(M),检测到错误页(B)等 。
如果涉及到了某项原因,就会显示为Tainted: GPF 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 : ffffffc00a4ffc40init_oopsdemo+0x24/0x38[oops_module]表示错误发生的地址是oops_module中的init_oopsdemo

经验总结扩展阅读