Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp960521imm; Wed, 25 Jul 2018 09:02:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdQuz9HmGzBywqPViV3JQQwtpB4xgDyDfSEY0YkruPgz+jMBBQA4mghl/6L96gpsAV3NVpu X-Received: by 2002:a65:6110:: with SMTP id z16-v6mr21557116pgu.412.1532534572601; Wed, 25 Jul 2018 09:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532534572; cv=none; d=google.com; s=arc-20160816; b=tOhsryju9Ps7MfgJ7O68lkK+OdGoz7l5E0EujhAKtT17nM2UlVRv9EzT/hKWgEkxX4 0VzpSWrzHVLiGu47TLui6R/yBfu+FQ326TY8EA1E/hA4qzGMsGhrkZI/vGuUMwvneVkO jWlIgDR0Sv6CKwdtn9pD+XE9qFJCl2UE3OUUGLNntKzA4pUuaQDHj3RIo97T34SVrRUW aWL5WQUwyqoTSppukYuGk45ka2g3gKlFB7bt/O3HEVZkM/XRky4qoeeW3OjencZ5dJmJ qm9OD8K8wOBJ8OpFNs+/ceQXtU9UyltOFDyW0z68ZTfLE+afouF7vFAbdnllMoDgt9n1 QO2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-disposition:mime-version:user-agent:in-reply-to:references :subject:cc:to:from:message-id:date:arc-authentication-results; bh=pmRJLEeUnqwO2aUX7oCMJrgVm2FhUFEwtD/dXsdz7PE=; b=bt59Cv2ImRMdSaYWFcd85iZVv7ehTCPqllgmr4GdAbHMB/o0m1hP6jVoGjLrB7kWFF I4M8z3Vf+Oryo6pk6+usF2pyM44h783ByaIHqw/GcgO61YdQpDJu3Q39zidktHD4G8hi ffQoP8IRVnePLXlGptKmYpmtrM2BC+NP9u6zbGK4XzFp1Ayfq/vcMH+EwlK+jQ7g9Wpz 040jJpqKTVMeNhlLVz8cfyGHJD9TbrFQ/yY3nNWDu3l193S/IonZ5zCOeLDR5tI8cMPh OzzpehcM63lRFKLM3xLwAAIetJmE/hxW0Vh0lwFAUhbfDHV533Hh/NcmXSFB8eOUc3Fb NlXA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w9-v6si14761533pfg.234.2018.07.25.09.02.37; Wed, 25 Jul 2018 09:02:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729354AbeGYRNz convert rfc822-to-8bit (ORCPT + 99 others); Wed, 25 Jul 2018 13:13:55 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:57521 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728600AbeGYRNz (ORCPT ); Wed, 25 Jul 2018 13:13:55 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 41bKjD0bXcz9ttgH; Wed, 25 Jul 2018 18:01:36 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id JmzXKJiaOXmg; Wed, 25 Jul 2018 18:01:36 +0200 (CEST) Received: from vm-hermes.si.c-s.fr (vm-hermes.si.c-s.fr [192.168.25.253]) by pegase1.c-s.fr (Postfix) with ESMTP id 41bKjD01mtz9ttg8; Wed, 25 Jul 2018 18:01:36 +0200 (CEST) Received: by vm-hermes.si.c-s.fr (Postfix, from userid 33) id E71FBCAA; Wed, 25 Jul 2018 18:01:34 +0200 (CEST) Received: from 37.173.118.119 ([37.173.118.119]) by messagerie.si.c-s.fr (Horde Framework) with HTTP; Wed, 25 Jul 2018 18:01:34 +0200 Date: Wed, 25 Jul 2018 18:01:34 +0200 Message-ID: <20180725180134.Horde.BdhyE2b-TXhoVB7W8bsBhg1@messagerie.si.c-s.fr> From: LEROY Christophe To: Murilo Opsfelder Araujo Cc: linuxppc-dev@lists.ozlabs.org, "Tobin C . Harding" , Sukadev Bhattiprolu , Simon Guo , Paul Mackerras , Nicholas Piggin , Michael Neuling , Michael Ellerman , "Eric W . Biederman" , Cyril Bur , Benjamin Herrenschmidt , Balbir Singh , Andrew Donnellan , Alastair D'Silva , linux-kernel@vger.kernel.org Subject: Re: [PATCH 7/7] powerpc/traps: Show instructions on exceptions References: <20180724192720.32417-1-muriloo@linux.ibm.com> <20180724192720.32417-8-muriloo@linux.ibm.com> In-Reply-To: <20180724192720.32417-8-muriloo@linux.ibm.com> User-Agent: Internet Messaging Program (IMP) H5 (6.2.3) Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Murilo Opsfelder Araujo a écrit : > Move show_instructions() declaration to arch/powerpc/include/asm/stacktrace.h > and include asm/stracktrace.h in arch/powerpc/kernel/process.c, > which contains > the implementation. > > Modify show_instructions() not to call __kernel_text_address(), allowing > userspace instruction dump. probe_kernel_address(), which returns -EFAULT if > something goes wrong, is still being called. > > Call show_instructions() in arch/powerpc/kernel/traps.c to dump > instructions at > faulty location, useful to debugging. Shouldn't this part be in a second patch ? Wouldn't it be better to also see regs in addition if we want to use this to understand what happened ? So you could call show_regs() instead of show_instructions() ? Christophe > > Before this patch, an unhandled signal message looked like: > > Jul 24 09:57:00 localhost kernel: pandafault[10524]: segfault > (11) at 00000000100007d0 nip 000000001000061c lr 00007fffbd295100 > code 2 in pandafault[10000000+10000] > > After this patch, it looks like: > > Jul 24 09:57:00 localhost kernel: pandafault[10524]: segfault > (11) at 00000000100007d0 nip 000000001000061c lr 00007fffbd295100 > code 2 in pandafault[10000000+10000] > Jul 24 09:57:00 localhost kernel: Instruction dump: > Jul 24 09:57:00 localhost kernel: 4bfffeec 4bfffee8 3c401002 > 38427f00 fbe1fff8 f821ffc1 7c3f0b78 3d22fffe > Jul 24 09:57:00 localhost kernel: 392988d0 f93f0020 e93f0020 > 39400048 <99490000> 39200000 7d234b78 383f0040 > > Signed-off-by: Murilo Opsfelder Araujo > --- > arch/powerpc/include/asm/stacktrace.h | 7 +++++++ > arch/powerpc/kernel/process.c | 6 +++--- > arch/powerpc/kernel/traps.c | 3 +++ > 3 files changed, 13 insertions(+), 3 deletions(-) > create mode 100644 arch/powerpc/include/asm/stacktrace.h > > diff --git a/arch/powerpc/include/asm/stacktrace.h > b/arch/powerpc/include/asm/stacktrace.h > new file mode 100644 > index 000000000000..46e5ef451578 > --- /dev/null > +++ b/arch/powerpc/include/asm/stacktrace.h > @@ -0,0 +1,7 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#ifndef _ASM_POWERPC_STACKTRACE_H > +#define _ASM_POWERPC_STACKTRACE_H > + > +void show_instructions(struct pt_regs *regs); > + > +#endif /* _ASM_POWERPC_STACKTRACE_H */ > diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c > index b1af3390249c..ee1d63e03c52 100644 > --- a/arch/powerpc/kernel/process.c > +++ b/arch/powerpc/kernel/process.c > @@ -52,6 +52,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1261,7 +1262,7 @@ struct task_struct *__switch_to(struct > task_struct *prev, > > static int instructions_to_print = 16; > > -static void show_instructions(struct pt_regs *regs) > +void show_instructions(struct pt_regs *regs) > { > int i; > unsigned long pc = regs->nip - (instructions_to_print * 3 / 4 * > @@ -1283,8 +1284,7 @@ static void show_instructions(struct pt_regs *regs) > pc = (unsigned long)phys_to_virt(pc); > #endif > > - if (!__kernel_text_address(pc) || > - probe_kernel_address((unsigned int __user *)pc, instr)) { > + if (probe_kernel_address((unsigned int __user *)pc, instr)) { > pr_cont("XXXXXXXX "); > } else { > if (regs->nip == pc) > diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c > index e55ee639d010..3beca17ac1b1 100644 > --- a/arch/powerpc/kernel/traps.c > +++ b/arch/powerpc/kernel/traps.c > @@ -70,6 +70,7 @@ > #include > #include > #include > +#include > > #if defined(CONFIG_DEBUGGER) || defined(CONFIG_KEXEC_CORE) > int (*__debugger)(struct pt_regs *regs) __read_mostly; > @@ -357,6 +358,8 @@ static void show_signal_msg(int signr, struct > pt_regs *regs, int code, > print_vma_addr(KERN_CONT " in ", regs->nip); > > pr_cont("\n"); > + > + show_instructions(regs); > } > > void _exception_pkey(int signr, struct pt_regs *regs, int code, > -- > 2.17.1