From nobody Wed Dec 17 15:34:27 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A501A21507F; Mon, 17 Mar 2025 06:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742192320; cv=none; b=bQMuUTHngY/LA8F01INRvrfqGHe7KPFRbiOPmUokUXhib+ub4wq2emMteBliYiLrJREtU7zwRhQ4CJkcKYptA/z4HyYsVVNiDf/4sSrMn/HG4n8YofyafUI/M8GAMADz0UJ9wMnkew4FfeZNVXUPbsIsqIVQw8JdRtHPONTT6Gw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742192320; c=relaxed/simple; bh=MdAqIVQWnso5W20SsCmoD1NDy5cD766+ecbtn2arYoY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mHe1SIJxW8si5J+TytLH8j9fmqfKfyWdEF4WyEMiELNMa4AAF4ZF4WfRXQ7I50FHn99XMunw/JvBqN0HMl+hi2PZWpJu/axSBRiqQ8sdDpk8ONwxJ2qDXt3o9u/FDCSeiJbPfGblF71OFvNnIlT1Fh0POfpONQVi8zYFx9dsO3Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F314C169E; Sun, 16 Mar 2025 23:18:45 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.16.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5B61A3F673; Sun, 16 Mar 2025 23:18:30 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Steven Price , Ryan Roberts , Madhavan Srinivasan , Nicholas Piggin , Paul Walmsley , Palmer Dabbelt , Gerald Schaefer , Heiko Carstens , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org Subject: [PATCH 1/2] mm/ptdump: Split note_page() into level specific callbacks Date: Mon, 17 Mar 2025 11:48:17 +0530 Message-Id: <20250317061818.16244-2-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250317061818.16244-1-anshuman.khandual@arm.com> References: <20250317061818.16244-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Last argument passed down in note_page() is u64 assuming pxd_val() returned value (all page table levels) is 64 bit - which might not be the case going ahead when D128 page tables is enabled on arm64 platform. Besides pxd_val() is very platform specific and its type should not be assumed in generic MM. Split note_page() into individual page table level specific callbacks which accepts corresponding pxd_t argument instead and then subscribing platforms just derive pxd_val() from the entries as required and proceed as earlier. Also add a note_page_flush() callback for flushing the last page table page that was being handled earlier via level =3D -1. Cc: Catalin Marinas Cc: Will Deacon Cc: Madhavan Srinivasan Cc: Nicholas Piggin Cc: Paul Walmsley Cc: Palmer Dabbelt Cc: Gerald Schaefer Cc: Heiko Carstens Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Ingo Molnar Cc: Andrew Morton Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: linuxppc-dev@lists.ozlabs.org Cc: linux-riscv@lists.infradead.org Cc: linux-s390@vger.kernel.org Cc: linux-mm@kvack.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/ptdump.h | 16 +++++++++-- arch/arm64/mm/ptdump.c | 48 ++++++++++++++++++++++++++++++--- arch/powerpc/mm/ptdump/ptdump.c | 46 +++++++++++++++++++++++++++++-- arch/riscv/mm/ptdump.c | 46 +++++++++++++++++++++++++++++-- arch/s390/mm/dump_pagetables.c | 46 +++++++++++++++++++++++++++++-- arch/x86/mm/dump_pagetables.c | 39 ++++++++++++++++++++++++++- include/linux/ptdump.h | 9 ++++--- mm/ptdump.c | 42 ++++++++++++++++++++++------- 8 files changed, 267 insertions(+), 25 deletions(-) diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdum= p.h index 6cf4aae05219..e5da9ce8a515 100644 --- a/arch/arm64/include/asm/ptdump.h +++ b/arch/arm64/include/asm/ptdump.h @@ -59,7 +59,13 @@ struct ptdump_pg_state { =20 void ptdump_walk(struct seq_file *s, struct ptdump_info *info); void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, - u64 val); + pteval_t val); +void note_page_pte(struct ptdump_state *st, unsigned long addr, pte_t pte); +void note_page_pmd(struct ptdump_state *st, unsigned long addr, pmd_t pmd); +void note_page_pud(struct ptdump_state *st, unsigned long addr, pud_t pud); +void note_page_p4d(struct ptdump_state *st, unsigned long addr, p4d_t p4d); +void note_page_pgd(struct ptdump_state *st, unsigned long addr, pgd_t pgd); +void note_page_flush(struct ptdump_state *st); #ifdef CONFIG_PTDUMP_DEBUGFS #define EFI_RUNTIME_MAP_END DEFAULT_MAP_WINDOW_64 void __init ptdump_debugfs_register(struct ptdump_info *info, const char *= name); @@ -69,7 +75,13 @@ static inline void ptdump_debugfs_register(struct ptdump= _info *info, #endif /* CONFIG_PTDUMP_DEBUGFS */ #else static inline void note_page(struct ptdump_state *pt_st, unsigned long add= r, - int level, u64 val) { } + int level, pteval_t val) { } +static inline void note_page_pte(struct ptdump_state *st, unsigned long ad= dr, pte_t pte) { } +static inline void note_page_pmd(struct ptdump_state *st, unsigned long ad= dr, pmd_t pmd) { } +static inline void note_page_pud(struct ptdump_state *st, unsigned long ad= dr, pud_t pud) { } +static inline void note_page_p4d(struct ptdump_state *st, unsigned long ad= dr, p4d_t p4d) { } +static inline void note_page_pgd(struct ptdump_state *st, unsigned long ad= dr, pgd_t pgd) { } +static inline void note_page_flush(struct ptdump_state *st) { } #endif /* CONFIG_PTDUMP_CORE */ =20 #endif /* __ASM_PTDUMP_H */ diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index 688fbe0271ca..fd1610b4fd15 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -189,7 +189,7 @@ static void note_prot_wx(struct ptdump_pg_state *st, un= signed long addr) } =20 void note_page(struct ptdump_state *pt_st, unsigned long addr, int level, - u64 val) + pteval_t val) { struct ptdump_pg_state *st =3D container_of(pt_st, struct ptdump_pg_state= , ptdump); struct ptdump_pg_level *pg_level =3D st->pg_level; @@ -251,6 +251,38 @@ void note_page(struct ptdump_state *pt_st, unsigned lo= ng addr, int level, =20 } =20 +void note_page_pte(struct ptdump_state *pt_st, unsigned long addr, pte_t p= te) +{ + note_page(pt_st, addr, 4, pte_val(pte)); +} + +void note_page_pmd(struct ptdump_state *pt_st, unsigned long addr, pmd_t p= md) +{ + note_page(pt_st, addr, 3, pmd_val(pmd)); +} + +void note_page_pud(struct ptdump_state *pt_st, unsigned long addr, pud_t p= ud) +{ + note_page(pt_st, addr, 2, pud_val(pud)); +} + +void note_page_p4d(struct ptdump_state *pt_st, unsigned long addr, p4d_t p= 4d) +{ + note_page(pt_st, addr, 1, p4d_val(p4d)); +} + +void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, pgd_t p= gd) +{ + note_page(pt_st, addr, 0, pgd_val(pgd)); +} + +void note_page_flush(struct ptdump_state *pt_st) +{ + pte_t pte_zero =3D {0}; + + note_page(pt_st, 0, -1, pte_val(pte_zero)); +} + void ptdump_walk(struct seq_file *s, struct ptdump_info *info) { unsigned long end =3D ~0UL; @@ -266,7 +298,12 @@ void ptdump_walk(struct seq_file *s, struct ptdump_inf= o *info) .pg_level =3D &kernel_pg_levels[0], .level =3D -1, .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D (struct ptdump_range[]){ {info->base_addr, end}, {0, 0} @@ -303,7 +340,12 @@ bool ptdump_check_wx(void) .level =3D -1, .check_wx =3D true, .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D (struct ptdump_range[]) { {_PAGE_OFFSET(vabits_actual), ~0UL}, {0, 0} diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdum= p.c index 9dc239967b77..b2358d794855 100644 --- a/arch/powerpc/mm/ptdump/ptdump.c +++ b/arch/powerpc/mm/ptdump/ptdump.c @@ -298,6 +298,38 @@ static void populate_markers(void) #endif } =20 +static void note_page_pte(struct ptdump_state *pt_st, unsigned long addr, = pte_t pte) +{ + note_page(pt_st, addr, 4, pte_val(pte)); +} + +static void note_page_pmd(struct ptdump_state *pt_st, unsigned long addr, = pmd_t pmd) +{ + note_page(pt_st, addr, 3, pmd_val(pmd)); +} + +static void note_page_pud(struct ptdump_state *pt_st, unsigned long addr, = pud_t pud) +{ + note_page(pt_st, addr, 2, pud_val(pud)); +} + +static void note_page_p4d(struct ptdump_state *pt_st, unsigned long addr, = p4d_t p4d) +{ + note_page(pt_st, addr, 1, p4d_val(p4d)); +} + +static void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, = pgd_t pgd) +{ + note_page(pt_st, addr, 0, pgd_val(pgd)); +} + +static void note_page_flush(struct ptdump_state *pt_st) +{ + pte_t pte_zero =3D {0}; + + note_page(pt_st, 0, -1, pte_val(pte_zero)); +} + static int ptdump_show(struct seq_file *m, void *v) { struct pg_state st =3D { @@ -305,7 +337,12 @@ static int ptdump_show(struct seq_file *m, void *v) .marker =3D address_markers, .level =3D -1, .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D ptdump_range, } }; @@ -338,7 +375,12 @@ bool ptdump_check_wx(void) .level =3D -1, .check_wx =3D true, .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D ptdump_range, } }; diff --git a/arch/riscv/mm/ptdump.c b/arch/riscv/mm/ptdump.c index 9d5f657a251b..32922550a50a 100644 --- a/arch/riscv/mm/ptdump.c +++ b/arch/riscv/mm/ptdump.c @@ -318,6 +318,38 @@ static void note_page(struct ptdump_state *pt_st, unsi= gned long addr, } } =20 +static void note_page_pte(struct ptdump_state *pt_st, unsigned long addr, = pte_t pte) +{ + note_page(pt_st, addr, 4, pte_val(pte)); +} + +static void note_page_pmd(struct ptdump_state *pt_st, unsigned long addr, = pmd_t pmd) +{ + note_page(pt_st, addr, 3, pmd_val(pmd)); +} + +static void note_page_pud(struct ptdump_state *pt_st, unsigned long addr, = pud_t pud) +{ + note_page(pt_st, addr, 2, pud_val(pud)); +} + +static void note_page_p4d(struct ptdump_state *pt_st, unsigned long addr, = p4d_t p4d) +{ + note_page(pt_st, addr, 1, p4d_val(p4d)); +} + +static void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, = pgd_t pgd) +{ + note_page(pt_st, addr, 0, pgd_val(pgd)); +} + +static void note_page_flush(struct ptdump_state *pt_st) +{ + pte_t pte_zero =3D {0}; + + note_page(pt_st, 0, -1, pte_val(pte_zero)); +} + static void ptdump_walk(struct seq_file *s, struct ptd_mm_info *pinfo) { struct pg_state st =3D { @@ -325,7 +357,12 @@ static void ptdump_walk(struct seq_file *s, struct ptd= _mm_info *pinfo) .marker =3D pinfo->markers, .level =3D -1, .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D (struct ptdump_range[]) { {pinfo->base_addr, pinfo->end}, {0, 0} @@ -347,7 +384,12 @@ bool ptdump_check_wx(void) .level =3D -1, .check_wx =3D true, .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D (struct ptdump_range[]) { {KERN_VIRT_START, ULONG_MAX}, {0, 0} diff --git a/arch/s390/mm/dump_pagetables.c b/arch/s390/mm/dump_pagetables.c index fa54f3bc0c8d..e7cc52542f71 100644 --- a/arch/s390/mm/dump_pagetables.c +++ b/arch/s390/mm/dump_pagetables.c @@ -145,11 +145,48 @@ static void note_page(struct ptdump_state *pt_st, uns= igned long addr, int level, } } =20 +static void note_page_pte(struct ptdump_state *pt_st, unsigned long addr, = pte_t pte) +{ + note_page(pt_st, addr, 4, pte_val(pte)); +} + +static void note_page_pmd(struct ptdump_state *pt_st, unsigned long addr, = pmd_t pmd) +{ + note_page(pt_st, addr, 3, pmd_val(pmd)); +} + +static void note_page_pud(struct ptdump_state *pt_st, unsigned long addr, = pud_t pud) +{ + note_page(pt_st, addr, 2, pud_val(pud)); +} + +static void note_page_p4d(struct ptdump_state *pt_st, unsigned long addr, = p4d_t p4d) +{ + note_page(pt_st, addr, 1, p4d_val(p4d)); +} + +static void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, = pgd_t pgd) +{ + note_page(pt_st, addr, 0, pgd_val(pgd)); +} + +static void note_page_flush(struct ptdump_state *pt_st) +{ + pte_t pte_zero =3D {0}; + + note_page(pt_st, 0, -1, pte_val(pte_zero)); +} + bool ptdump_check_wx(void) { struct pg_state st =3D { .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D (struct ptdump_range[]) { {.start =3D 0, .end =3D max_addr}, {.start =3D 0, .end =3D 0}, @@ -188,7 +225,12 @@ static int ptdump_show(struct seq_file *m, void *v) { struct pg_state st =3D { .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .range =3D (struct ptdump_range[]) { {.start =3D 0, .end =3D max_addr}, {.start =3D 0, .end =3D 0}, diff --git a/arch/x86/mm/dump_pagetables.c b/arch/x86/mm/dump_pagetables.c index 89079ea73e65..2e1c2d006ace 100644 --- a/arch/x86/mm/dump_pagetables.c +++ b/arch/x86/mm/dump_pagetables.c @@ -362,6 +362,38 @@ static void note_page(struct ptdump_state *pt_st, unsi= gned long addr, int level, } } =20 +static void note_page_pte(struct ptdump_state *pt_st, unsigned long addr, = pte_t pte) +{ + note_page(pt_st, addr, 4, pte_val(pte)); +} + +static void note_page_pmd(struct ptdump_state *pt_st, unsigned long addr, = pmd_t pmd) +{ + note_page(pt_st, addr, 3, pmd_val(pmd)); +} + +static void note_page_pud(struct ptdump_state *pt_st, unsigned long addr, = pud_t pud) +{ + note_page(pt_st, addr, 2, pud_val(pud)); +} + +static void note_page_p4d(struct ptdump_state *pt_st, unsigned long addr, = p4d_t p4d) +{ + note_page(pt_st, addr, 1, p4d_val(p4d)); +} + +static void note_page_pgd(struct ptdump_state *pt_st, unsigned long addr, = pgd_t pgd) +{ + note_page(pt_st, addr, 0, pgd_val(pgd)); +} + +static void note_page_flush(struct ptdump_state *pt_st) +{ + pte_t pte_zero =3D {0}; + + note_page(pt_st, 0, -1, pte_val(pte_zero)); +} + bool ptdump_walk_pgd_level_core(struct seq_file *m, struct mm_struct *mm, pgd_t *pgd, bool checkwx, bool dmesg) @@ -378,7 +410,12 @@ bool ptdump_walk_pgd_level_core(struct seq_file *m, =20 struct pg_state st =3D { .ptdump =3D { - .note_page =3D note_page, + .note_page_pte =3D note_page_pte, + .note_page_pmd =3D note_page_pmd, + .note_page_pud =3D note_page_pud, + .note_page_p4d =3D note_page_p4d, + .note_page_pgd =3D note_page_pgd, + .note_page_flush =3D note_page_flush, .effective_prot =3D effective_prot, .range =3D ptdump_ranges }, diff --git a/include/linux/ptdump.h b/include/linux/ptdump.h index 8dbd51ea8626..1c1eb1fae199 100644 --- a/include/linux/ptdump.h +++ b/include/linux/ptdump.h @@ -11,9 +11,12 @@ struct ptdump_range { }; =20 struct ptdump_state { - /* level is 0:PGD to 4:PTE, or -1 if unknown */ - void (*note_page)(struct ptdump_state *st, unsigned long addr, - int level, u64 val); + void (*note_page_pte)(struct ptdump_state *st, unsigned long addr, pte_t = pte); + void (*note_page_pmd)(struct ptdump_state *st, unsigned long addr, pmd_t = pmd); + void (*note_page_pud)(struct ptdump_state *st, unsigned long addr, pud_t = pud); + void (*note_page_p4d)(struct ptdump_state *st, unsigned long addr, p4d_t = p4d); + void (*note_page_pgd)(struct ptdump_state *st, unsigned long addr, pgd_t = pgd); + void (*note_page_flush)(struct ptdump_state *st); void (*effective_prot)(struct ptdump_state *st, int level, u64 val); const struct ptdump_range *range; }; diff --git a/mm/ptdump.c b/mm/ptdump.c index 106e1d66e9f9..706cfc19439b 100644 --- a/mm/ptdump.c +++ b/mm/ptdump.c @@ -18,7 +18,7 @@ static inline int note_kasan_page_table(struct mm_walk *w= alk, { struct ptdump_state *st =3D walk->private; =20 - st->note_page(st, addr, 4, pte_val(kasan_early_shadow_pte[0])); + st->note_page_pte(st, addr, kasan_early_shadow_pte[0]); =20 walk->action =3D ACTION_CONTINUE; =20 @@ -42,7 +42,7 @@ static int ptdump_pgd_entry(pgd_t *pgd, unsigned long add= r, st->effective_prot(st, 0, pgd_val(val)); =20 if (pgd_leaf(val)) { - st->note_page(st, addr, 0, pgd_val(val)); + st->note_page_pgd(st, addr, val); walk->action =3D ACTION_CONTINUE; } =20 @@ -65,7 +65,7 @@ static int ptdump_p4d_entry(p4d_t *p4d, unsigned long add= r, st->effective_prot(st, 1, p4d_val(val)); =20 if (p4d_leaf(val)) { - st->note_page(st, addr, 1, p4d_val(val)); + st->note_page_p4d(st, addr, val); walk->action =3D ACTION_CONTINUE; } =20 @@ -88,7 +88,7 @@ static int ptdump_pud_entry(pud_t *pud, unsigned long add= r, st->effective_prot(st, 2, pud_val(val)); =20 if (pud_leaf(val)) { - st->note_page(st, addr, 2, pud_val(val)); + st->note_page_pud(st, addr, val); walk->action =3D ACTION_CONTINUE; } =20 @@ -109,7 +109,7 @@ static int ptdump_pmd_entry(pmd_t *pmd, unsigned long a= ddr, if (st->effective_prot) st->effective_prot(st, 3, pmd_val(val)); if (pmd_leaf(val)) { - st->note_page(st, addr, 3, pmd_val(val)); + st->note_page_pmd(st, addr, val); walk->action =3D ACTION_CONTINUE; } =20 @@ -125,7 +125,7 @@ static int ptdump_pte_entry(pte_t *pte, unsigned long a= ddr, if (st->effective_prot) st->effective_prot(st, 4, pte_val(val)); =20 - st->note_page(st, addr, 4, pte_val(val)); + st->note_page_pte(st, addr, val); =20 return 0; } @@ -134,9 +134,31 @@ static int ptdump_hole(unsigned long addr, unsigned lo= ng next, int depth, struct mm_walk *walk) { struct ptdump_state *st =3D walk->private; - - st->note_page(st, addr, depth, 0); - + pte_t pte_zero =3D {0}; + pmd_t pmd_zero =3D {0}; + pud_t pud_zero =3D {0}; + p4d_t p4d_zero =3D {0}; + pgd_t pgd_zero =3D {0}; + + switch (depth) { + case 4: + st->note_page_pte(st, addr, pte_zero); + break; + case 3: + st->note_page_pmd(st, addr, pmd_zero); + break; + case 2: + st->note_page_pud(st, addr, pud_zero); + break; + case 1: + st->note_page_p4d(st, addr, p4d_zero); + break; + case 0: + st->note_page_pgd(st, addr, pgd_zero); + break; + default: + break; + } return 0; } =20 @@ -162,7 +184,7 @@ void ptdump_walk_pgd(struct ptdump_state *st, struct mm= _struct *mm, pgd_t *pgd) mmap_write_unlock(mm); =20 /* Flush out the last page */ - st->note_page(st, 0, -1, 0); + st->note_page_flush(st); } =20 static int check_wx_show(struct seq_file *m, void *v) --=20 2.25.1 From nobody Wed Dec 17 15:34:27 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D00321A454; Mon, 17 Mar 2025 06:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742192326; cv=none; b=J3I4SvW22PIZPJkur9k85aHj02rf5cLnsR00qdQoTwGIYuNwJW2B3WXB0XbgVj13OqAQetypzMlp5J0e75Fxv2tMKLKXdopAKUg2GySwNXjB1NVUX3LlWDaKFiB/BLbphifxZeLvxmUFgj3/zYBvsIahhEH4GZgeCUGnGPm5v6E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742192326; c=relaxed/simple; bh=pY8Ytozw6CNLACzJxR2R/10S+fFYQn4ueqSWacLtSzM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c4BGT/ampel04g9ZMGSDiExwnhx8vZUJVoQZ0bLAlkMIAWJpAOKJyEM9ZWAoBpDP5AQcDdNKWGVMlcn+b5OUtqK/hqgdXeizUN9nu+x+gySsWs172u0zB+xhJmZxQxg1i02oBgPFkLdupVZDQeufHUfzTVQkCovi+Y77FqiaonM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2FFCB1BF3; Sun, 16 Mar 2025 23:18:53 -0700 (PDT) Received: from a077893.blr.arm.com (a077893.blr.arm.com [10.162.16.153]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8DC983F673; Sun, 16 Mar 2025 23:18:37 -0700 (PDT) From: Anshuman Khandual To: linux-mm@kvack.org Cc: Anshuman Khandual , Catalin Marinas , Will Deacon , Steven Price , Ryan Roberts , Madhavan Srinivasan , Nicholas Piggin , Paul Walmsley , Palmer Dabbelt , Gerald Schaefer , Heiko Carstens , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, Marc Zyngier Subject: [PATCH 2/2] arm64/ptdump: Replace u64 with pteval_t Date: Mon, 17 Mar 2025 11:48:18 +0530 Message-Id: <20250317061818.16244-3-anshuman.khandual@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250317061818.16244-1-anshuman.khandual@arm.com> References: <20250317061818.16244-1-anshuman.khandual@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Page table entry's value, mask and protection are represented with pteval_t data type format not u64 that has been assumed while dumping the page table entries. Replace all such u64 instances with pteval_t instead as required. Cc: Catalin Marinas Cc: Will Deacon Cc: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual --- arch/arm64/include/asm/ptdump.h | 8 ++++---- arch/arm64/mm/ptdump.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/ptdump.h b/arch/arm64/include/asm/ptdum= p.h index e5da9ce8a515..476a870489b9 100644 --- a/arch/arm64/include/asm/ptdump.h +++ b/arch/arm64/include/asm/ptdump.h @@ -24,8 +24,8 @@ struct ptdump_info { }; =20 struct ptdump_prot_bits { - u64 mask; - u64 val; + pteval_t mask; + pteval_t val; const char *set; const char *clear; }; @@ -34,7 +34,7 @@ struct ptdump_pg_level { const struct ptdump_prot_bits *bits; char name[4]; int num; - u64 mask; + pteval_t mask; }; =20 /* @@ -51,7 +51,7 @@ struct ptdump_pg_state { const struct mm_struct *mm; unsigned long start_address; int level; - u64 current_prot; + pteval_t current_prot; bool check_wx; unsigned long wx_pages; unsigned long uxn_pages; diff --git a/arch/arm64/mm/ptdump.c b/arch/arm64/mm/ptdump.c index fd1610b4fd15..a5651be95868 100644 --- a/arch/arm64/mm/ptdump.c +++ b/arch/arm64/mm/ptdump.c @@ -194,7 +194,7 @@ void note_page(struct ptdump_state *pt_st, unsigned lon= g addr, int level, struct ptdump_pg_state *st =3D container_of(pt_st, struct ptdump_pg_state= , ptdump); struct ptdump_pg_level *pg_level =3D st->pg_level; static const char units[] =3D "KMGTPE"; - u64 prot =3D 0; + pteval_t prot =3D 0; =20 /* check if the current level has been folded dynamically */ if (st->mm && ((level =3D=3D 1 && mm_p4d_folded(st->mm)) || --=20 2.25.1