Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ddb9bf8 authored by Laura Abbott's avatar Laura Abbott Committed by Catalin Marinas
Browse files

arm64: dump: Make ptdump debugfs a separate option



ptdump_register currently initializes a set of page table information and
registers debugfs. There are uses for the ptdump option without wanting the
debugfs options. Split this out to make it a separate option.

Reviewed-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
Tested-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarLaura Abbott <labbott@redhat.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 0bfc445d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2,9 +2,13 @@ menu "Kernel hacking"

source "lib/Kconfig.debug"

config ARM64_PTDUMP
config ARM64_PTDUMP_CORE
	def_bool n

config ARM64_PTDUMP_DEBUGFS
	bool "Export kernel pagetable layout to userspace via debugfs"
	depends on DEBUG_KERNEL
	select ARM64_PTDUMP_CORE
	select DEBUG_FS
        help
	  Say Y here if you want to show the kernel pagetable layout in a
+9 −6
Original line number Diff line number Diff line
@@ -16,9 +16,10 @@
#ifndef __ASM_PTDUMP_H
#define __ASM_PTDUMP_H

#ifdef CONFIG_ARM64_PTDUMP
#ifdef CONFIG_ARM64_PTDUMP_CORE

#include <linux/mm_types.h>
#include <linux/seq_file.h>

struct addr_marker {
	unsigned long start_address;
@@ -32,13 +33,15 @@ struct ptdump_info {
	unsigned long			max_addr;
};

int ptdump_register(struct ptdump_info *info, const char *name);

void ptdump_walk_pgd(struct seq_file *s, struct ptdump_info *info);
#ifdef CONFIG_ARM64_PTDUMP_DEBUGFS
int ptdump_debugfs_register(struct ptdump_info *info, const char *name);
#else
static inline int ptdump_register(struct ptdump_info *info, const char *name)
static inline int ptdump_debugfs_register(struct ptdump_info *info,
					const char *name)
{
	return 0;
}
#endif /* CONFIG_ARM64_PTDUMP */

#endif
#endif /* CONFIG_ARM64_PTDUMP_CORE */
#endif /* __ASM_PTDUMP_H */
+2 −1
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ obj-y := dma-mapping.o extable.o fault.o init.o \
				   ioremap.o mmap.o pgd.o mmu.o \
				   context.o proc.o pageattr.o
obj-$(CONFIG_HUGETLB_PAGE)	+= hugetlbpage.o
obj-$(CONFIG_ARM64_PTDUMP)	+= dump.o
obj-$(CONFIG_ARM64_PTDUMP_CORE)	+= dump.o
obj-$(CONFIG_ARM64_PTDUMP_DEBUGFS)	+= ptdump_debugfs.o
obj-$(CONFIG_NUMA)		+= numa.o

obj-$(CONFIG_KASAN)		+= kasan_init.o
+5 −21
Original line number Diff line number Diff line
@@ -304,9 +304,8 @@ static void walk_pgd(struct pg_state *st, struct mm_struct *mm,
	}
}

static int ptdump_show(struct seq_file *m, void *v)
void ptdump_walk_pgd(struct seq_file *m, struct ptdump_info *info)
{
	struct ptdump_info *info = m->private;
	struct pg_state st = {
		.seq = m,
		.marker = info->markers,
@@ -315,33 +314,16 @@ static int ptdump_show(struct seq_file *m, void *v)
	walk_pgd(&st, info->mm, info->base_addr);

	note_page(&st, 0, 0, 0);
	return 0;
}

static int ptdump_open(struct inode *inode, struct file *file)
static void ptdump_initialize(void)
{
	return single_open(file, ptdump_show, inode->i_private);
}

static const struct file_operations ptdump_fops = {
	.open		= ptdump_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

int ptdump_register(struct ptdump_info *info, const char *name)
{
	struct dentry *pe;
	unsigned i, j;

	for (i = 0; i < ARRAY_SIZE(pg_level); i++)
		if (pg_level[i].bits)
			for (j = 0; j < pg_level[i].num; j++)
				pg_level[i].mask |= pg_level[i].bits[j].mask;

	pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops);
	return pe ? 0 : -ENOMEM;
}

static struct ptdump_info kernel_ptdump_info = {
@@ -352,6 +334,8 @@ static struct ptdump_info kernel_ptdump_info = {

static int ptdump_init(void)
{
	return ptdump_register(&kernel_ptdump_info, "kernel_page_tables");
	ptdump_initialize();
	return ptdump_debugfs_register(&kernel_ptdump_info,
					"kernel_page_tables");
}
device_initcall(ptdump_init);
+31 −0
Original line number Diff line number Diff line
#include <linux/debugfs.h>
#include <linux/seq_file.h>

#include <asm/ptdump.h>

static int ptdump_show(struct seq_file *m, void *v)
{
	struct ptdump_info *info = m->private;
	ptdump_walk_pgd(m, info);
	return 0;
}

static int ptdump_open(struct inode *inode, struct file *file)
{
	return single_open(file, ptdump_show, inode->i_private);
}

static const struct file_operations ptdump_fops = {
	.open		= ptdump_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

int ptdump_debugfs_register(struct ptdump_info *info, const char *name)
{
	struct dentry *pe;
	pe = debugfs_create_file(name, 0400, NULL, info, &ptdump_fops);
	return pe ? 0 : -ENOMEM;

}
Loading