From: Kees Cook <keescook@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>,
Arjan van de Ven <arjan@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org
Subject: [PATCH] x86, kernel: make dump_pagetables a tristate
Date: Sat, 29 Jun 2013 21:05:15 -0700 [thread overview]
Message-ID: <20130630040514.GA20587@www.outflux.net> (raw)
Being able to examine page tables is handy, so make this a module that
can be loaded as needed.
Signed-off-by: Kees Cook <keescook@chromium.org>
---
arch/x86/Kconfig.debug | 2 +-
arch/x86/kernel/head.c | 6 ++++++
arch/x86/mm/dump_pagetables.c | 13 ++++++++++---
3 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index c198b7e..a43b7ca 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -70,7 +70,7 @@ config DEBUG_STACKOVERFLOW
If in doubt, say "N".
config X86_PTDUMP
- bool "Export kernel pagetable layout to userspace via debugfs"
+ tristate "Export kernel pagetable layout to userspace via debugfs"
depends on DEBUG_KERNEL
select DEBUG_FS
---help---
diff --git a/arch/x86/kernel/head.c b/arch/x86/kernel/head.c
index 992f442..871c0ca 100644
--- a/arch/x86/kernel/head.c
+++ b/arch/x86/kernel/head.c
@@ -69,3 +69,9 @@ void __init reserve_ebda_region(void)
/* reserve all memory between lowmem and the 1MB mark */
memblock_reserve(lowmem, 0x100000 - lowmem);
}
+
+#ifdef CONFIG_X86_64
+EXPORT_SYMBOL_GPL(init_level4_pgt);
+#else
+EXPORT_SYMBOL_GPL(swapper_pg_dir);
+#endif
diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c
index 0002a3a..7a54145 100644
--- a/arch/x86/mm/dump_pagetables.c
+++ b/arch/x86/mm/dump_pagetables.c
@@ -340,6 +340,8 @@ static int ptdump_open(struct inode *inode, struct file *filp)
return single_open(filp, ptdump_show, NULL);
}
+static struct dentry *pe;
+
static const struct file_operations ptdump_fops = {
.open = ptdump_open,
.read = seq_read,
@@ -347,9 +349,8 @@ static const struct file_operations ptdump_fops = {
.release = single_release,
};
-static int pt_dump_init(void)
+static int __init pt_dump_init(void)
{
- struct dentry *pe;
#ifdef CONFIG_X86_32
/* Not a compile-time constant on x86-32 */
@@ -369,7 +370,13 @@ static int pt_dump_init(void)
return 0;
}
-__initcall(pt_dump_init);
+static void __exit pt_dump_exit(void)
+{
+ debugfs_remove_recursive(pe);
+}
+
+module_init(pt_dump_init);
+module_exit(pt_dump_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Arjan van de Ven <arjan@linux.intel.com>");
MODULE_DESCRIPTION("Kernel debugging helper that dumps pagetables");
--
1.7.9.5
--
Kees Cook
Chrome OS Security
next reply other threads:[~2013-06-30 4:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-30 4:05 Kees Cook [this message]
2013-07-01 13:58 ` [PATCH] x86, kernel: make dump_pagetables a tristate Arjan van de Ven
2013-07-01 15:55 ` Kees Cook
2013-07-01 16:35 ` Arjan van de Ven
2013-07-01 16:56 ` Kees Cook
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=20130630040514.GA20587@www.outflux.net \
--to=keescook@chromium.org \
--cc=arjan@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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