Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1359563pxa; Fri, 28 Aug 2020 10:25:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRhiKsbs2ADcmxQ8Fh6fVrw6xWuZMWFeEdqszTFlFQy7rg+u65lsuYY2i94GDVzHPn50di X-Received: by 2002:a05:6402:743:: with SMTP id p3mr2952747edy.19.1598635535061; Fri, 28 Aug 2020 10:25:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598635535; cv=none; d=google.com; s=arc-20160816; b=VJ6MxbjbFWYP/jQ8QdJPgirDXF7QocRIf3yK+YDPtM9lAuk3o2ycSrp4wwY4yST5FD wc5YJAFJwxiKHmF0kZYIIM6nnI4k1FIgp0KtyPoBydLB9LNDimDmT2Y9xuWbJGGdyBtu 2hmqVZ1w2nwrob2T4nlSLG4coJ5bCKrpdm3VlilqU7pJEZaGc1Pllp51jObz6xAHWO3F cOykKZzqxQBZy/qeHsaI91w07rzOOhDqKP/PzH3QMR3VZWkNa4AWZ/Q+Xb6kG5ivPAX7 FJHv6q1zzZaiUOBknbzN62boecPvGgXzc8HHEDgufz/FOlM+Wqe0yaZtBvIAUNtCJYfI 7ZWg== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :wdcironportexception:ironport-sdr:ironport-sdr:ironport-sdr :dkim-signature; bh=qLPz69kOin62E1Icdynwwi25th+NZesqTt+XE9T8U7Q=; b=Rcnn+E3HHBSEk+3s4ANcOzNTSfdVQ8SSjcLx5699UOFV4FoLqbkJrbOXGY5hPVKb29 4sLiuTfzoSNSS072stFDKNkWYiHA77Ap/pTkgdG3pAHWhj73EGaf6yeu+1flD15Vq9/J t+QyhvlXeBrIcArfQZ1VFe4+tnWGBqd/prpUM0pVdAZkwIKKG4sSz6/nf3xSwA0SRGpj 4uwGHJjrfG5bwUrUpOYotnxah3SoQVSiRsIFzvguGAyr3GvKjJ61Zis1shiTikbtZTdf lIifykNdZAtPyUsqHJ8NM5VR60N3rD5ITzcQjHsvcWdjycDPXSQ71uWoyCEJ5UAcCoie 6pFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="q/Cz+0+D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i7si101384ejo.230.2020.08.28.10.25.10; Fri, 28 Aug 2020 10:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="q/Cz+0+D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727924AbgH1RWA (ORCPT + 99 others); Fri, 28 Aug 2020 13:22:00 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:11687 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727101AbgH1RVW (ORCPT ); Fri, 28 Aug 2020 13:21:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1598635281; x=1630171281; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zACmpNxMVkpKW6XFtwU9imKwJIzxQN1bq0wJXy/9ILY=; b=q/Cz+0+DeXs2uSHZJz9DzQFIHJ4IJNeCvNzhOsodlEY3/RaWQdMm/R8G vwPTSiKt7uacfmZT3x+2kw6PLAR1He+7bpe6xrCaCSic5pvEYaMNaL7eL G+LXT9z0OuF2rUc5qLwVlUy4f8E4gaxXr9eeKrdHXOTkH5Qw/BCisNKbA ba6hv5sfpI3Efo5xoIYIS1IHuCkyIohpncYmwaYcAzeCBdYqpH5ylNHqR lmqK8b3ZgNZpPnm+afnfEsHjyWcjmt9rjXzXOJviGwPSjpbFtCEreS3Dv IOjp+ZKLqR5p9fv724RYpFp7xoZpKoCxMII8XW2hjGiKkKlkUit1B5i/V Q==; IronPort-SDR: GjdafDz1RsK3ErUOQg4g2LQrrfuSwM2ry0RQSDy7tKBH2nSZKL3ugktRdkx5WFRRLQqeqokxuf qOLv7sG1FE2AT70HqLAfH2RHu7l4N5kkZuDAc8t8XL2XPjlDO99R+qJCe3GYtn3lVbXG2uBRqv 9ZMXc16SgqKJHMnwifZslcwE+6HJ+Q6+R8mpuMGsU8Y72hzgjRinajmsyMtQb2R24cmGV9Te+p c6NUcA+cuP7tU4bqZJk6bnT64LXJqA4DBuMcwEDGR0fYHsFSKHNhZAotZxPExDF93aNFzouo3J txo= X-IronPort-AV: E=Sophos;i="5.76,364,1592841600"; d="scan'208";a="146018528" Received: from h199-255-45-14.hgst.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 29 Aug 2020 01:20:48 +0800 IronPort-SDR: 1mzc4SjoNpnp2xcLvvisjDPS4Gfos9mxE7wXUJltwDyvXHr8RvZYjzilA6FJBGnBVmX2ZbXZQq r7Fa3RqhY9Ig== Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2020 10:08:20 -0700 IronPort-SDR: l258ELJoT28WLwZNYHFmJmSjuwFsyOrEsXSTZpwi5VfI7uzXgWZriyWxxOHaE3STpkfikRXKrQ moCtEqf0bz5Q== WDCIronportException: Internal Received: from 6hj08h2.ad.shared (HELO jedi-01.hgst.com) ([10.86.59.137]) by uls-op-cesaip01.wdc.com with ESMTP; 28 Aug 2020 10:20:47 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Alistair Francis , Anup Patel , Ard Biesheuvel , Arvind Sankar , Greentime Hu , Ingo Molnar , linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org, Masahiro Yamada , Mike Rapoport , Nick Desaulniers , Palmer Dabbelt , Paul Walmsley Subject: [PATCH v7 9/9] RISC-V: Add page table dump support for uefi Date: Fri, 28 Aug 2020 10:20:36 -0700 Message-Id: <20200828172036.8056-10-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200828172036.8056-1-atish.patra@wdc.com> References: <20200828172036.8056-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend the current page table dump support in RISC-V to include efi pages as well. Here is the output of efi runtime page table mappings. ---[ UEFI runtime start ]--- 0x0000000020002000-0x0000000020003000 0x00000000be732000 4K PTE D A . . . W R V 0x0000000020018000-0x0000000020019000 0x00000000be738000 4K PTE D A . . . W R V 0x000000002002c000-0x000000002002d000 0x00000000be73c000 4K PTE D A . . . W R V 0x0000000020031000-0x0000000020032000 0x00000000bff61000 4K PTE D A . . X W R V ---[ UEFI runtime end ]--- Signed-off-by: Atish Patra Reviewed-by: Anup Patel --- arch/riscv/mm/ptdump.c | 48 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index 0831c2e61a8f..ace74dec7492 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -3,6 +3,7 @@ * Copyright (C) 2019 SiFive */ +#include #include #include #include @@ -49,6 +50,14 @@ struct addr_marker { const char *name; }; +/* Private information for debugfs */ +struct ptd_mm_info { + struct mm_struct *mm; + const struct addr_marker *markers; + unsigned long base_addr; + unsigned long end; +}; + static struct addr_marker address_markers[] = { #ifdef CONFIG_KASAN {KASAN_SHADOW_START, "Kasan shadow start"}, @@ -68,6 +77,28 @@ static struct addr_marker address_markers[] = { {-1, NULL}, }; +static struct ptd_mm_info kernel_ptd_info = { + .mm = &init_mm, + .markers = address_markers, + .base_addr = KERN_VIRT_START, + .end = ULONG_MAX, +}; + +#ifdef CONFIG_EFI +static struct addr_marker efi_addr_markers[] = { + { 0, "UEFI runtime start" }, + { SZ_1G, "UEFI runtime end" }, + { -1, NULL } +}; + +static struct ptd_mm_info efi_ptd_info = { + .mm = &efi_mm, + .markers = efi_addr_markers, + .base_addr = 0, + .end = SZ_2G, +}; +#endif + /* Page Table Entry */ struct prot_bits { u64 mask; @@ -245,22 +276,22 @@ static void note_page(struct ptdump_state *pt_st, unsigned long addr, } } -static void ptdump_walk(struct seq_file *s) +static void ptdump_walk(struct seq_file *s, struct ptd_mm_info *pinfo) { struct pg_state st = { .seq = s, - .marker = address_markers, + .marker = pinfo->markers, .level = -1, .ptdump = { .note_page = note_page, .range = (struct ptdump_range[]) { - {KERN_VIRT_START, ULONG_MAX}, + {pinfo->base_addr, pinfo->end}, {0, 0} } } }; - ptdump_walk_pgd(&st.ptdump, &init_mm, NULL); + ptdump_walk_pgd(&st.ptdump, pinfo->mm, NULL); } void ptdump_check_wx(void) @@ -293,7 +324,7 @@ void ptdump_check_wx(void) static int ptdump_show(struct seq_file *m, void *v) { - ptdump_walk(m); + ptdump_walk(m, m->private); return 0; } @@ -308,8 +339,13 @@ static int ptdump_init(void) for (j = 0; j < ARRAY_SIZE(pte_bits); j++) pg_level[i].mask |= pte_bits[j].mask; - debugfs_create_file("kernel_page_tables", 0400, NULL, NULL, + debugfs_create_file("kernel_page_tables", 0400, NULL, &kernel_ptd_info, &ptdump_fops); +#ifdef CONFIG_EFI + if (efi_enabled(EFI_RUNTIME_SERVICES)) + debugfs_create_file("efi_page_tables", 0400, NULL, &efi_ptd_info, + &ptdump_fops); +#endif return 0; } -- 2.24.0