// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 * Debug helper to dump the current kernel pagetables of the system
 * so that we can see what the various memory ranges are set to.
 *
 * Derived from x86 and arm implementation:
 * (C) Copyright 2008 Intel Corporation
 *
 * Author: Arjan van de Ven <arjan@linux.intel.com>
 */
#include <linux/debugfs.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/io.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/ptdump.h>
#include <linux/sched.h>
#include <linux/seq_file.h>

#include <asm/fixmap.h>
#include <asm/kasan.h>
#include <asm/memory.h>
#include <asm/pgtable-hwdef.h>
#include <asm/ptdump.h>
#include <asm/kvm_pkvm.h>
#include <asm/kvm_pgtable.h>


enum address_markers_idx {
	PAGE_OFFSET_NR = 0,
	PAGE_END_NR,
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
	KASAN_START_NR,
#endif
};

static struct addr_marker address_markers[] = {
	{ PAGE_OFFSET,			"Linear Mapping start" },
	{ 0 /* PAGE_END */,		"Linear Mapping end" },
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
	{ 0 /* KASAN_SHADOW_START */,	"Kasan shadow start" },
	{ KASAN_SHADOW_END,		"Kasan shadow end" },
#endif
	{ MODULES_VADDR,		"Modules start" },
	{ MODULES_END,			"Modules end" },
	{ VMALLOC_START,		"vmalloc() area" },
	{ VMALLOC_END,			"vmalloc() end" },
	{ FIXADDR_TOT_START,		"Fixmap start" },
	{ FIXADDR_TOP,			"Fixmap end" },
	{ PCI_IO_START,			"PCI I/O start" },
	{ PCI_IO_END,			"PCI I/O end" },
	{ VMEMMAP_START,		"vmemmap start" },
	{ VMEMMAP_START + VMEMMAP_SIZE,	"vmemmap end" },
	{ -1,				NULL },
};

