Blame SOURCES/0026-ppc64-still-allow-to-move-on-if-the-emergency-stacks.patch

3ce5e9
From edbd19bb260f7a98bc9e0b49fe2f0b8214885797 Mon Sep 17 00:00:00 2001
3ce5e9
From: Lianbo Jiang <lijiang@redhat.com>
3ce5e9
Date: Tue, 4 Oct 2022 18:57:11 +0800
3ce5e9
Subject: [PATCH 26/28] ppc64: still allow to move on if the emergency stacks
3ce5e9
 info fails to initialize
3ce5e9
3ce5e9
Currently crash will fail and then exit, if the initialization of
3ce5e9
the emergency stacks information fails. In real customer environments,
3ce5e9
sometimes, a vmcore may be partially damaged, although such vmcores
3ce5e9
are rare. For example:
3ce5e9
3ce5e9
  # ./crash ../3.10.0-1127.18.2.el7.ppc64le/vmcore ../3.10.0-1127.18.2.el7.ppc64le/vmlinux  -s
3ce5e9
  crash: invalid kernel virtual address: 38  type: "paca->emergency_sp"
3ce5e9
  #
3ce5e9
3ce5e9
Lets try to keep loading vmcore if such issues happen, so call
3ce5e9
the readmem() with the RETURN_ON_ERROR instead of FAULT_ON_ERROR,
3ce5e9
which allows the crash move on.
3ce5e9
3ce5e9
Reported-by: Dave Wysochanski <dwysocha@redhat.com>
3ce5e9
Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
3ce5e9
---
3ce5e9
 ppc64.c | 18 +++++++++---------
3ce5e9
 1 file changed, 9 insertions(+), 9 deletions(-)
3ce5e9
3ce5e9
diff --git a/ppc64.c b/ppc64.c
3ce5e9
index 4ea1f7c0c6f8..b95a621d8fe4 100644
3ce5e9
--- a/ppc64.c
3ce5e9
+++ b/ppc64.c
3ce5e9
@@ -1224,13 +1224,13 @@ ppc64_init_paca_info(void)
3ce5e9
 		ulong paca_loc;
3ce5e9
 
3ce5e9
 		readmem(symbol_value("paca_ptrs"), KVADDR, &paca_loc, sizeof(void *),
3ce5e9
-			"paca double pointer", FAULT_ON_ERROR);
3ce5e9
+			"paca double pointer", RETURN_ON_ERROR);
3ce5e9
 		readmem(paca_loc, KVADDR, paca_ptr, sizeof(void *) * kt->cpus,
3ce5e9
-			"paca pointers", FAULT_ON_ERROR);
3ce5e9
+			"paca pointers", RETURN_ON_ERROR);
3ce5e9
 	} else if (symbol_exists("paca") &&
3ce5e9
 		   (get_symbol_type("paca", NULL, NULL) == TYPE_CODE_PTR)) {
3ce5e9
 		readmem(symbol_value("paca"), KVADDR, paca_ptr, sizeof(void *) * kt->cpus,
3ce5e9
-			"paca pointers", FAULT_ON_ERROR);
3ce5e9
+			"paca pointers", RETURN_ON_ERROR);
3ce5e9
 	} else {
3ce5e9
 		free(paca_ptr);
3ce5e9
 		return;
3ce5e9
@@ -1245,7 +1245,7 @@ ppc64_init_paca_info(void)
3ce5e9
 		for (i = 0; i < kt->cpus; i++)
3ce5e9
 			readmem(paca_ptr[i] + offset, KVADDR, &ms->emergency_sp[i],
3ce5e9
 				sizeof(void *), "paca->emergency_sp",
3ce5e9
-				FAULT_ON_ERROR);
3ce5e9
+				RETURN_ON_ERROR);
3ce5e9
 	}
3ce5e9
 
3ce5e9
 	if (MEMBER_EXISTS("paca_struct", "nmi_emergency_sp")) {
3ce5e9
@@ -1256,7 +1256,7 @@ ppc64_init_paca_info(void)
3ce5e9
 		for (i = 0; i < kt->cpus; i++)
3ce5e9
 			readmem(paca_ptr[i] + offset, KVADDR, &ms->nmi_emergency_sp[i],
3ce5e9
 				sizeof(void *), "paca->nmi_emergency_sp",
3ce5e9
-				FAULT_ON_ERROR);
3ce5e9
+				RETURN_ON_ERROR);
3ce5e9
 	}
3ce5e9
 
3ce5e9
 	if (MEMBER_EXISTS("paca_struct", "mc_emergency_sp")) {
3ce5e9
@@ -1267,7 +1267,7 @@ ppc64_init_paca_info(void)
3ce5e9
 		for (i = 0; i < kt->cpus; i++)
3ce5e9
 			readmem(paca_ptr[i] + offset, KVADDR, &ms->mc_emergency_sp[i],
3ce5e9
 				sizeof(void *), "paca->mc_emergency_sp",
3ce5e9
-				FAULT_ON_ERROR);
3ce5e9
+				RETURN_ON_ERROR);
3ce5e9
 	}
3ce5e9
 
3ce5e9
 	free(paca_ptr);
3ce5e9
@@ -1947,7 +1947,7 @@ ppc64_in_emergency_stack(int cpu, ulong addr, bool verbose)
3ce5e9
 	if (cpu < 0  || cpu >= kt->cpus)
3ce5e9
 		return NONE_STACK;
3ce5e9
 
3ce5e9
-	if (ms->emergency_sp) {
3ce5e9
+	if (ms->emergency_sp && IS_KVADDR(ms->emergency_sp[cpu])) {
3ce5e9
 		top = ms->emergency_sp[cpu];
3ce5e9
 		base =  top - STACKSIZE();
3ce5e9
 		if (addr >= base && addr < top) {
3ce5e9
@@ -1957,7 +1957,7 @@ ppc64_in_emergency_stack(int cpu, ulong addr, bool verbose)
3ce5e9
 		}
3ce5e9
 	}
3ce5e9
 
3ce5e9
-	if (ms->nmi_emergency_sp) {
3ce5e9
+	if (ms->nmi_emergency_sp && IS_KVADDR(ms->nmi_emergency_sp[cpu])) {
3ce5e9
 		top = ms->nmi_emergency_sp[cpu];
3ce5e9
 		base = top - STACKSIZE();
3ce5e9
 		if (addr >= base && addr < top) {
3ce5e9
@@ -1967,7 +1967,7 @@ ppc64_in_emergency_stack(int cpu, ulong addr, bool verbose)
3ce5e9
 		}
3ce5e9
 	}
3ce5e9
 
3ce5e9
-	if (ms->mc_emergency_sp) {
3ce5e9
+	if (ms->mc_emergency_sp && IS_KVADDR(ms->mc_emergency_sp[cpu])) {
3ce5e9
 		top = ms->mc_emergency_sp[cpu];
3ce5e9
 		base =  top - STACKSIZE();
3ce5e9
 		if (addr >= base && addr < top) {
3ce5e9
-- 
3ce5e9
2.37.1
3ce5e9