linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
To: linux-snps-arc@lists.infradead.org,
	Vineet Gupta <vineet.gupta1@synopsys.com>
Cc: linux-kernel@vger.kernel.org,
	Alexey Brodkin <alexey.brodkin@synopsys.com>,
	Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Subject: [PATCH 1/3] ARC: split show_faulting_vma for logic and representation parts
Date: Fri, 16 Nov 2018 13:44:25 +0300	[thread overview]
Message-ID: <20181116104427.25264-2-Eugeniy.Paltsev@synopsys.com> (raw)
In-Reply-To: <20181116104427.25264-1-Eugeniy.Paltsev@synopsys.com>

In preparation for introduncing SmaRT support for ARC split
show_faulting_vma() for logic and representation parts to be
able to use logic part in SmaRT code.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
---
 arch/arc/include/asm/bug.h     |  9 +++++++++
 arch/arc/kernel/troubleshoot.c | 43 ++++++++++++++++++++++++++++++------------
 2 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/arch/arc/include/asm/bug.h b/arch/arc/include/asm/bug.h
index b68f7f82f2d8..064391646d38 100644
--- a/arch/arc/include/asm/bug.h
+++ b/arch/arc/include/asm/bug.h
@@ -15,6 +15,15 @@
 
 struct task_struct;
 
+struct faulting_vma_info {
+	char *file_path;
+	unsigned long offset;
+	unsigned long vm_start;
+	unsigned long vm_end;
+};
+
+int get_faulting_vma_info(unsigned long address, char *buf, int buflen,
+			  struct faulting_vma_info *fvma);
 void show_regs(struct pt_regs *regs);
 void show_exception_mesg(struct pt_regs *regs);
 void show_stacktrace(struct task_struct *tsk, struct pt_regs *regs);
diff --git a/arch/arc/kernel/troubleshoot.c b/arch/arc/kernel/troubleshoot.c
index fdfba1942a06..00efcdfde0ee 100644
--- a/arch/arc/kernel/troubleshoot.c
+++ b/arch/arc/kernel/troubleshoot.c
@@ -80,11 +80,14 @@ static void print_task_path_n_nm(struct task_struct *tsk, char *buf)
 	pr_info("Path: %s\n", !IS_ERR(path_nm) ? path_nm : "?");
 }
 
-static void show_faulting_vma(unsigned long address, char *buf)
+int get_faulting_vma_info(unsigned long address, char *buf, int buflen,
+			  struct faulting_vma_info *fvma)
 {
 	struct vm_area_struct *vma;
-	char *nm = buf;
 	struct mm_struct *active_mm = current->active_mm;
+	int ret = -ENOENT;
+
+	fvma->file_path = "?";
 
 	/* can't use print_vma_addr() yet as it doesn't check for
 	 * non-inclusive vma
@@ -97,19 +100,35 @@ static void show_faulting_vma(unsigned long address, char *buf)
 	 */
 	if (vma && (vma->vm_start <= address)) {
 		if (vma->vm_file) {
-			nm = file_path(vma->vm_file, buf, PAGE_SIZE - 1);
-			if (IS_ERR(nm))
-				nm = "?";
+			fvma->file_path = file_path(vma->vm_file, buf, buflen);
+			if (IS_ERR(fvma->file_path))
+				fvma->file_path = "?";
 		}
 
-		pr_cont("[off 0x%lx in %s, VMA: %08lx:%08lx] ",
-			vma->vm_start < TASK_UNMAPPED_BASE ?
-				address : address - vma->vm_start,
-			nm, vma->vm_start, vma->vm_end);
-	} else
-		pr_cont("[No matching VMA found] ");
+		fvma->vm_start = vma->vm_start;
+		fvma->vm_end = vma->vm_end;
+		fvma->offset = vma->vm_start < TASK_UNMAPPED_BASE ?
+				address : address - vma->vm_start;
+
+		ret = 0;
+	}
 
 	up_read(&active_mm->mmap_sem);
+
+	return ret;
+}
+
+static void show_faulting_vma(unsigned long address, char *buf, int buflen)
+{
+	struct faulting_vma_info fvma;
+	int ret;
+
+	ret = get_faulting_vma_info(address, buf, buflen, &fvma);
+	if (ret)
+		pr_cont("[No matching VMA found] ");
+	else
+		pr_cont("[off 0x%lx in %s, VMA: %08lx:%08lx] ", fvma.offset,
+			fvma.file_path, fvma.vm_start, fvma.vm_end);
 }
 
 static void show_ecr_verbose(struct pt_regs *regs)
@@ -175,7 +194,7 @@ static inline void show_exception_mesg_u(struct pt_regs *regs)
 
 	buf = (char *)__get_free_page(GFP_NOWAIT);
 	if (buf) {
-		show_faulting_vma(regs->ret, buf);
+		show_faulting_vma(regs->ret, buf, PAGE_SIZE - 1);
 		free_page((unsigned long)buf);
 	}
 
-- 
2.14.5


  reply	other threads:[~2018-11-16 10:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16 10:44 [PATCH 0/3] ARC: ARCv2: Introduce SmaRT support Eugeniy Paltsev
2018-11-16 10:44 ` Eugeniy Paltsev [this message]
2018-11-16 10:44 ` [PATCH 2/3] " Eugeniy Paltsev
2018-11-16 10:44 ` [PATCH 3/3] ARC: show detaled SmaRT configuration in mumbojumbo Eugeniy Paltsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181116104427.25264-2-Eugeniy.Paltsev@synopsys.com \
    --to=eugeniy.paltsev@synopsys.com \
    --cc=alexey.brodkin@synopsys.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=vineet.gupta1@synopsys.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).