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

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