#define pt_dump_seq_printf(m, fmt, args...)	\
({						\
	if (m)					\
		seq_printf(m, fmt, ##args);	\
})

#define pt_dump_seq_puts(m, fmt)	\
({					\
	if (m)				\
		seq_printf(m, fmt);	\
})

/*
 * The page dumper groups page table entries of the same type into a single
 * description. It uses pg_state to track the range information while
 * iterating over the pte entries. When the continuity is broken it then
 * dumps out a description of the range.
 */
struct pg_state {
	struct ptdump_state ptdump;
	struct seq_file *seq;
	struct pg_level *pg_level;
	const struct addr_marker *marker;
	unsigned long start_address;
	int level;
	u64 current_prot;
	bool check_wx;
	unsigned long wx_pages;
	unsigned long uxn_pages;
	struct ptdump_info *info;
};

/*
 * This callback checks the runtime configuration before interpreting the
 * attributes defined in the prot_bits.
 */
typedef bool (*is_feature_cb)(const void *ctx);

struct prot_bits {
	u64		mask;
	u64		val;
	const char	*set;
	const char	*clear;
	is_feature_cb   feature_on;  /* bit ignored if the callback returns false */
	is_feature_cb   feature_off; /* bit ignored if the callback returns true */
};

static const struct prot_bits pte_bits[] = {
	{
		.mask	= PTE_VALID,
		.val	= PTE_VALID,
		.set	= " ",
		.clear	= "F",
	}, {
		.mask	= PTE_USER,
		.val	= PTE_USER,
		.set	= "USR",
		.clear	= "   ",
	}, {
		.mask	= PTE_RDONLY,
		.val	= PTE_RDONLY,
		.set	= "ro",
		.clear	= "RW",
	}, {
		.mask	= PTE_PXN,
		.val	= PTE_PXN,
		.set	= "NX",
		.clear	= "x ",
	}, {
		.mask	= PTE_SHARED,
		.val	= PTE_SHARED,
		.set	= "SHD",
		.clear	= "   ",
	}, {
		.mask	= PTE_AF,
		.val	= PTE_AF,
		.set	= "AF",
		.clear	= "  ",
	}, {
		.mask	= PTE_NG,
		.val	= PTE_NG,
		.set	= "NG",
		.clear	= "  ",
	}, {
		.mask	= PTE_CONT,
		.val	= PTE_CONT,
		.set	= "CON",
		.clear	= "   ",
	}, {
		.mask	= PTE_TABLE_BIT,
		.val	= PTE_TABLE_BIT,
		.set	= "   ",
		.clear	= "BLK",
	}, {
		.mask	= PTE_UXN,
		.val	= PTE_UXN,
		.set	= "UXN",
		.clear	= "   ",
	}, {
		.mask	= PTE_GP,
		.val	= PTE_GP,
		.set	= "GP",
		.clear	= "  ",
	}, {
		.mask	= PTE_ATTRINDX_MASK,
		.val	= PTE_ATTRINDX(MT_DEVICE_nGnRnE),
		.set	= "DEVICE/nGnRnE",
	}, {
		.mask	= PTE_ATTRINDX_MASK,
		.val	= PTE_ATTRINDX(MT_DEVICE_nGnRE),
		.set	= "DEVICE/nGnRE",
	}, {
		.mask	= PTE_ATTRINDX_MASK,
		.val	= PTE_ATTRINDX(MT_NORMAL_NC),
		.set	= "MEM/NORMAL-NC",
	}, {
		.mask	= PTE_ATTRINDX_MASK,
		.val	= PTE_ATTRINDX(MT_NORMAL),
		.set	= "MEM/NORMAL",
	}, {
		.mask	= PTE_ATTRINDX_MASK,
		.val	= PTE_ATTRINDX(MT_NORMAL_TAGGED),
		.set	= "MEM/NORMAL-TAGGED",
	}
};

static bool is_fwb_enabled(const void *ctx)
{
	const struct pg_state *st = ctx;
	const struct ptdump_info *info = st->info;
	struct kvm_pgtable_snapshot *snapshot = info->priv;
	struct kvm_pgtable *pgtable = &snapshot->pgtable;

	bool fwb_enabled = false;

	if (cpus_have_const_cap(ARM64_HAS_STAGE2_FWB))
		fwb_enabled = !(pgtable->flags & KVM_PGTABLE_S2_NOFWB);

	return fwb_enabled;
}

static bool is_table_bit_ignored(const void *ctx)
{
	const struct pg_state *st = ctx;

	if (!(st->current_prot & PTE_VALID))
		return true;

	if (st->level == CONFIG_PGTABLE_LEVELS)
		return true;

	return false;
}

static const struct prot_bits stage2_pte_bits[] = {
	{
		.mask	= PTE_VALID,
		.val	= PTE_VALID,
		.set	= " ",
		.clear	= "F",
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
		.val	= KVM_PTE_LEAF_ATTR_HI_S2_XN,
		.set	= "XN",
		.clear	= "  ",
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R,
		.val	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_R,
		.set	= "R",
		.clear	= " ",
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W,
		.val	= KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W,
		.set	= "W",
		.clear	= " ",
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_AF,
		.val	= KVM_PTE_LEAF_ATTR_LO_S2_AF,
		.set	= "AF",
		.clear	= "  ",
	}, {
		.mask	= PTE_NG,
		.val	= PTE_NG,
		.set	= "FnXS",
		.clear	= "  ",
	}, {
		.mask	= PTE_CONT,
		.val	= PTE_CONT,
		.set	= "CON",
		.clear	= "   ",
	}, {
		.mask	= PTE_TABLE_BIT,
		.val	= PTE_TABLE_BIT,
		.set	= "   ",
		.clear	= "BLK",
		.feature_off	= is_table_bit_ignored,
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR | PTE_VALID,
		.val	= PTE_S2_MEMATTR(MT_S2_DEVICE_nGnRE) | PTE_VALID,
		.set	= "DEVICE/nGnRE",
		.feature_off	= is_fwb_enabled,
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR | PTE_VALID,
		.val	= PTE_S2_MEMATTR(MT_S2_FWB_DEVICE_nGnRE) | PTE_VALID,
		.set	= "DEVICE/nGnRE FWB",
		.feature_on	= is_fwb_enabled,
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR | PTE_VALID,
		.val	= PTE_S2_MEMATTR(MT_S2_NORMAL) | PTE_VALID,
		.set	= "MEM/NORMAL",
		.feature_off	= is_fwb_enabled,
	}, {
		.mask	= KVM_PTE_LEAF_ATTR_LO_S2_MEMATTR | PTE_VALID,
		.val	= PTE_S2_MEMATTR(MT_S2_FWB_NORMAL) | PTE_VALID,
		.set	= "MEM/NORMAL FWB",
		.feature_on	= is_fwb_enabled,
	}, {
		.mask	= KVM_INVALID_PTE_OWNER_MASK | PTE_VALID,
		.val	= FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK,
					   PKVM_ID_HYP),
		.set	= "HYP",
	}, {
		.mask	= KVM_INVALID_PTE_OWNER_MASK | PTE_VALID,
		.val	= FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK,
					   PKVM_ID_FFA),
		.set	= "FF-A",
	}, {
		.mask	= KVM_INVALID_PTE_OWNER_MASK | PTE_VALID,
		.val	= FIELD_PREP_CONST(KVM_INVALID_PTE_OWNER_MASK,
					   PKVM_ID_GUEST),
		.set	= "GUEST",
	}, {
		.mask	= KVM_PGTABLE_PROT_SW0,
		.val	= KVM_PGTABLE_PROT_SW0,
		.set	= "SW0", /* PKVM_PAGE_SHARED_OWNED */
	}, {
		.mask   = KVM_PGTABLE_PROT_SW1,
		.val	= KVM_PGTABLE_PROT_SW1,
		.set	= "SW1", /* PKVM_PAGE_SHARED_BORROWED */
	}, {
		.mask	= KVM_PGTABLE_PROT_SW2,
		.val	= KVM_PGTABLE_PROT_SW2,
		.set	= "SW2",
	}, {
		.mask   = KVM_PGTABLE_PROT_SW3,
		.val	= KVM_PGTABLE_PROT_SW3,
		.set	= "SW3",
	},
};

