2e409b
commit 7e3936895386ea6e85a6dc01bc5027f8133d12bb
2e409b
Author: Dave Anderson <anderson@redhat.com>
2e409b
Date:   Mon Sep 17 14:33:08 2018 -0400
2e409b
2e409b
    An addendum to crash commit 5fe78861ea1589084f6a2956a6ff63677c9269e1,
2e409b
    this patch for the PPC64 "bt" command prevents an invalid error
2e409b
    message from being displayed when an active non-panic task is
2e409b
    interrupted while running in user space.  Without the patch, the
2e409b
    command correctly indicates "Task is running in user space", dumps
2e409b
    the user-space exception frame, but then prints the invalid error
2e409b
    message "bt: invalid kernel virtual address: ffffffffffffff90 type:
2e409b
    Regs NIP value".
2e409b
    (anderson@redhat.com)
2e409b
2e409b
diff --git a/ppc64.c b/ppc64.c
2e409b
index 03fecd3..8badcde 100644
2e409b
--- a/ppc64.c
2e409b
+++ b/ppc64.c
2e409b
@@ -2254,6 +2254,7 @@ ppc64_vmcore_stack_frame(struct bt_info *bt_in, ulong *nip, ulong *ksp)
2e409b
 {
2e409b
 	struct ppc64_pt_regs *pt_regs;
2e409b
 	unsigned long unip;
2e409b
+	int in_user_space = FALSE;
2e409b
 
2e409b
 	pt_regs = (struct ppc64_pt_regs *)bt_in->machdep;
2e409b
 	if (!pt_regs || !pt_regs->gpr[1]) {
2e409b
@@ -2272,10 +2273,11 @@ ppc64_vmcore_stack_frame(struct bt_info *bt_in, ulong *nip, ulong *ksp)
2e409b
 			FAULT_ON_ERROR);
2e409b
 		*nip = unip;
2e409b
 	} else {
2e409b
-		if (IN_TASK_VMA(bt_in->task, *ksp))
2e409b
+		if (IN_TASK_VMA(bt_in->task, *ksp)) {
2e409b
 			fprintf(fp, "%0lx: Task is running in user space\n",
2e409b
 				bt_in->task);
2e409b
-		else
2e409b
+			in_user_space = TRUE;
2e409b
+		} else
2e409b
 			fprintf(fp, "%0lx: Invalid Stack Pointer %0lx\n",
2e409b
 				bt_in->task, *ksp);
2e409b
 		*nip = pt_regs->nip;
2e409b
@@ -2289,6 +2291,8 @@ ppc64_vmcore_stack_frame(struct bt_info *bt_in, ulong *nip, ulong *ksp)
2e409b
 	 * Print the collected regs for the active task
2e409b
 	 */
2e409b
 	ppc64_print_regs(pt_regs);
2e409b
+	if (in_user_space)
2e409b
+		return TRUE;
2e409b
 	if (!IS_KVADDR(*ksp))
2e409b
 		return FALSE;
2e409b