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