struct pg_level {
	const struct prot_bits *bits;
	const char *name;
	size_t num;
	u64 mask;
};

static struct pg_level pg_level[] = {
	{ /* pgd */
		.name	= "PGD",
		.bits	= pte_bits,
		.num	= ARRAY_SIZE(pte_bits),
	}, { /* p4d */
		.name	= "P4D",
		.bits	= pte_bits,
		.num	= ARRAY_SIZE(pte_bits),
	}, { /* pud */
		.name	= (CONFIG_PGTABLE_LEVELS > 3) ? "PUD" : "PGD",
		.bits	= pte_bits,
		.num	= ARRAY_SIZE(pte_bits),
	}, { /* pmd */
		.name	= (CONFIG_PGTABLE_LEVELS > 2) ? "PMD" : "PGD",
		.bits	= pte_bits,
		.num	= ARRAY_SIZE(pte_bits),
	}, { /* pte */
		.name	= "PTE",
		.bits	= pte_bits,
		.num	= ARRAY_SIZE(pte_bits),
	},
};

static struct pg_level stage2_pg_level[] = {
	{ /* pgd */
		.name	= "PGD",
		.bits	= stage2_pte_bits,
		.num	= ARRAY_SIZE(stage2_pte_bits),
	}, { /* p4d */
		.name	= "P4D",
		.bits	= stage2_pte_bits,
		.num	= ARRAY_SIZE(stage2_pte_bits),
	}, { /* pud */
		.name	= (CONFIG_PGTABLE_LEVELS > 3) ? "PUD" : "PGD",
		.bits	= stage2_pte_bits,
		.num	= ARRAY_SIZE(stage2_pte_bits),
	}, { /* pmd */
		.name	= (CONFIG_PGTABLE_LEVELS > 2) ? "PMD" : "PGD",
		.bits	= stage2_pte_bits,
		.num	= ARRAY_SIZE(stage2_pte_bits),
	}, { /* pte */
		.name	= "PTE",
		.bits	= stage2_pte_bits,
		.num	= ARRAY_SIZE(stage2_pte_bits),
	},
};

static void dump_prot(struct pg_state *st, const struct prot_bits *bits,
		      size_t num)
{
	unsigned i;

	for (i = 0; i < num; i++, bits++) {
		const char *s;

		if (bits->feature_on && !bits->feature_on(st))
			continue;

		if (bits->feature_off && bits->feature_off(st))
			continue;

		if ((st->current_prot & bits->mask) == bits->val)
			s = bits->set;
		else
			s = bits->clear;

		if (s)
			pt_dump_seq_printf(st->seq, " %s", s);
	}
}

