From patchwork Fri May 13 12:56:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 67780 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp252929qge; Fri, 13 May 2016 05:58:06 -0700 (PDT) X-Received: by 10.66.176.103 with SMTP id ch7mr22792211pac.20.1463144286522; Fri, 13 May 2016 05:58:06 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id c125si24381276pfc.145.2016.05.13.05.58.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 May 2016 05:58:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b1Ce2-0006VY-IK; Fri, 13 May 2016 12:56:42 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1b1Cdy-0006TY-Ka for linux-arm-kernel@lists.infradead.org; Fri, 13 May 2016 12:56:39 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7480D3DB; Fri, 13 May 2016 05:56:31 -0700 (PDT) Received: from leverpostej (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 64C3C3F21A; Fri, 13 May 2016 05:56:16 -0700 (PDT) Date: Fri, 13 May 2016 13:56:07 +0100 From: Mark Rutland To: Will Deacon Subject: Re: [PATCH v2 4/6] arm64: mm: dump: make page table dumping reusable Message-ID: <20160513125606.GB4088@leverpostej> References: <1461343688-8552-1-git-send-email-ard.biesheuvel@linaro.org> <1461343688-8552-5-git-send-email-ard.biesheuvel@linaro.org> <20160425110757.GI16065@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160425110757.GI16065@arm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160513_055638_721844_784E01EA X-CRM114-Status: GOOD ( 26.22 ) X-Spam-Score: -8.3 (--------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-8.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-efi@vger.kernel.org, linux@arm.linux.org.uk, keescook@chromium.org, Ard Biesheuvel , catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org On Mon, Apr 25, 2016 at 12:07:57PM +0100, Will Deacon wrote: > Hi Ard, Mark, > > On Fri, Apr 22, 2016 at 06:48:06PM +0200, Ard Biesheuvel wrote: > > From: Mark Rutland > > > > For debugging purposes, it would be nice if we could export page tables > > other than the swapper_pg_dir to userspace. To enable this, this patch > > refactors the arm64 page table dumping code such that multiple tables > > may be registered with the framework, and exported under debugfs. > > > > Signed-off-by: Mark Rutland > > Signed-off-by: Ard Biesheuvel > > --- > > arch/arm64/include/asm/ptdump.h | 44 ++++++++++++++++++++ > > arch/arm64/mm/dump.c | 32 ++++++++------ > > 2 files changed, 64 insertions(+), 12 deletions(-) > > Could you reorder this with patch 3, please? I'm unsure about the benefit > of the very specific string literal changes, but the ptdump stuff here > certainly looks beneficial. I'm sure this is far too late, but for posterity I've rebased patch 4 below atop of pathes 1 & 2 as queued in the arm64 for-next/core branch, without patch 3. It builds cleanly, and I've given it a spin on Juno. Will, I guess I should rebase and resend this after we hit v4.7-rc1? Thanks, Mark. ---->8---- >From f17b52c0f004614027c356c848fd21308f4177c1 Mon Sep 17 00:00:00 2001 From: Mark Rutland Date: Fri, 22 Apr 2016 18:48:06 +0200 Subject: [PATCH] arm64: mm: dump: make page table dumping reusable For debugging purposes, it would be nice if we could export page tables other than the swapper_pg_dir to userspace. To enable this, this patch refactors the arm64 page table dumping code such that multiple tables may be registered with the framework, and exported under debugfs. Signed-off-by: Mark Rutland Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/ptdump.h | 44 +++++++++++++++++++++++++++++++++++++++++ arch/arm64/mm/dump.c | 32 +++++++++++++++++++----------- 2 files changed, 64 insertions(+), 12 deletions(-) create mode 100644 arch/arm64/include/asm/ptdump.h -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdump.h new file mode 100644 index 0000000..07b8ed0 --- /dev/null +++ b/arch/arm64/include/asm/ptdump.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2014 ARM Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef __ASM_PTDUMP_H +#define __ASM_PTDUMP_H + +#ifdef CONFIG_ARM64_PTDUMP + +#include + +struct addr_marker { + unsigned long start_address; + char *name; +}; + +struct ptdump_info { + struct mm_struct *mm; + const struct addr_marker *markers; + unsigned long base_addr; + unsigned long max_addr; +}; + +int ptdump_register(struct ptdump_info *info, const char *name); + +#else +static inline int ptdump_register(struct ptdump_info *info, const char *name) +{ + return 0; +} +#endif /* CONFIG_ARM64_PTDUMP */ + +#endif /* __ASM_PTDUMP_H */ diff --git a/arch/arm64/mm/dump.c b/arch/arm64/mm/dump.c index 8404190..a56a7ad 100644 --- a/arch/arm64/mm/dump.c +++ b/arch/arm64/mm/dump.c @@ -27,11 +27,7 @@ #include #include #include - -struct addr_marker { - unsigned long start_address; - const char *name; -}; +#include static const struct addr_marker address_markers[] = { #ifdef CONFIG_KASAN @@ -284,7 +280,8 @@ static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start) } } -static void walk_pgd(struct pg_state *st, struct mm_struct *mm, unsigned long start) +static void walk_pgd(struct pg_state *st, struct mm_struct *mm, + unsigned long start) { pgd_t *pgd = pgd_offset(mm, 0UL); unsigned i; @@ -303,12 +300,13 @@ static void walk_pgd(struct pg_state *st, struct mm_struct *mm, unsigned long st static int ptdump_show(struct seq_file *m, void *v) { + struct ptdump_info *info = m->private; struct pg_state st = { .seq = m, - .marker = address_markers, + .marker = info->markers, }; - walk_pgd(&st, &init_mm, VA_START); + walk_pgd(&st, info->mm, info->base_addr); note_page(&st, 0, 0, 0); return 0; @@ -316,7 +314,7 @@ static int ptdump_show(struct seq_file *m, void *v) static int ptdump_open(struct inode *inode, struct file *file) { - return single_open(file, ptdump_show, NULL); + return single_open(file, ptdump_show, inode->i_private); } static const struct file_operations ptdump_fops = { @@ -326,7 +324,7 @@ static const struct file_operations ptdump_fops = { .release = single_release, }; -static int ptdump_init(void) +int ptdump_register(struct ptdump_info *info, const char *name) { struct dentry *pe; unsigned i, j; @@ -336,8 +334,18 @@ static int ptdump_init(void) for (j = 0; j < pg_level[i].num; j++) pg_level[i].mask |= pg_level[i].bits[j].mask; - pe = debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, - &ptdump_fops); + pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops); return pe ? 0 : -ENOMEM; } + +static struct ptdump_info kernel_ptdump_info = { + .mm = &init_mm, + .markers = address_markers, + .base_addr = VA_START, +}; + +static int ptdump_init(void) +{ + return ptdump_register(&kernel_ptdump_info, "kernel_page_tables"); +} device_initcall(ptdump_init);