blob: 197ad59ab9bf71cbcfbec783680105967ead06a7 [file] [log] [blame]
Sergiu Iordache4126dac2011-08-13 12:34:56 -07001Ramoops oops/panic logger
2=========================
3
4Sergiu Iordache <sergiu@chromium.org>
5
Kees Cook9ba80d92012-05-03 15:45:02 +10006Updated: 17 November 2011
Sergiu Iordache4126dac2011-08-13 12:34:56 -07007
80. Introduction
9
10Ramoops is an oops/panic logger that writes its logs to RAM before the system
11crashes. It works by logging oopses and panics in a circular buffer. Ramoops
12needs a system with persistent RAM so that the content of that area can
13survive after a restart.
14
151. Ramoops concepts
16
17Ramoops uses a predefined memory area to store the dump. The start and size of
18the memory area are set using two variables:
19 * "mem_address" for the start
20 * "mem_size" for the size. The memory size will be rounded down to a
21 power of two.
22
23The memory area is divided into "record_size" chunks (also rounded down to
24power of two) and each oops/panic writes a "record_size" chunk of
25information.
26
27Dumping both oopses and panics can be done by setting 1 in the "dump_oops"
28variable while setting 0 in that variable dumps only the panics.
29
30The module uses a counter to record multiple dumps but the counter gets reset
31on restart (i.e. new dumps after the restart will overwrite old ones).
32
Anton Vorontsov39eb7e972012-05-17 00:15:34 -070033Ramoops also supports software ECC protection of persistent memory regions.
34This might be useful when a hardware reset was used to bring the machine back
35to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat
36corrupt, but usually it is restorable.
37
Sergiu Iordache4126dac2011-08-13 12:34:56 -0700382. Setting the parameters
39
40Setting the ramoops parameters can be done in 2 different manners:
41 1. Use the module parameters (which have the names of the variables described
42 as before).
Anton Vorontsov958502d2012-05-26 06:20:25 -070043 For quick debugging, you can also reserve parts of memory during boot
44 and then use the reserved memory for ramoops. For example, assuming a machine
45 with > 128 MB of memory, the following kernel command line will tell the
46 kernel to use only the first 128 MB of memory, and place ECC-protected ramoops
47 region at 128 MB boundary:
48 "mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1"
Sergiu Iordache4126dac2011-08-13 12:34:56 -070049 2. Use a platform device and set the platform data. The parameters can then
50 be set through that platform data. An example of doing that is:
51
Anton Vorontsov1894a252012-05-16 05:43:08 -070052#include <linux/pstore_ram.h>
Sergiu Iordache4126dac2011-08-13 12:34:56 -070053[...]
54
55static struct ramoops_platform_data ramoops_data = {
56 .mem_size = <...>,
57 .mem_address = <...>,
58 .record_size = <...>,
59 .dump_oops = <...>,
Anton Vorontsov39eb7e972012-05-17 00:15:34 -070060 .ecc = <...>,
Sergiu Iordache4126dac2011-08-13 12:34:56 -070061};
62
63static struct platform_device ramoops_dev = {
64 .name = "ramoops",
65 .dev = {
66 .platform_data = &ramoops_data,
67 },
68};
69
70[... inside a function ...]
71int ret;
72
73ret = platform_device_register(&ramoops_dev);
74if (ret) {
75 printk(KERN_ERR "unable to register platform device\n");
76 return ret;
77}
78
Anton Vorontsov958502d2012-05-26 06:20:25 -070079You can specify either RAM memory or peripheral devices' memory. However, when
80specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
81very early in the architecture code, e.g.:
82
83#include <linux/memblock.h>
84
85memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
86
Sergiu Iordache4126dac2011-08-13 12:34:56 -0700873. Dump format
88
89The data dump begins with a header, currently defined as "====" followed by a
90timestamp and a new line. The dump then continues with the actual data.
91
924. Reading the data
93
Kees Cook9ba80d92012-05-03 15:45:02 +100094The dump data can be read from the pstore filesystem. The format for these
95files is "dmesg-ramoops-N", where N is the record number in memory. To delete
96a stored record from RAM, simply unlink the respective pstore file.
Anton Vorontsova694d1b2012-07-09 17:10:44 -070097
985. Persistent function tracing
99
100Persistent function tracing might be useful for debugging software or hardware
101related hangs. The functions call chain log is stored in a "ftrace-ramoops"
102file. Here is an example of usage:
103
104 # mount -t debugfs debugfs /sys/kernel/debug/
105 # cd /sys/kernel/debug/tracing
106 # echo function > current_tracer
107 # echo 1 > options/func_pstore
108 # reboot -f
109 [...]
110 # mount -t pstore pstore /mnt/
111 # tail /mnt/ftrace-ramoops
112 0 ffffffff8101ea64 ffffffff8101bcda native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
113 0 ffffffff8101ea44 ffffffff8101bcf6 native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
114 0 ffffffff81020084 ffffffff8101a4b5 hpet_disable <- native_machine_shutdown+0x75/0x90
115 0 ffffffff81005f94 ffffffff8101a4bb iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
116 0 ffffffff8101a6a1 ffffffff8101a437 native_machine_emergency_restart <- native_machine_restart+0x37/0x40
117 0 ffffffff811f9876 ffffffff8101a73a acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
118 0 ffffffff8101a514 ffffffff8101a772 mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
119 0 ffffffff811d9c54 ffffffff8101a7a0 __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
120 0 ffffffff811d9c34 ffffffff811d9c80 __delay <- __const_udelay+0x30/0x40
121 0 ffffffff811d9d14 ffffffff811d9c3f delay_tsc <- __delay+0xf/0x20