static void note_prot_uxn(struct pg_state *st, unsigned long addr)
{
	if (!st->check_wx)
		return;

	if ((st->current_prot & PTE_UXN) == PTE_UXN)
		return;

	WARN_ONCE(1, "arm64/mm: Found non-UXN mapping at address %p/%pS\n",
		  (void *)st->start_address, (void *)st->start_address);

	st->uxn_pages += (addr - st->start_address) / PAGE_SIZE;
}

static void note_prot_wx(struct pg_state *st, unsigned long addr)
{
	if (!st->check_wx)
		return;
	if ((st->current_prot & PTE_RDONLY) == PTE_RDONLY)
		return;
	if ((st->current_prot & PTE_PXN) == PTE_PXN)
		return;

	WARN_ONCE(1, "arm64/mm: Found insecure W+X mapping at address %p/%pS\n",
		  (void *)st->start_address, (void *)st->start_address);

	st->wx_pages += (addr - st->start_address) / PAGE_SIZE;
}

static void note_page(struct ptdump_state *pt_st, unsigned long addr, int level,
		      u64 val)
{
	struct pg_state *st = container_of(pt_st, struct pg_state, ptdump);
	struct pg_level *pg_info = st->pg_level;
	static const char units[] = "KMGTPE";
	u64 prot = 0;

	if (level >= 0)
		prot = val & pg_info[level].mask;

	if (st->level == -1) {
		st->level = level;
		st->current_prot = prot;
		st->start_address = addr;
		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
	} else if (prot != st->current_prot || level != st->level ||
		   addr >= st->marker[1].start_address) {
		const char *unit = units;
		unsigned long delta;

		if (st->current_prot) {
			note_prot_uxn(st, addr);
			note_prot_wx(st, addr);
		}

		pt_dump_seq_printf(st->seq, "0x%016lx-0x%016lx   ",
				   st->start_address, addr);

		delta = (addr - st->start_address) >> 10;
		while (!(delta & 1023) && unit[1]) {
			delta >>= 10;
			unit++;
		}
		pt_dump_seq_printf(st->seq, "%9lu%c %s", delta, *unit,
				   pg_info[st->level].name);
		if (st->current_prot && pg_info[st->level].bits)
			dump_prot(st, pg_info[st->level].bits,
				  pg_info[st->level].num);
		pt_dump_seq_puts(st->seq, "\n");

		if (addr >= st->marker[1].start_address) {
			st->marker++;
			pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
		}

		st->start_address = addr;
		st->current_prot = prot;
		st->level = level;
	}

	if (addr >= st->marker[1].start_address) {
		st->marker++;
		pt_dump_seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
	}

}

void ptdump_walk(struct seq_file *s, struct ptdump_info *info)
{
	unsigned long end = ~0UL;
	struct pg_state st;

	if (info->base_addr < TASK_SIZE_64)
		end = TASK_SIZE_64;

	st = (struct pg_state){
		.seq = s,
		.marker = info->markers,
		.pg_level = &pg_level[0],
		.level = -1,
		.ptdump = {
			.note_page = note_page,
			.range = (struct ptdump_range[]){
				{info->base_addr, end},
				{0, 0}
			}
		}
	};

	ptdump_walk_pgd(&st.ptdump, info->mm, NULL);
}

static void __init ptdump_initialize(void)
{
	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;

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

static struct ptdump_info kernel_ptdump_info = {
	.mm		= &init_mm,
	.markers	= address_markers,
	.base_addr	= PAGE_OFFSET,
	.ptdump_walk	= &ptdump_walk,
};

void ptdump_check_wx(void)
{
	struct pg_state st = {
		.seq = NULL,
		.marker = (struct addr_marker[]) {
			{ 0, NULL},
			{ -1, NULL},
		},
		.pg_level = &pg_level[0],
		.level = -1,
		.check_wx = true,
		.ptdump = {
			.note_page = note_page,
			.range = (struct ptdump_range[]) {
				{PAGE_OFFSET, ~0UL},
				{0, 0}
			}
		}
	};

	ptdump_walk_pgd(&st.ptdump, &init_mm, NULL);

	if (st.wx_pages || st.uxn_pages)
		pr_warn("Checked W+X mappings: FAILED, %lu W+X pages found, %lu non-UXN pages found\n",
			st.wx_pages, st.uxn_pages);
	else
		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),
};

