From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96FE5C433E1 for ; Wed, 29 Jul 2020 23:37:25 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 65A662074B for ; Wed, 29 Jul 2020 23:37:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZyFzDOan"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="IuoozH1g" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65A662074B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SQjZF0VRVRZ3ulDQQODGthWgibnhPaxKC1Cal+eRKiM=; b=ZyFzDOan8D9DcKygHNhBqoU/4 Sys996xGB1FdkGUe0i3pham7X3ZPlNJEM8Kw1SnHWKGA0AfOOudmMc4srGLYnxTiBOS8xOduyA9kx /jxgJzy7Q5fNlbvW/T1falhcUBqq+oWztto0xWX6Z1q1USqg5mefa4fM8WH8LVZ0DAFbbi86mikM+ 7oc5bHIGFFJIub129KWmcn1jSNbrO+L/4Ac7bSO47nh2kcr3Ju57MqmqXmjYN4u8XAoN92taKzIvu 7Bx40W12zEgZLJmT9emdn5zQgm/BZ42MkJVzsdcCALKgTuvT2VdWSvTgAjTf4vhDfV+//LS1UtOzX hOlMG/wjw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0vdI-0004zF-UM; Wed, 29 Jul 2020 23:37:12 +0000 Received: from esa1.hgst.iphmx.com ([68.232.141.245]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0vdA-0004qb-NR for linux-riscv@lists.infradead.org; Wed, 29 Jul 2020 23:37:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1596065824; x=1627601824; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+GUmN6ZNbnCfom5PIzX3LeRfgAzIkaN7Tqfa0vPyyjQ=; b=IuoozH1gssYW92rBIz664SZj9irPnJxZuVilJJ/6aUCvKehQMvQncZOT 15P70iiO+VGnBKW2sYQ63ny/b2759+hW8VuLctW5K39qHqHWZSAL3KSxa kRV8vutXdbldP36ZXHd8XW4xAmCeM9SOP67203goEe9WwlOxLVrp8cGGl 2Pal0k97eOJmKZX3cghrsqb0+YMRt+UK6bAneI6D1vnyaYeBoYflYFE9/ Dm1Lb2xIbCCbluAeaH4zXt3zXLmlOACczxS0vToAodlgp884bbNxSD+3T VscyjSDBSVkXGWQ7fp5ej4G1yXyN2jiBA/c9+WnG5uZG8W57BlFZn4nT8 g==; IronPort-SDR: +hqDTThQ2OpPg6RWd6aa0fqwr8nM0wwbrRgEyQkjKIcrN0HAGHhpi+PTDI8qY9ivFO/IxFEKR6 ucqJo+BF0B7/arPoOCDoELr0L+Vn+5XY/yF3HfISC5E9kM+AouNTeUujPyI2wtJdirhD5Hz4s5 Td0HLwQ2qhqqYba1HgfBfiBlKv95TZXm+VXUWGGQLM7o/xP/0eYTEffmfZf06MbpxC1UlXMt5M QCHQps0AN3aZqf/je01kSiptE3z/sUy8e3TglFl+XlUQrYXSbL4mbLEIcMa/5IW3l7RpXoyEkq 3qY= X-IronPort-AV: E=Sophos;i="5.75,412,1589212800"; d="scan'208";a="253037270" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 30 Jul 2020 07:36:58 +0800 IronPort-SDR: oAQuTbkGCRvj/jA7+ZbBOj1cw3p6dPGyc+0hdkRKjUGN0Ht97F5YOjwMbHs07HpjUklbut1Eh8 u5kRsQ063dQlLuyzC6sQ9ReknBPDeIdQs= Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jul 2020 16:24:28 -0700 IronPort-SDR: oRu3jhyRAp3Dj6mouWcVjsE0ucflLYfALvrIxFoA6rnYtVsNahoUfJ32FT80J3fm4iHiwUDjKn Hiz/xaSry70Q== WDCIronportException: Internal Received: from jpf009043.ad.shared (HELO jedi-01.hgst.com) ([10.86.58.210]) by uls-op-cesaip01.wdc.com with ESMTP; 29 Jul 2020 16:36:59 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Subject: [RFT PATCH v4 9/9] RISC-V: Add page table dump support for uefi Date: Wed, 29 Jul 2020 16:36:35 -0700 Message-Id: <20200729233635.14406-10-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200729233635.14406-1-atish.patra@wdc.com> References: <20200729233635.14406-1-atish.patra@wdc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_193704_943216_E174ED95 X-CRM114-Status: GOOD ( 17.59 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-efi@vger.kernel.org, Thomas Gleixner , Kees Cook , Nick Hu , "Paul E. McKenney" , Masahiro Yamada , Anup Patel , Yash Shah , Ard Biesheuvel , Atish Patra , Arvind Sankar , Palmer Dabbelt , Zong Li , Paul Walmsley , Greentime Hu , linux-riscv@lists.infradead.org, Will Deacon , Ingo Molnar , Mike Rapoport Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.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 --- 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 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv