Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1577802ybh; Thu, 16 Jul 2020 16:42:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8B5SmdTttxz6dK0Meo1ILgwdjE2Guhfbu2+L/mLjPI0cw5ImqPhq+G4JvD+I2sWwetQTM X-Received: by 2002:a50:a451:: with SMTP id v17mr6418520edb.256.1594942940906; Thu, 16 Jul 2020 16:42:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594942940; cv=none; d=google.com; s=arc-20160816; b=jqkagKw36574/0rmZuoofnsZ9k9Yi36sH1mh6rwvfPqFWTHXC7x7mmTQsyekeeqT5j CuTjONTaxG5M2yGZfzncyS3DJvg9zbbOV255lbgDTpxZ9fy5b7cxhJT0qoTBbCL1HNNm Y2P+zqF+AQ1PFH2s6dEFGh8XfitUHp/Aziimf1+2oZF+8mwP4cB5OqKwWBMH1rY9Ruu+ Yng2MWL3i2L4n/HZoJ3CFuw8PaCkrx58yKeTlMlgkoAOKH33ZG469BiwxBJgsEPF9dGl U1vrOBp9giSNsYh4FThA29MZyWinZevh3XYCZEuIgH0SN47NgAM3IOG1Aay1cClcqRxQ ZkGg== 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=wS+KH6DS0BbZcXNOGvXmXLaf5sUs3GUHZACsRgR0AWc=; b=JAf3gdUBnVrDr7gICG70fgw1vL0T0MzBMxdpyYhR/nsWAIQzd+m0bLpUoFpqcN5pnm AeF/m2RiDnHrZg7WSOAOCbgytUqvDi4gnXg9eLYVQbNigi6ZBObLi3eSBB/fo4Mkx7+x H4O+c5WzHBLLewcp+qXX8uU8buNN+Du76gI/T/DFeU+ngvo/03oqBeyFekzUkoRORdYL UOFmOQ2aoSCZ4OYHF3D205xeFyLJwSUzkkf3SSwLojXVs2M6EyOmfJI/bpKXNm7zFJNt jiCqAwZBrS6sZX0M/+J+I4YHCApt67aXl19liP1iLP1Rksvxx3GsPTD3QSh9mKprmUJz t5UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=iaKiuBHO; 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 g22si4235888edm.294.2020.07.16.16.41.58; Thu, 16 Jul 2020 16:42:20 -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=iaKiuBHO; 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 S1726848AbgGPXle (ORCPT + 99 others); Thu, 16 Jul 2020 19:41:34 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:7125 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgGPXl2 (ORCPT ); Thu, 16 Jul 2020 19:41:28 -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=1594942887; x=1626478887; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+GUmN6ZNbnCfom5PIzX3LeRfgAzIkaN7Tqfa0vPyyjQ=; b=iaKiuBHORH7HSvx6drSIEOysxJab2DFI4PMCq8j5cbOlgWc0L7aKkRkW huG05ie6hMPalI/kHGSfts5LLeI4PnkQlcbme9ga83hLQNtANyRwCuw3n tSEHGWHTp74tBbLaOVW1SD+opF9b335RoDmMQOikKHq+Cqek8L2nKeZI+ E3a8ULw/vLsWhfmqcpFtZhFTki0E0tG0RvKxnArIA23sw3lbDhtsA2AGH YODGmJwxrc0J+Zta0Lv/cROTgO0hikwBHD16Sv2oJ9nhC5/xbedwBktpN 16ey5L3zKzRekXaXK23GXUSGRc8PZdBkOLr8a7Yg+hPDs9/U96eJutTlu A==; IronPort-SDR: OR+ttN/pi7wvpyn6PJCffXCruklEf4leftVs4JmpNvvebz0srXfohWXaQAmNhvaVtUyzOmuNwN XtvCzPdkGyG/uLLqxhudsP1AzFx4CBUhVEhDzSm9ID3k4NCmead6suh3M1E0hcTHCrIGZQNS4Z 3VGrSjBshorrYdHqFS5KMC7mlqHhAUffKQw3sIOICbDiCXbUD6apys5wPca6L0jIn5WTBM1hHY emEpgmoOGAeANaIDzZGk8oLqHn4ia4PVQk3XyvhTUDz3nhyqJQQq7OKynclUJvI4QNVNiZx1Wp HeQ= X-IronPort-AV: E=Sophos;i="5.75,360,1589212800"; d="scan'208";a="251923256" 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; 17 Jul 2020 07:41:27 +0800 IronPort-SDR: z33pVsdJtjTVuCGhuphFzW0oGSnpbKxaqBZPBGZILT1d6fevpX+UoQXSnLmowO3gtEYNgsrUrb Vq7Q6kvHjqUT39Y1t3MTuVVGxbDhUEWZE= Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jul 2020 16:29:51 -0700 IronPort-SDR: VCDmHz9Po+SyWMa2wkQ6fO1BA4c8cJ8S21BUcZ+C96V9L2BSJuvr7B+3fwjWpRBN+TU8iuP1OY xP/JAlmmqMqQ== WDCIronportException: Internal Received: from phd004806.ad.shared (HELO jedi-01.hgst.com) ([10.86.58.54]) by uls-op-cesaip02.wdc.com with ESMTP; 16 Jul 2020 16:41:25 -0700 From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Anup Patel , Ard Biesheuvel , Arnd Bergmann , Greentime Hu , Kees Cook , linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Masahiro Yamada , Mike Rapoport , Palmer Dabbelt , Paul Walmsley , Will Deacon , Zong Li , Heinrich Schuchardt , linux-arm-kernel@lists.infradead.org Subject: [RFT PATCH v3 9/9] RISC-V: Add page table dump support for uefi Date: Thu, 16 Jul 2020 16:41:04 -0700 Message-Id: <20200716234104.29049-10-atish.patra@wdc.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200716234104.29049-1-atish.patra@wdc.com> References: <20200716234104.29049-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 --- 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