From: Sebastian Ene <sebastianene@google.com>
To: linux-kernel@vger.kernel.org
Cc: kernel-team@android.com, will@kernel.org, ryan.roberts@arm.com,
mark.rutland@arm.com, maz@kernel.org, vdonnefort@google.com,
Sebastian Ene <sebastianene@google.com>
Subject: [PATCH 06/11] arm64: ptdump: Register a debugfs entry for the host stage-2 page-tables
Date: Wed, 27 Sep 2023 11:25:12 +0000 [thread overview]
Message-ID: <20230927112517.2631674-7-sebastianene@google.com> (raw)
In-Reply-To: <20230927112517.2631674-1-sebastianene@google.com>
Initialize the structures used to keep the state of the stage-2 ptdump
walker. To satisfy the ptdump API for parsing no VMA regions, initialize
a memory structure. Since we are going to parse a snapshot of the host
stage-2 paget-tables we don't rely on the locking from the memory
structure.
Signed-off-by: Sebastian Ene <sebastianene@google.com>
---
arch/arm64/kvm/Kconfig | 12 ++++++++++++
arch/arm64/mm/ptdump.c | 26 ++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/arch/arm64/kvm/Kconfig b/arch/arm64/kvm/Kconfig
index 83c1e09be42e..2974bb5c4838 100644
--- a/arch/arm64/kvm/Kconfig
+++ b/arch/arm64/kvm/Kconfig
@@ -71,4 +71,16 @@ config PROTECTED_NVHE_STACKTRACE
If unsure, or not using protected nVHE (pKVM), say N.
+config NVHE_EL2_PTDUMP_DEBUGFS
+ bool "Present the stage-2 pagetables to debugfs"
+ depends on NVHE_EL2_DEBUG && PTDUMP_DEBUGFS
+ help
+ Say Y here if you want to show the pKVM host stage-2 kernel pagetable
+ layout in a debugfs file. This information is only useful for kernel developers
+ who are working in architecture specific areas of the kernel.
+ It is probably not a good idea to enable this feature in a production
+ kernel.
+
+ If in doubt, say N.
+
endif # VIRTUALIZATION
diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c
index 8c4f06ca622a..25c0640e82aa 100644
--- a/arch/arm64/mm/ptdump.c
+++ b/arch/arm64/mm/ptdump.c
@@ -469,6 +469,21 @@ void ptdump_check_wx(void)
pr_info("Checked W+X mappings: passed, no W+X pages found\n");
}
+#ifdef CONFIG_NVHE_EL2_PTDUMP_DEBUGFS
+static struct ptdump_info stage2_kernel_ptdump_info;
+static struct addr_marker ipa_address_markers[] = {
+ { 0, "IPA start"},
+ { -1, "IPA end"},
+ { -1, NULL},
+};
+
+/* Initialize a memory structure used by ptdump to walk the no-VMA region */
+static struct mm_struct ipa_init_mm = {
+ .mm_mt = MTREE_INIT_EXT(mm_mt, MM_MT_FLAGS,
+ ipa_init_mm.mmap_lock),
+};
+#endif /* CONFIG_NVHE_EL2_PTDUMP_DEBUGFS */
+
static int __init ptdump_init(void)
{
address_markers[PAGE_END_NR].start_address = PAGE_END;
@@ -477,6 +492,17 @@ static int __init ptdump_init(void)
#endif
ptdump_initialize();
ptdump_debugfs_register(&kernel_ptdump_info, "kernel_page_tables");
+
+#ifdef CONFIG_NVHE_EL2_PTDUMP_DEBUGFS
+ stage2_kernel_ptdump_info = (struct ptdump_info) {
+ .markers = ipa_address_markers,
+ .mm = &ipa_init_mm,
+ };
+
+ init_rwsem(&ipa_init_mm.mmap_lock);
+ ptdump_debugfs_register(&stage2_kernel_ptdump_info,
+ "host_stage2_kernel_page_tables");
+#endif
return 0;
}
device_initcall(ptdump_init);
--
2.42.0.515.g380fc7ccd1-goog
next prev parent reply other threads:[~2023-09-27 11:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 11:25 [PATCH 00/11] arm64: ptdump: View " Sebastian Ene
2023-09-27 11:25 ` [PATCH 01/11] KVM: arm64: Add snap shooting the host stage-2 pagetables Sebastian Ene
2023-09-28 18:33 ` kernel test robot
2023-09-27 11:25 ` [PATCH 02/11] arm64: ptdump: Use the mask from the state structure Sebastian Ene
2023-09-27 11:25 ` [PATCH 03/11] arm64: ptdump: Add the walker function to the ptdump info structure Sebastian Ene
2023-09-27 11:25 ` [PATCH 04/11] KVM: arm64: Move pagetable definitions to common header Sebastian Ene
2023-09-27 11:25 ` [PATCH 05/11] arm64: ptdump: Introduce stage-2 pagetables format description Sebastian Ene
2023-09-27 11:25 ` Sebastian Ene [this message]
2023-09-27 11:25 ` [PATCH 07/11] arm64: ptdump: Snapshot the host stage-2 pagetables Sebastian Ene
2023-09-27 11:25 ` [PATCH 08/11] arm64: ptdump: Parse the host stage-2 page-tables from the snapshot Sebastian Ene
2023-09-27 11:25 ` [PATCH 09/11] arm64: ptdump: Interpret memory attributes based on runtime configuration Sebastian Ene
2023-09-27 11:25 ` [PATCH 10/11] arm64: ptdump: Interpret pKVM ownership annotations Sebastian Ene
2023-09-27 11:25 ` [PATCH 11/11] arm64: ptdump: Fix format output during stage-2 pagetable dumping Sebastian Ene
2023-09-29 13:11 ` [PATCH 00/11] arm64: ptdump: View the host stage-2 page-tables Marc Zyngier
2023-09-30 16:31 ` Sebastian Ene
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230927112517.2631674-7-sebastianene@google.com \
--to=sebastianene@google.com \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=ryan.roberts@arm.com \
--cc=vdonnefort@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®