static phys_addr_t ptdump_host_pa(void *addr)
{
	return __pa(addr);
}

static void *ptdump_host_va(phys_addr_t phys)
{
	return __va(phys);
}

static size_t stage2_get_pgd_len(void)
{
	u64 mmfr0, mmfr1, vtcr;
	u32 phys_shift = get_kvm_ipa_limit();

	mmfr0 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1);
	mmfr1 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1);
	vtcr = kvm_get_vtcr(mmfr0, mmfr1, phys_shift);

	return kvm_pgtable_stage2_pgd_size(vtcr);
}

static void stage2_ptdump_prepare_walk(struct ptdump_info *info)
{
	struct kvm_pgtable_snapshot *snapshot;
	int ret, pgd_index, mc_index, pgd_pages_sz;
	void *page_hva;

	snapshot = alloc_pages_exact(PAGE_SIZE, GFP_KERNEL_ACCOUNT);
	if (!snapshot)
		return;

	memset(snapshot, 0, PAGE_SIZE);
	ret = kvm_call_hyp_nvhe(__pkvm_host_share_hyp, virt_to_pfn(snapshot));
	if (ret)
		goto free_snapshot;

	snapshot->pgd_len = stage2_get_pgd_len();
	pgd_pages_sz = snapshot->pgd_len / PAGE_SIZE;
	snapshot->pgd_hva = alloc_pages_exact(snapshot->pgd_len,
					      GFP_KERNEL_ACCOUNT);
	if (!snapshot->pgd_hva)
		goto unshare_snapshot;

	for (pgd_index = 0; pgd_index < pgd_pages_sz; pgd_index++) {
		page_hva = snapshot->pgd_hva + pgd_index * PAGE_SIZE;
		ret = kvm_call_hyp_nvhe(__pkvm_host_share_hyp,
					virt_to_pfn(page_hva));
		if (ret)
			goto unshare_pgd_pages;
	}

	for (mc_index = 0; mc_index < info->mc_len; mc_index++) {
		page_hva = alloc_pages_exact(PAGE_SIZE, GFP_KERNEL_ACCOUNT);
		if (!page_hva)
			goto free_memcache_pages;

		push_hyp_memcache(&snapshot->mc, page_hva, ptdump_host_pa);
		ret = kvm_call_hyp_nvhe(__pkvm_host_share_hyp,
					virt_to_pfn(page_hva));
		if (ret) {
			pop_hyp_memcache(&snapshot->mc, ptdump_host_va);
			free_pages_exact(page_hva, PAGE_SIZE);
			goto free_memcache_pages;
		}
	}

	ret = kvm_call_hyp_nvhe(__pkvm_copy_host_stage2, snapshot);
	if (ret)
		goto free_memcache_pages;

	info->priv = snapshot;
	return;

free_memcache_pages:
	page_hva = pop_hyp_memcache(&snapshot->mc, ptdump_host_va);
	while (page_hva) {
		ret = kvm_call_hyp_nvhe(__pkvm_host_unshare_hyp,
					virt_to_pfn(page_hva));
		WARN_ON(ret);
		free_pages_exact(page_hva, PAGE_SIZE);
		page_hva = pop_hyp_memcache(&snapshot->mc, ptdump_host_va);
	}
unshare_pgd_pages:
	pgd_index = pgd_index - 1;
	for (; pgd_index >= 0; pgd_index--) {
		page_hva = snapshot->pgd_hva + pgd_index * PAGE_SIZE;
		ret = kvm_call_hyp_nvhe(__pkvm_host_unshare_hyp,
					virt_to_pfn(page_hva));
		WARN_ON(ret);
	}
	free_pages_exact(snapshot->pgd_hva, snapshot->pgd_len);
unshare_snapshot:
	WARN_ON(kvm_call_hyp_nvhe(__pkvm_host_unshare_hyp,
				  virt_to_pfn(snapshot)));
free_snapshot:
	free_pages_exact(snapshot, PAGE_SIZE);
	info->priv = NULL;
}

