]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - Documentation/admin-guide/ramoops.rst
x86/cpu: Make alternative_msr_write work for 32-bit code
[mirror_ubuntu-artful-kernel.git] / Documentation / admin-guide / ramoops.rst
CommitLineData
4126dacb
SI
1Ramoops oops/panic logger
2=========================
3
4Sergiu Iordache <sergiu@chromium.org>
5
9ba80d99 6Updated: 17 November 2011
4126dacb 7
b2777b65
MCC
8Introduction
9------------
4126dacb
SI
10
11Ramoops is an oops/panic logger that writes its logs to RAM before the system
12crashes. It works by logging oopses and panics in a circular buffer. Ramoops
13needs a system with persistent RAM so that the content of that area can
14survive after a restart.
15
b2777b65
MCC
16Ramoops concepts
17----------------
4126dacb 18
027bc8b0
TL
19Ramoops uses a predefined memory area to store the dump. The start and size
20and type of the memory area are set using three variables:
b2777b65
MCC
21
22 * ``mem_address`` for the start
23 * ``mem_size`` for the size. The memory size will be rounded down to a
24 power of two.
25 * ``mem_type`` to specifiy if the memory type (default is pgprot_writecombine).
26
27Typically the default value of ``mem_type=0`` should be used as that sets the pstore
28mapping to pgprot_writecombine. Setting ``mem_type=1`` attempts to use
29``pgprot_noncached``, which only works on some platforms. This is because pstore
027bc8b0
TL
30depends on atomic operations. At least on ARM, pgprot_noncached causes the
31memory to be mapped strongly ordered, and atomic operations on strongly ordered
32memory are implementation defined, and won't work on many ARMs such as omaps.
4126dacb 33
b2777b65
MCC
34The memory area is divided into ``record_size`` chunks (also rounded down to
35power of two) and each oops/panic writes a ``record_size`` chunk of
4126dacb
SI
36information.
37
b2777b65 38Dumping both oopses and panics can be done by setting 1 in the ``dump_oops``
4126dacb
SI
39variable while setting 0 in that variable dumps only the panics.
40
41The module uses a counter to record multiple dumps but the counter gets reset
42on restart (i.e. new dumps after the restart will overwrite old ones).
43
39eb7e97
AV
44Ramoops also supports software ECC protection of persistent memory regions.
45This might be useful when a hardware reset was used to bring the machine back
46to life (i.e. a watchdog triggered). In such cases, RAM may be somewhat
47corrupt, but usually it is restorable.
48
b2777b65
MCC
49Setting the parameters
50----------------------
4126dacb 51
529182e2
KC
52Setting the ramoops parameters can be done in several different manners:
53
54 A. Use the module parameters (which have the names of the variables described
55 as before). For quick debugging, you can also reserve parts of memory during
56 boot and then use the reserved memory for ramoops. For example, assuming a
57 machine with > 128 MB of memory, the following kernel command line will tell
58 the kernel to use only the first 128 MB of memory, and place ECC-protected
b2777b65
MCC
59 ramoops region at 128 MB boundary::
60
61 mem=128M ramoops.mem_address=0x8000000 ramoops.ecc=1
529182e2
KC
62
63 B. Use Device Tree bindings, as described in
8c27ceff 64 ``Documentation/device-tree/bindings/reserved-memory/admin-guide/ramoops.rst``.
b2777b65 65 For example::
529182e2
KC
66
67 reserved-memory {
68 #address-cells = <2>;
69 #size-cells = <2>;
70 ranges;
71
72 ramoops@8f000000 {
73 compatible = "ramoops";
74 reg = <0 0x8f000000 0 0x100000>;
75 record-size = <0x4000>;
76 console-size = <0x4000>;
77 };
78 };
79
80 C. Use a platform device and set the platform data. The parameters can then
07a37ba5
JN
81 be set through that platform data. An example of doing that is:
82
83 .. code-block:: c
4126dacb 84
b2777b65
MCC
85 #include <linux/pstore_ram.h>
86 [...]
4126dacb 87
b2777b65 88 static struct ramoops_platform_data ramoops_data = {
4126dacb
SI
89 .mem_size = <...>,
90 .mem_address = <...>,
027bc8b0 91 .mem_type = <...>,
4126dacb
SI
92 .record_size = <...>,
93 .dump_oops = <...>,
39eb7e97 94 .ecc = <...>,
b2777b65 95 };
4126dacb 96
b2777b65 97 static struct platform_device ramoops_dev = {
4126dacb
SI
98 .name = "ramoops",
99 .dev = {
100 .platform_data = &ramoops_data,
101 },
b2777b65 102 };
4126dacb 103
b2777b65
MCC
104 [... inside a function ...]
105 int ret;
4126dacb 106
b2777b65
MCC
107 ret = platform_device_register(&ramoops_dev);
108 if (ret) {
4126dacb
SI
109 printk(KERN_ERR "unable to register platform device\n");
110 return ret;
b2777b65 111 }
4126dacb 112
958502d8
AV
113You can specify either RAM memory or peripheral devices' memory. However, when
114specifying RAM, be sure to reserve the memory by issuing memblock_reserve()
b2777b65 115very early in the architecture code, e.g.::
958502d8 116
b2777b65 117 #include <linux/memblock.h>
958502d8 118
b2777b65 119 memblock_reserve(ramoops_data.mem_address, ramoops_data.mem_size);
958502d8 120
b2777b65
MCC
121Dump format
122-----------
4126dacb 123
b2777b65 124The data dump begins with a header, currently defined as ``====`` followed by a
4126dacb
SI
125timestamp and a new line. The dump then continues with the actual data.
126
b2777b65
MCC
127Reading the data
128----------------
4126dacb 129
9ba80d99 130The dump data can be read from the pstore filesystem. The format for these
b2777b65 131files is ``dmesg-ramoops-N``, where N is the record number in memory. To delete
9ba80d99 132a stored record from RAM, simply unlink the respective pstore file.
a694d1b5 133
b2777b65
MCC
134Persistent function tracing
135---------------------------
a694d1b5
AV
136
137Persistent function tracing might be useful for debugging software or hardware
b2777b65
MCC
138related hangs. The functions call chain log is stored in a ``ftrace-ramoops``
139file. Here is an example of usage::
a694d1b5
AV
140
141 # mount -t debugfs debugfs /sys/kernel/debug/
65f8c95e 142 # echo 1 > /sys/kernel/debug/pstore/record_ftrace
a694d1b5
AV
143 # reboot -f
144 [...]
145 # mount -t pstore pstore /mnt/
146 # tail /mnt/ftrace-ramoops
147 0 ffffffff8101ea64 ffffffff8101bcda native_apic_mem_read <- disconnect_bsp_APIC+0x6a/0xc0
148 0 ffffffff8101ea44 ffffffff8101bcf6 native_apic_mem_write <- disconnect_bsp_APIC+0x86/0xc0
149 0 ffffffff81020084 ffffffff8101a4b5 hpet_disable <- native_machine_shutdown+0x75/0x90
150 0 ffffffff81005f94 ffffffff8101a4bb iommu_shutdown_noop <- native_machine_shutdown+0x7b/0x90
151 0 ffffffff8101a6a1 ffffffff8101a437 native_machine_emergency_restart <- native_machine_restart+0x37/0x40
152 0 ffffffff811f9876 ffffffff8101a73a acpi_reboot <- native_machine_emergency_restart+0xaa/0x1e0
153 0 ffffffff8101a514 ffffffff8101a772 mach_reboot_fixups <- native_machine_emergency_restart+0xe2/0x1e0
154 0 ffffffff811d9c54 ffffffff8101a7a0 __const_udelay <- native_machine_emergency_restart+0x110/0x1e0
155 0 ffffffff811d9c34 ffffffff811d9c80 __delay <- __const_udelay+0x30/0x40
156 0 ffffffff811d9d14 ffffffff811d9c3f delay_tsc <- __delay+0xf/0x20