powerpc/fadump: save CPU reg data in vmcore when PHYP terminates LPAR
PATCH 1/1 powerpc/fadump: save CPU reg data in vmcore when PHYP terminates LPAR
An LPAR can be terminated by the POWER Hypervisor (PHYP) for various reasons. If FADump was configured when PHYP terminates the LPAR, platform-assisted dump is initiated to save the kernel dump. But CPU register data would not be processed/saved in the vmcore in such case because CPU mask is set in crash_fadump() at the time of kernel crash and it remains unset in this case with LPAR being terminated by PHYP abruptly.
To get around the problem, initialize cpu_mask to cpu_possible_mask so as to ensure all possible CPUs' register data is processed for the vmcore generated on PHYP terminated LPAR. Also, rename the crash info member variable from online_mask to cpu_mask as it doesn't necessarily have to be online CPU mask always.
--- arch/powerpc/include/asm/fadump-internal.h | 2 +- arch/powerpc/kernel/fadump.c | 7 ++++++- arch/powerpc/platforms/pseries/rtas-fadump.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/fadump-internal.h +1 -1
@@ -50,7 +50,7 @@ struct fadump_crash_info_header {u64 elfcorehdr_addr;u32 crashing_cpu;struct pt_regs regs; -struct cpumask online_mask; +struct cpumask cpu_mask; };struct fadump_memory_range {
arch/powerpc/kernel/fadump.c +6 -1
@@ -728,7 +728,7 @@ void crash_fadump(struct pt_regs *regs, const char *str)else ppc_save_regs (&fdh->regs); - fdh->online_mask = *cpu_online_mask; + fdh->cpu_mask = *cpu_online_mask;/* * If we came in via system reset, wait a while for the secondary
@@ -1164,6 +1164,11 @@ static unsigned long init_fadump_header(unsigned long addr) fdh->elfcorehdr_addr = addr;/* We will set the crashing cpu id in crash_fadump() during crash. */ fdh->crashing_cpu =FADUMP_CPU_UNKNOWN ; +/* +* When LPAR is terminated by PYHP, ensure all possible CPUs' +* register data is processed while exporting the vmcore. +*/ + fdh->cpu_mask = *cpu_possible_mask;return addr; }
arch/powerpc/platforms/pseries/rtas-fadump.c +1 -1
@@ -351,7 +351,7 @@ static int __init rtas_fadump_build_cpu_notes(struct fw_dump *fadump_conf)/* Lower 4 bytes of reg_value contains logical cpu id */ cpu = (be64_to_cpu (reg_entry->reg_value) &RTAS_FADUMP_CPU_ID_MASK ); -if (fdh && !cpumask_test_cpu (cpu, &fdh->online_mask)) { +if (fdh && !cpumask_test_cpu (cpu, &fdh->cpu_mask)) {RTAS_FADUMP_SKIP_TO_NEXT_CPU (reg_entry);continue ; }
Signature · 1 line
2.35.1
Quoted 48 lines · Hari Bathini
An LPAR can be terminated by the POWER Hypervisor (PHYP) for various reasons. If FADump was configured when PHYP terminates the LPAR, platform-assisted dump is initiated to save the kernel dump. But CPU register data would not be processed/saved in the vmcore in such case because CPU mask is set in
crash_fadump()at the time of kernel crash and it remains unset in this case with LPAR being terminated by PHYP abruptly.To get around the problem, initialize
cpu_masktocpu_possible_maskso as to ensure all possible CPUs' register data is processed for the vmcore generated on PHYP terminated LPAR. Also, rename the crash info member variable fromonline_masktocpu_maskas it doesn't necessarily have to be online CPU mask always.Signed-off-by Hari Bathini <[email protected]>--- arch/powerpc/include/asm/fadump-internal.h | 2 +- arch/powerpc/kernel/fadump.c | 7 ++++++- arch/powerpc/platforms/pseries/rtas-fadump.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-)arch/powerpc/include/asm/fadump-internal.h +1
-1@@ -50,7 +50,7 @@ struct fadump_crash_info_header {u64 elfcorehdr_addr;u32 crashing_cpu;struct pt_regs regs; -struct cpumask online_mask; +struct cpumask cpu_mask; };struct fadump_memory_range {arch/powerpc/kernel/fadump.c +1
-1@@ -728,7 +728,7 @@ void crash_fadump(struct pt_regs *regs, const char *str)else ppc_save_regs (&fdh->regs); - fdh->online_mask = *cpu_online_mask; + fdh->cpu_mask = *cpu_online_mask;/* * If we came in via system reset, wait a while for the secondary
arch/powerpc/kernel/fadump.c static unsigned long init_fadump_header(unsigned long addr) · line 1171
Quoted 8 lines
arch/powerpc/kernel/fadump.c +5
-0@@ -1164,6 +1164,11 @@ static unsigned long init_fadump_header(unsigned long addr) fdh->elfcorehdr_addr = addr;/* We will set the crashing cpu id in crash_fadump() during crash. */ fdh->crashing_cpu =FADUMP_CPU_UNKNOWN ; +/* +* When LPAR is terminated by PYHP, ensure all possible CPUs' +* register data is processed while exporting the vmcore. +*/ + fdh->cpu_mask = *cpu_possible_mask;
Looks good to me.
Thanks,
-Mahesh.
Quoted 19 lines
arch/powerpc/kernel/fadump.c +0
-0return addr; }arch/powerpc/platforms/pseries/rtas-fadump.c +1
-1@@ -351,7 +351,7 @@ static int __init rtas_fadump_build_cpu_notes(struct fw_dump *fadump_conf)/* Lower 4 bytes of reg_value contains logical cpu id */ cpu = (be64_to_cpu (reg_entry->reg_value) &RTAS_FADUMP_CPU_ID_MASK ); -if (fdh && !cpumask_test_cpu (cpu, &fdh->online_mask)) { +if (fdh && !cpumask_test_cpu (cpu, &fdh->cpu_mask)) {RTAS_FADUMP_SKIP_TO_NEXT_CPU (reg_entry);continue ; }Signature · 1 line
2.35.1
Signature · 1 line
Mahesh J Salgaonkar
Michael Ellerman
AppliedQuoted 9 lines · Hari Bathini
An LPAR can be terminated by the POWER Hypervisor (PHYP) for various reasons. If FADump was configured when PHYP terminates the LPAR, platform-assisted dump is initiated to save the kernel dump. But CPU register data would not be processed/saved in the vmcore in such case because CPU mask is set in
crash_fadump()at the time of kernel crash and it remains unset in this case with LPAR being terminated by PHYP abruptly.[...]
Applied to powerpc/next.
[1/1] powerpc/fadump: save CPU reg data in vmcore when PHYP terminates LPAR
https://git.kernel.org/powerpc/c/6584cec0a2255ab407d047d1b135fa0aae88d6c6
cheers