Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp759445pxk; Thu, 17 Sep 2020 15:49:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfn0StsYkaWL0IrmN1VWv6Aezfvkp6JW6WQ+dtZW8rqTL5oK4swUPbLMFFcquCqZSqdkWm X-Received: by 2002:aa7:df14:: with SMTP id c20mr35836789edy.334.1600382962665; Thu, 17 Sep 2020 15:49:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600382962; cv=none; d=google.com; s=arc-20160816; b=eDMOj2mt81nmn0JasE2yGdjrc3NV0L7PgDMPx5gv8lcFZMuXrxEM9GA8GjKoN42qDJ ltRfXw0DH2UH4XU/kxIeZsc3YSZqoFc1oKllOv+aJ+OkBuw3QrffyKc4pXhhoGDT/gHQ dx12W87gYf8hDyd1TaI6Mc2u+D7CCyT/iIRxwjk2e7lJQcWNR2LwOsc/2Iq9/OyGFgoM vnFMc8o7RYXaUhXDyf/jZyA9aKgNYIlE9gk1p8M4DN3U/hGqZqCspxt0QD0DTzY3qPU9 cw5DWsvdSdV7oqXHuF+ogt/GM29qlst72kt7LHLl9+kEvQhPIcBoseZu+YDqSiv8cB0f EdcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence: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=0cgTKdRfgvel3E3isXfbgnzZymV8vUL0uYVmnQDd4MM=; b=WKaKpCL/S4VlQ6DBuhE1qA4DxgUiCtGa5op1cjCxzTa9MYlE6fTZoqTxf2GnZJPRpG As1Xl2qpkIpg2c7UtUi1a5vRSm7mkYlZHxoDzxL6INEuPJv+e1ahVilZUwpt/G37+d12 pNEJlyVvfJJxrKWrrkTFDI1+ItGVuk/TN1ae4mEH076QPuc7i+K1ZFjnDV+NnI5SgrnV wL01hn/yPArVb0e1GvzeWf4kQmx6rOoWuDVbm29ALb2T39IyB/Y/5YHtlse92AWv4t9R gjPcmXpMkbz6KLVpg+ZIg4xRCeup255ebrRqI+t4rDE22dd/LBU0OtXH8n8bEuYr9ZR0 Ih1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=iuWrMmnd; 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 k25si937877ejq.407.2020.09.17.15.48.59; Thu, 17 Sep 2020 15:49:22 -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=iuWrMmnd; 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 S1726307AbgIQWr4 (ORCPT + 99 others); Thu, 17 Sep 2020 18:47:56 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:54153 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726156AbgIQWrw (ORCPT ); Thu, 17 Sep 2020 18:47:52 -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=1600382928; x=1631918928; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=442DvRpDFEIcCxIif/4Q8FsTmegEl5WBXsmfapV7ChU=; b=iuWrMmndE5OxB7LI0ELfCiF+rwLkjIovnZkOGfgg3Z+8qfi8uCXwQGJK dWqp9TWeGrhWXeHyv+h+UW5nfxKxn8FXuM+xSgzZ8hBN5J48VrrsJGy4Q ji9WsHTuPysCatFbJAdWsJkjaYvEdShh/wB13SrtUR4xxd5DVpbHg4N3B q/VfKXnCUJ5N9frpHsdUY3Udp8qzhglT54TZeQCx6h4UR0VjPFdth/pI+ W2OwUraEwXbnHeWg1mzfDcXG8CgC7vZ3ONjnzJ9hGsptOG2BjIbICX0Nr xFcvWMSq6oPLvplYyPyLcxLUwiFzY8mVUf4G8cB5aeL+h2RyB5vNkhIBU w==; IronPort-SDR: XIc4U+VPxayoruXZpi4OIDaXW6cW9/OYw1dgUDDdL33B5jN/ClF+WVtcog7JiGaBY2aoe11d86 n6/H1A4kZpmig7xNqIAiazbWx30uzA84f8SVeZURevdAMAcQDRq4svdW0MBdHesqwFh0Hy/ZFQ wE5LLryf8EJJjdTNQX7PpO5yCjB4+pIgwI0DWvM5r6Jt5PyDhyOd2i61oQwBeRf8SJx29bFFyx MJml77sCjyLUbHAieV8AMPmVsuLgVuszLG6LnkK2kxI3+MmGocfcG6j4tSHoDtK0GTv3hcU1rZ /V0= X-IronPort-AV: E=Sophos;i="5.77,272,1596470400"; d="scan'208";a="251021100" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 18 Sep 2020 06:38:03 +0800 IronPort-SDR: L0nhOalOtLtE1ngQNJH0wWxCFHbDmoW+7OVxEfjKVY1x7CXXosKdDH0eHhPWy+LJ7i5oJ3F+sa 4Zc42cRCxriQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Sep 2020 15:23:57 -0700 IronPort-SDR: wrXIzonbackQ6e9XZnFifGX9ISPiDEGGrJezt3qkhBAlbQc65qc4Oo3JxmZ3qiEUgdqG4lhSUU qiYx3gppgXVw== WDCIronportException: Internal Received: from use204338.ad.shared (HELO jedi-01.hgst.com) ([10.86.60.39]) by uls-op-cesaip02.wdc.com with ESMTP; 17 Sep 2020 15:37:43 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Palmer Dabbelt , Albert Ou , Alistair Francis , Andrew Morton , Anup Patel , Ard Biesheuvel , Arvind Sankar , Borislav Petkov , Greentime Hu , Heiko Carstens , Ingo Molnar , Kees Cook , linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org, Masahiro Yamada , Maxim Uvarov , Michal Simek , Mike Rapoport , Nick Desaulniers , Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Zong Li Subject: [PATCH v8 7/7] RISC-V: Add page table dump support for uefi Date: Thu, 17 Sep 2020 15:37:16 -0700 Message-Id: <20200917223716.2300238-8-atish.patra@wdc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200917223716.2300238-1-atish.patra@wdc.com> References: <20200917223716.2300238-1-atish.patra@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Palmer Dabbelt --- 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.25.1