Skip to content

Commit f0d2188

Browse files
committed
Automatic merge of 'next-test' into merge-test (2024-04-22 23:54)
2 parents 124f3f2 + 3e53919 commit f0d2188

File tree

54 files changed

+537
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+537
-404
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: Apr 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/Kbuild

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror
2+
subdir-ccflags-$(CONFIG_PPC_WERROR) := -Werror -Wa,--fatal-warnings
3+
subdir-asflags-$(CONFIG_PPC_WERROR) := -Wa,--fatal-warnings
34

45
obj-y += kernel/
56
obj-y += mm/

arch/powerpc/include/asm/cpu_has_feature.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static __always_inline bool cpu_has_feature(unsigned long feature)
2929
#endif
3030

3131
#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
32-
if (!static_key_initialized) {
32+
if (!static_key_feature_checks_initialized) {
3333
printk("Warning! cpu_has_feature() used prior to jump label init!\n");
3434
dump_stack();
3535
return early_cpu_has_feature(feature);

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

arch/powerpc/include/asm/feature-fixups.h

+2
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ extern long __start___rfi_flush_fixup, __stop___rfi_flush_fixup;
291291
extern long __start___barrier_nospec_fixup, __stop___barrier_nospec_fixup;
292292
extern long __start__btb_flush_fixup, __stop__btb_flush_fixup;
293293

294+
extern bool static_key_feature_checks_initialized;
295+
294296
void apply_feature_fixups(void);
295297
void update_mmu_feature_fixups(unsigned long mask);
296298
void setup_feature_keys(void);

arch/powerpc/include/asm/hvcall.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ struct hvcall_mpp_data {
570570
unsigned long backing_mem;
571571
};
572572

573-
int h_get_mpp(struct hvcall_mpp_data *);
573+
long h_get_mpp(struct hvcall_mpp_data *mpp_data);
574574

575575
struct hvcall_mpp_x_data {
576576
unsigned long coalesced_bytes;

arch/powerpc/include/asm/interrupt.h

+10
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ static inline void interrupt_nmi_enter_prepare(struct pt_regs *regs, struct inte
336336
if (IS_ENABLED(CONFIG_KASAN))
337337
return;
338338

339+
/*
340+
* Likewise, do not use it in real mode if percpu first chunk is not
341+
* embedded. With CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK enabled there
342+
* are chances where percpu allocation can come from vmalloc area.
343+
*/
344+
if (percpu_first_chunk_is_paged)
345+
return;
346+
339347
/* Otherwise, it should be safe to call it */
340348
nmi_enter();
341349
}
@@ -351,6 +359,8 @@ static inline void interrupt_nmi_exit_prepare(struct pt_regs *regs, struct inter
351359
// no nmi_exit for a pseries hash guest taking a real mode exception
352360
} else if (IS_ENABLED(CONFIG_KASAN)) {
353361
// no nmi_exit for KASAN in real mode
362+
} else if (percpu_first_chunk_is_paged) {
363+
// no nmi_exit if percpu first chunk is not embedded
354364
} else {
355365
nmi_exit();
356366
}

arch/powerpc/include/asm/mmu.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static __always_inline bool mmu_has_feature(unsigned long feature)
251251
#endif
252252

253253
#ifdef CONFIG_JUMP_LABEL_FEATURE_CHECK_DEBUG
254-
if (!static_key_initialized) {
254+
if (!static_key_feature_checks_initialized) {
255255
printk("Warning! mmu_has_feature() used prior to jump label init!\n");
256256
dump_stack();
257257
return early_mmu_has_feature(feature);

arch/powerpc/include/asm/percpu.h

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
#endif /* CONFIG_SMP */
1616
#endif /* __powerpc64__ */
1717

18+
#if defined(CONFIG_NEED_PER_CPU_PAGE_FIRST_CHUNK) && defined(CONFIG_SMP)
19+
#include <linux/jump_label.h>
20+
DECLARE_STATIC_KEY_FALSE(__percpu_first_chunk_is_paged);
21+
22+
#define percpu_first_chunk_is_paged \
23+
(static_key_enabled(&__percpu_first_chunk_is_paged.key))
24+
#else
25+
#define percpu_first_chunk_is_paged false
26+
#endif /* CONFIG_PPC64 && CONFIG_SMP */
27+
1828
#include <asm-generic/percpu.h>
1929

2030
#include <asm/paca.h>

0 commit comments

Comments
 (0)