diff mbox series

powerpc/fadump: save CPU reg data in vmcore when PHYP terminates LPAR

Message ID 20220404182137.59231-1-hbathini@linux.ibm.com (mailing list archive)
State Accepted
Headers show
Series powerpc/fadump: save CPU reg data in vmcore when PHYP terminates LPAR | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 24 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 7 jobs.

Commit Message

Hari Bathini April 4, 2022, 6:21 p.m. UTC
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>
---
 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(-)

Comments

Mahesh J Salgaonkar April 8, 2022, 4:59 a.m. UTC | #1
On 2022-04-04 23:51:37 Mon, Hari Bathini wrote:
> 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>
> ---
>  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(-)
> 
> diff --git a/arch/powerpc/include/asm/fadump-internal.h b/arch/powerpc/include/asm/fadump-internal.h
> index 81bcb9abb371..27f9e11eda28 100644
> --- a/arch/powerpc/include/asm/fadump-internal.h
> +++ b/arch/powerpc/include/asm/fadump-internal.h
> @@ -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 {
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index 65562c4a0a69..8343c0b14277 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -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;

Looks good to me.

Reviewed-by: Mahesh Salgaonkar <mahesh@linux.ibm.com>

Thanks,
-Mahesh.

>  
>  	return addr;
>  }
> diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
> index 35f9cb602c30..617c0f3b1f4f 100644
> --- a/arch/powerpc/platforms/pseries/rtas-fadump.c
> +++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
> @@ -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;
>  		}
> -- 
> 2.35.1
>
Michael Ellerman May 15, 2022, 10:12 a.m. UTC | #2
On Mon, 4 Apr 2022 23:51:37 +0530, Hari Bathini wrote:
> 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
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/fadump-internal.h b/arch/powerpc/include/asm/fadump-internal.h
index 81bcb9abb371..27f9e11eda28 100644
--- a/arch/powerpc/include/asm/fadump-internal.h
+++ b/arch/powerpc/include/asm/fadump-internal.h
@@ -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 {
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 65562c4a0a69..8343c0b14277 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -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;
 }
diff --git a/arch/powerpc/platforms/pseries/rtas-fadump.c b/arch/powerpc/platforms/pseries/rtas-fadump.c
index 35f9cb602c30..617c0f3b1f4f 100644
--- a/arch/powerpc/platforms/pseries/rtas-fadump.c
+++ b/arch/powerpc/platforms/pseries/rtas-fadump.c
@@ -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;
 		}