Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp299036imu; Fri, 16 Nov 2018 02:45:28 -0800 (PST) X-Google-Smtp-Source: AJdET5firt6+1RgaFbBRU3CeS9BKjAYYYDUVUTzkwyMx1ZhcuDgG2tyum71wBot4+yJ3uGelO7vt X-Received: by 2002:a63:cf56:: with SMTP id b22mr8983091pgj.336.1542365128625; Fri, 16 Nov 2018 02:45:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542365128; cv=none; d=google.com; s=arc-20160816; b=SmyCQkmjtlarN9T5Wbh3X88J4j+KUhfM8Us5awPvDRS1vkegELbTsDWZYFlAVGmJps 0sWBvZzWX6w4c0xoffGm0D1klvg5mD2jdaHlwPEO9tTZcNBvI7/PIsRysz+MY1n+mQR2 KZp4+de8XUwdzUElX1N6PzA8XdvmyEEUEEUHNu5+7J4LJAYT1AjA3+F6x0ol7BVhMWTK YrhNpoQuU8mw+G50L6bSU3U2aXO5PwueGHVe3re4aRXFmPrawlaAbzoYdckd4L4kRxHf EUjNZ/BG8hKaZSmvFZNc4Nva5uEtSSZrqy0zczFNN7k265BBU6814OSZu2bmfS+kmOw7 fOcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Xs7j+jEZ/YMIDKSKhe4O5rhf4z5DiAKqDjeji2PY/Fc=; b=LsNCzwcy4rMKfEZVihXVyDYQPN0rqotGQ2QWdYyQH4GSzPS5wdLG/j/ARYzpC7BnU7 LiKUZ99UPM3HwXMoXsYmqMv8zJEn6c2VeIgv8aF7wT8z+CydKmv3pZCEbZvagf2yfSZw mU1dFbMIeTALkobt5u+EUPlfpfWp/5bS3KLat6hv+BxgO+NeMo4FwaITB6+W5JlOVWX8 tiT/tiOZI5tzYUN5D5I7sD8XlPHlWYdMPf3ijjYNlivVp/Bp8X0jGUe1WGqF/b4fC9Bd QGiIgHbHi4tyznCPuruGtm83f8M19nLqZCHP4KJJZVZ2rq5+Ik+SfKGiBhNPkcC0hopD bLrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b=Btn2ISmj; 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 15-v6si32887801pfr.242.2018.11.16.02.45.14; Fri, 16 Nov 2018 02:45:28 -0800 (PST) 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=Btn2ISmj; 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 S2389551AbeKPU4W (ORCPT + 99 others); Fri, 16 Nov 2018 15:56:22 -0500 Received: from smtprelay4.synopsys.com ([198.182.47.9]:47758 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389532AbeKPU4V (ORCPT ); Fri, 16 Nov 2018 15:56:21 -0500 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 1189624E1146; Fri, 16 Nov 2018 02:44:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1542365075; bh=5pkZrd6kJ3caL9OXjHwvJuw9JnzWH4BYk+kQM13Wlb0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Btn2ISmjfQGzBPQDSgOWxYE7T8rsf67eVS0O8jWjQmHNRll9z5qsPsra5fTaYGJH3 R5flgujOx5wN/ZKUglexR7TcciSaRnoARmissbHC2neKHl/xUPz8pAwaP77GMGm6kN Aljk5kJv0jDqEgitu1aN8jeS/gbBHKrFzCXsxifiR8F4kElVwMiY7R6xdFV519aqjM eW5aaU7Sb35J8GMbjLThnurDpnxtJ6/W/18Ne0Xviuz0TfEmrUDdb6DK4maEO3h8dl /1xCAJO+gkRpb8tmH/8cvODKOaU3qPXpNfOkO0GvihQ1BgrLZGadZJyA94PdeHL8dl qh29SQv50L4zw== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.3.66]) by mailhost.synopsys.com (Postfix) with ESMTP id 7340A55A2; Fri, 16 Nov 2018 02:44:32 -0800 (PST) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org, Vineet Gupta Cc: linux-kernel@vger.kernel.org, Alexey Brodkin , Eugeniy Paltsev Subject: [PATCH 1/3] ARC: split show_faulting_vma for logic and representation parts Date: Fri, 16 Nov 2018 13:44:25 +0300 Message-Id: <20181116104427.25264-2-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20181116104427.25264-1-Eugeniy.Paltsev@synopsys.com> References: <20181116104427.25264-1-Eugeniy.Paltsev@synopsys.com> 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