static void stage2_ptdump_end_walk(struct ptdump_info *info)
{
	struct kvm_pgtable_snapshot *snapshot = info->priv;
	void *page_hva;
	int pgd_index, ret, pgd_pages_sz;

	if (!snapshot)
		return;

	page_hva = pop_hyp_memcache(&snapshot->mc, ptdump_host_va);
	while (page_hva) {
		ret = kvm_call_hyp_nvhe(__pkvm_host_unshare_hyp,
					virt_to_pfn(page_hva));
		WARN_ON(ret);
		free_pages_exact(page_hva, PAGE_SIZE);
		page_hva = pop_hyp_memcache(&snapshot->mc, ptdump_host_va);
	}

	pgd_pages_sz = snapshot->pgd_len / PAGE_SIZE;
	for (pgd_index = 0; pgd_index < pgd_pages_sz; pgd_index++) {
		page_hva = snapshot->pgd_hva + pgd_index * PAGE_SIZE;
		ret = kvm_call_hyp_nvhe(__pkvm_host_unshare_hyp,
					virt_to_pfn(page_hva));
		WARN_ON(ret);
	}

	free_pages_exact(snapshot->pgd_hva, snapshot->pgd_len);
	WARN_ON(kvm_call_hyp_nvhe(__pkvm_host_unshare_hyp,
				  virt_to_pfn(snapshot)));
	free_pages_exact(snapshot, PAGE_SIZE);
	info->priv = NULL;
}

static u32 stage2_get_max_pgd_index(u32 ipa_bits, u32 start_level)
{
	u64 end_ipa = BIT(ipa_bits) - 1;
	u32 shift = ARM64_HW_PGTABLE_LEVEL_SHIFT(start_level - 1);

	return end_ipa >> shift;
}

static void stage2_ptdump_walk(struct seq_file *s, struct ptdump_info *info)
{
	struct kvm_pgtable_snapshot *snapshot = info->priv;
	struct pg_state st;
	struct kvm_pgtable *pgtable;
	u32 pgd_index, pgd_pages, pgd_shift;
	u64 start_ipa = 0, end_ipa;
	pgd_t *pgd;

	if (snapshot == NULL || !snapshot->pgtable.pgd)
		return;

	pgtable = &snapshot->pgtable;
	info->mm->pgd = phys_to_virt((phys_addr_t)pgtable->pgd);
	pgd_shift = ARM64_HW_PGTABLE_LEVEL_SHIFT(pgtable->start_level - 1);
	pgd_pages = stage2_get_max_pgd_index(pgtable->ia_bits,
					     pgtable->start_level);

	for (pgd_index = 0; pgd_index <= pgd_pages; pgd_index++) {
		end_ipa = start_ipa + (1UL << pgd_shift);

		st = (struct pg_state) {
			.seq		= s,
			.marker		= info->markers,
			.level		= pgtable->start_level,
			.pg_level	= &stage2_pg_level[0],
			.info		= info,
			.ptdump		= {
				.note_page	= note_page,
				.range		= (struct ptdump_range[]) {
					{start_ipa,	end_ipa},
					{0,		0},
				},
			},
		};

		ipa_address_markers[0].start_address = start_ipa;
		ipa_address_markers[1].start_address = end_ipa;

		pgd = &info->mm->pgd[pgd_index * PTRS_PER_PTE];
		ptdump_walk_pgd(&st.ptdump, info->mm, pgd);
		start_ipa = end_ipa;
	}
}
#endif /* CONFIG_NVHE_EL2_PTDUMP_DEBUGFS */

static int __init ptdump_init(void)
{
	address_markers[PAGE_END_NR].start_address = PAGE_END;
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
	address_markers[KASAN_START_NR].start_address = KASAN_SHADOW_START;
#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,
		.mc_len			= host_s2_pgtable_pages(),
		.ptdump_prepare_walk	= stage2_ptdump_prepare_walk,
		.ptdump_end_walk	= stage2_ptdump_end_walk,
		.ptdump_walk		= stage2_ptdump_walk,
	};

	init_rwsem(&ipa_init_mm.mmap_lock);
	mutex_init(&stage2_kernel_ptdump_info.file_lock);

	ptdump_debugfs_register(&stage2_kernel_ptdump_info,
				"host_stage2_kernel_page_tables");
#endif
	return 0;
}
device_initcall(ptdump_init);
