Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3647674imd; Mon, 29 Oct 2018 10:10:30 -0700 (PDT) X-Google-Smtp-Source: AJdET5eCqyEwUeGsfaksLfmN146FDW9a//QmpTx7UWXrR7efrTa0GadLAt5d23NqxLNhJrQsEvkM X-Received: by 2002:a17:902:15a8:: with SMTP id m37-v6mr15166994pla.256.1540833030103; Mon, 29 Oct 2018 10:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540833030; cv=none; d=google.com; s=arc-20160816; b=qV5K79+vM6g///qnnJd30MSXOka+NHSRClUZvKD6CROYkoIZTiGa4DQdrMFkDbevln 6pnLzPxBmd2b/Pk+rQlTLbxM4cUZMII5wG7JdtjIn1XPh6P5XK+jNm8w3ET6MhHELpVl 5hDInVF+NnS3WdVuLTW3u9HlNEHWjcGQq6BJWuVAdH5jUSsP+zDb10Mw4HiU+8e8ecr3 B0VFdbKTXYmAYvjlEczgMEtBgeFcF4I4k3xyIm7J6RoZFy1aW8tqBYr8rO1WsyAkEnus p5/n0C5N69qy/2rCmGAvLfCzfYO9er07Gw52UBMlDDxPkri38SNi8JRjbcTgQY/DOKBE /WiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=Xs7j+jEZ/YMIDKSKhe4O5rhf4z5DiAKqDjeji2PY/Fc=; b=xADImDXRwdQ2YHvrwwFxJUpZHhlyJ07fIFRedYPqiQNJKWc59ArKMbT/xnG19Q0tYY n3/NCwduw4m1CNIiV7YCYXF7K7upC61XfdTCMlCGAxJu/Coti9TGPPZlNLnUiNTqVeyu 4vgKoDkqy+SVmbah0czJbCHpS0lkPWOGd5Nk7IqJcZzoJI3MZ9JaAVgNOH2hqt/eJIFZ NmRy2awk0xS7nBswl2Vz8eflRGbeVnHz3v9Mxu0kZ6+WzBJKfclB2MikuudEHDahl8D8 68OqZljPBOqf34Tpyq0otjiE4zCSflxBQJkf9jKs1LC8cVqw72V3jTZIb+5MyA9vnsay 8OeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=Q5TgxY+m; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i32-v6si5556986pgb.564.2018.10.29.10.10.14; Mon, 29 Oct 2018 10:10:30 -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; dkim=pass header.i=@synopsys.com header.s=mail header.b=Q5TgxY+m; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbeJ3B7R (ORCPT + 99 others); Mon, 29 Oct 2018 21:59:17 -0400 Received: from smtprelay.synopsys.com ([198.182.60.111]:52794 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbeJ3B7Q (ORCPT ); Mon, 29 Oct 2018 21:59:16 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0F3AE10C031B; Mon, 29 Oct 2018 10:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1540832988; bh=5pkZrd6kJ3caL9OXjHwvJuw9JnzWH4BYk+kQM13Wlb0=; h=From:To:Cc:Subject:Date:From; b=Q5TgxY+mEKKWi9k2QyyqECOTAhl/ZJj5UZTeZA/3Lo9YKaK3MQH5ny3is9XPJ5Gfq gTnZ92SOn9vcfkrN9Z2W2R6up9XisgcbmGUIeBHoG1V39c7NHsnF2EewRB1kZLTm3D nUN7R7FcT71ayG3ALS9dJNpcUyAachbcG8tUSP0xpmyFkZLgLDLY7TbFKNRJYbbyNM Uxswx55TNSzqZt0aFdqfV1leRJA8KA2ihO3KJV0qWEBAnHgB4HKtHU4wWcDwPhtbYU SIi7nFVKSBOw3Tzsc3lM50Rilt8aV0/G6/9K6MfdxNvvx90kdhsUDHFq4uBDuAeDEs hKzQFHCqCHlzg== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.3.38]) by mailhost.synopsys.com (Postfix) with ESMTP id 59DF8363F; Mon, 29 Oct 2018 10:09:46 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Cc: linux-kernel@vger.kernel.org, Alexey Brodkin , Eugeniy Paltsev Subject: [RFC v2 1/2] ARC: split show_faulting_vma for logic and representation parts Date: Mon, 29 Oct 2018 20:09:40 +0300 Message-Id: <20181029170941.13811-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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