Linux内核错误panic oops

1、panic
当内核遇到严重错误的时候,内核panic,立马崩溃。死机。

2、oops
oops是内核遇到错误时发出的提示“声音”,oops有时候会触发panic,有时候不会,而是直接杀死当前进程,系统可以继续运行。

比如说内核态下的段错误,当内核设置了panic_on_oops=1的时候,oops会触发panic。【panic_on_oops的值在内核编译的时候配置,可以在/proc/sys/kernel/panic_on_oops查看值,同时可以使用sysctl修改】

当panic_on_oops=0的时候,如果错误发生在中断上下文,oops也会触发panic。如果错误只是发生在进程上下文,这个时候只需要kill当前进程。【中断上下文包括以下情况:硬中断、软中断、NMI】。

oops的时候内核还可以运行,只是可能不稳定,这个时候,内核会调用printk打印输出内核栈的信息和寄存器的信息。

oops提示:

[  263.336138] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[  263.342790] pgd = d4a44000
[  263.345467] [00000000] *pgd=566db831, *pte=00000000, *ppte=00000000
[  263.351708] Internal error: Oops: 817 [#1] PREEMPT SMP
[  263.356826] Modules linked in: hello(+)
[  263.360647] CPU: 0    Not tainted  (3.0.15 #20)
[  263.365165] PC is at hello_init+0x18/0x20 [hello]
[  263.369856] LR is at do_one_initcall+0x3c/0x190
[  263.374361] pc : [<bf002018>]    lr : [<c003e684>]    psr: 60000013
[  263.374365] sp : d4a17f18  ip : d4a17f28  fp : d4a17f24
[  263.385817] r10: 00000000  r9 : d4a16000  r8 : c0045ae8
[  263.391025] r7 : 0000534b  r6 : 00000000  r5 : bf000034  r4 : c096f840
[  263.397536] r3 : 00000000  r2 : 00000001  r1 : d4a17f28  r0 : 00000000
[  263.404047] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  263.411163] Control: 10c5387d  Table: 54a4404a  DAC: 00000015
[  263.416891] 
[  263.416893] LR: 0xc003e604:

from: https://blog.csdn.net/weixin_38812277/article/details/95939853

原文地址:https://www.cnblogs.com/aspirs/p/14706401.html