powerpc/fadump: save CPU reg data in vmcore when PHYP terminates LPAR
authorHari Bathini <hbathini@linux.ibm.com>
Mon, 4 Apr 2022 18:21:37 +0000 (23:51 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 26 Apr 2022 12:36:57 +0000 (22:36 +1000)
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.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220404182137.59231-1-hbathini@linux.ibm.com
arch/powerpc/include/asm/fadump-internal.h
arch/powerpc/kernel/fadump.c
arch/powerpc/platforms/pseries/rtas-fadump.c

index 81bcb9abb3718fdf3cfa9898efd52b5c1656c384..27f9e11eda28cd2c9254b52e9fdafe1eac820003 100644 (file)
@@ -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 {
index 65562c4a0a690b7672eddacfe81c2ecda083fcd7..8343c0b142772be4cdf5a4c05e466b5aaa9f5a69 100644 (file)
@@ -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;
 }
index 35f9cb602c304bb3fc595c32447a126564fa09ae..617c0f3b1f4f155900a1bc761f509df43a5344db 100644 (file)
@@ -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;
                }