Skip to content

Commit 03fbf34

Browse files
author
Fox Snowpatch
committed
1 parent 35d5936 commit 03fbf34

File tree

6 files changed

+299
-239
lines changed

6 files changed

+299
-239
lines changed

Documentation/ABI/testing/sysfs-kernel-fadump

+11
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,14 @@ Contact: [email protected]
3838
Description: read only
3939
Provide information about the amount of memory reserved by
4040
FADump to save the crash dump in bytes.
41+
42+
What: /sys/kernel/fadump/hotplug_ready
43+
Date: Feb 2024
44+
45+
Description: read only
46+
Kdump udev rule re-registers fadump on memory add/remove events,
47+
primarily to update the elfcorehdr. This sysfs indicates the
48+
kdump udev rule that fadump re-registration is not required on
49+
memory add/remove events because elfcorehdr is now prepared in
50+
the second/fadump kernel.
51+
User: kexec-tools

Documentation/arch/powerpc/firmware-assisted-dump.rst

+42-49
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ that are run. If there is dump data, then the
134134
memory is held.
135135

136136
If there is no waiting dump data, then only the memory required to
137-
hold CPU state, HPTE region, boot memory dump, FADump header and
138-
elfcore header, is usually reserved at an offset greater than boot
139-
memory size (see Fig. 1). This area is *not* released: this region
140-
will be kept permanently reserved, so that it can act as a receptacle
141-
for a copy of the boot memory content in addition to CPU state and
142-
HPTE region, in the case a crash does occur.
137+
hold CPU state, HPTE region, boot memory dump, and FADump header is
138+
usually reserved at an offset greater than boot memory size (see Fig. 1).
139+
This area is *not* released: this region will be kept permanently
140+
reserved, so that it can act as a receptacle for a copy of the boot
141+
memory content in addition to CPU state and HPTE region, in the case
142+
a crash does occur.
143143

144144
Since this reserved memory area is used only after the system crash,
145145
there is no point in blocking this significant chunk of memory from
@@ -153,22 +153,22 @@ that were present in CMA region::
153153

154154
o Memory Reservation during first kernel
155155

156-
Low memory Top of memory
157-
0 boot memory size |<--- Reserved dump area --->| |
158-
| | | Permanent Reservation | |
159-
V V | | V
160-
+-----------+-----/ /---+---+----+-------+-----+-----+----+--+
161-
| | |///|////| DUMP | HDR | ELF |////| |
162-
+-----------+-----/ /---+---+----+-------+-----+-----+----+--+
163-
| ^ ^ ^ ^ ^
164-
| | | | | |
165-
\ CPU HPTE / | |
166-
------------------------------ | |
167-
Boot memory content gets transferred | |
168-
to reserved area by firmware at the | |
169-
time of crash. | |
170-
FADump Header |
171-
(meta area) |
156+
Low memory Top of memory
157+
0 boot memory size |<------ Reserved dump area ----->| |
158+
| | | Permanent Reservation | |
159+
V V | | V
160+
+-----------+-----/ /---+---+----+-----------+-------+----+-----+
161+
| | |///|////| DUMP | HDR |////| |
162+
+-----------+-----/ /---+---+----+-----------+-------+----+-----+
163+
| ^ ^ ^ ^ ^
164+
| | | | | |
165+
\ CPU HPTE / | |
166+
-------------------------------- | |
167+
Boot memory content gets transferred | |
168+
to reserved area by firmware at the | |
169+
time of crash. | |
170+
FADump Header |
171+
(meta area) |
172172
|
173173
|
174174
Metadata: This area holds a metadata structure whose
@@ -186,20 +186,33 @@ that were present in CMA region::
186186
0 boot memory size |
187187
| |<------------ Crash preserved area ------------>|
188188
V V |<--- Reserved dump area --->| |
189-
+-----------+-----/ /---+---+----+-------+-----+-----+----+--+
190-
| | |///|////| DUMP | HDR | ELF |////| |
191-
+-----------+-----/ /---+---+----+-------+-----+-----+----+--+
192-
| |
193-
V V
194-
Used by second /proc/vmcore
195-
kernel to boot
189+
+----+---+--+-----/ /---+---+----+-------+-----+-----+-------+
190+
| |ELF| | |///|////| DUMP | HDR |/////| |
191+
+----+---+--+-----/ /---+---+----+-------+-----+-----+-------+
192+
| | | | | |
193+
----- ------------------------------ ---------------
194+
\ | |
195+
\ | |
196+
\ | |
197+
\ | ----------------------------
198+
\ | /
199+
\ | /
200+
\ | /
201+
/proc/vmcore
202+
196203

197204
+---+
198205
|///| -> Regions (CPU, HPTE & Metadata) marked like this in the above
199206
+---+ figures are not always present. For example, OPAL platform
200207
does not have CPU & HPTE regions while Metadata region is
201208
not supported on pSeries currently.
202209

210+
+---+
211+
|ELF| -> elfcorehdr, it is created in second kernel after crash.
212+
+---+
213+
214+
Note: Memory from 0 to the boot memory size is used by second kernel
215+
203216
Fig. 2
204217

205218

@@ -353,26 +366,6 @@ TODO:
353366
- Need to come up with the better approach to find out more
354367
accurate boot memory size that is required for a kernel to
355368
boot successfully when booted with restricted memory.
356-
- The FADump implementation introduces a FADump crash info structure
357-
in the scratch area before the ELF core header. The idea of introducing
358-
this structure is to pass some important crash info data to the second
359-
kernel which will help second kernel to populate ELF core header with
360-
correct data before it gets exported through /proc/vmcore. The current
361-
design implementation does not address a possibility of introducing
362-
additional fields (in future) to this structure without affecting
363-
compatibility. Need to come up with the better approach to address this.
364-
365-
The possible approaches are:
366-
367-
1. Introduce version field for version tracking, bump up the version
368-
whenever a new field is added to the structure in future. The version
369-
field can be used to find out what fields are valid for the current
370-
version of the structure.
371-
2. Reserve the area of predefined size (say PAGE_SIZE) for this
372-
structure and have unused area as reserved (initialized to zero)
373-
for future field additions.
374-
375-
The advantage of approach 1 over 2 is we don't need to reserve extra space.
376369

377370
Author: Mahesh Salgaonkar <[email protected]>
378371

arch/powerpc/include/asm/fadump-internal.h

+29-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,38 @@ static inline u64 fadump_str_to_u64(const char *str)
4242

4343
#define FADUMP_CPU_UNKNOWN (~((u32)0))
4444

45-
#define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPINF")
45+
/*
46+
* The introduction of new fields in the fadump crash info header has
47+
* led to a change in the magic key from `FADMPINF` to `FADMPSIG` for
48+
* identifying a kernel crash from an old kernel.
49+
*
50+
* To prevent the need for further changes to the magic number in the
51+
* event of future modifications to the fadump crash info header, a
52+
* version field has been introduced to track the fadump crash info
53+
* header version.
54+
*
55+
* Consider a few points before adding new members to the fadump crash info
56+
* header structure:
57+
*
58+
* - Append new members; avoid adding them in between.
59+
* - Non-primitive members should have a size member as well.
60+
* - For every change in the fadump header, increment the
61+
* fadump header version. This helps the updated kernel decide how to
62+
* handle kernel dumps from older kernels.
63+
*/
64+
#define FADUMP_CRASH_INFO_MAGIC_OLD fadump_str_to_u64("FADMPINF")
65+
#define FADUMP_CRASH_INFO_MAGIC fadump_str_to_u64("FADMPSIG")
66+
#define FADUMP_HEADER_VERSION 1
4667

4768
/* fadump crash info structure */
4869
struct fadump_crash_info_header {
4970
u64 magic_number;
50-
u64 elfcorehdr_addr;
71+
u32 version;
5172
u32 crashing_cpu;
73+
u64 vmcoreinfo_raddr;
74+
u64 vmcoreinfo_size;
75+
u32 pt_regs_sz;
76+
u32 cpu_mask_sz;
5277
struct pt_regs regs;
5378
struct cpumask cpu_mask;
5479
};
@@ -94,6 +119,8 @@ struct fw_dump {
94119
u64 boot_mem_regs_cnt;
95120

96121
unsigned long fadumphdr_addr;
122+
u64 elfcorehdr_addr;
123+
u64 elfcorehdr_size;
97124
unsigned long cpu_notes_buf_vaddr;
98125
unsigned long cpu_notes_buf_size;
99126

0 commit comments

Comments
 (0)