arm64, powerpc, riscv, s390, x86: ptdump: refactor CONFIG_DEBUG_WX
All architectures using the core ptdump functionality also implement CONFIG_DEBUG_WX, and they all do it more or less the same way, with a function called debug_checkwx() that is called by mark_rodata_ro(), which is a substitute to ptdump_check_wx() when CONFIG_DEBUG_WX is set and a no-op otherwise. Refactor by centrally defining debug_checkwx() in linux/ptdump.h and call debug_checkwx() immediately after calling mark_rodata_ro() instead of calling it at the end of every mark_rodata_ro(). On x86_32, mark_rodata_ro() first checks __supported_pte_mask has _PAGE_NX before calling debug_checkwx(). Now the check is inside the callee ptdump_walk_pgd_level_checkwx(). On powerpc_64, mark_rodata_ro() bails out early before calling ptdump_check_wx() when the MMU doesn't have KERNEL_RO feature. The check is now also done in ptdump_check_wx() as it is called outside mark_rodata_ro(). Link: https://lkml.kernel.org/r/a59b102d7964261d31ead0316a9f18628e4e7a8e.1706610398.git.christophe.leroy@csgroup.eu Signed-off-by:Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by:
Alexandre Ghiti <alexghiti@rivosinc.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: "Aneesh Kumar K.V (IBM)" <aneesh.kumar@kernel.org> Cc: Borislav Petkov (AMD) <bp@alien8.de> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Christian Borntraeger <borntraeger@linux.ibm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com> Cc: Greg KH <greg@kroah.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com> Cc: Nicholas Piggin <npiggin@gmail.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Phong Tran <tranmanphong@gmail.com> Cc: Russell King <linux@armlinux.org.uk> Cc: Steven Price <steven.price@arm.com> Cc: Sven Schnelle <svens@linux.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Vasily Gorbik <gor@linux.ibm.com> Cc: Will Deacon <will@kernel.org> Signed-off-by:
Andrew Morton <akpm@linux-foundation.org>
Showing
- arch/arm64/include/asm/ptdump.h 0 additions, 7 deletionsarch/arm64/include/asm/ptdump.h
- arch/arm64/mm/mmu.c 0 additions, 2 deletionsarch/arm64/mm/mmu.c
- arch/powerpc/mm/mmu_decl.h 0 additions, 6 deletionsarch/powerpc/mm/mmu_decl.h
- arch/powerpc/mm/pgtable_32.c 0 additions, 4 deletionsarch/powerpc/mm/pgtable_32.c
- arch/powerpc/mm/pgtable_64.c 0 additions, 3 deletionsarch/powerpc/mm/pgtable_64.c
- arch/powerpc/mm/ptdump/ptdump.c 3 additions, 0 deletionsarch/powerpc/mm/ptdump/ptdump.c
- arch/riscv/include/asm/ptdump.h 0 additions, 22 deletionsarch/riscv/include/asm/ptdump.h
- arch/riscv/mm/init.c 0 additions, 3 deletionsarch/riscv/mm/init.c
- arch/riscv/mm/ptdump.c 0 additions, 1 deletionarch/riscv/mm/ptdump.c
- arch/s390/include/asm/ptdump.h 0 additions, 14 deletionsarch/s390/include/asm/ptdump.h
- arch/s390/mm/dump_pagetables.c 0 additions, 1 deletionarch/s390/mm/dump_pagetables.c
- arch/s390/mm/init.c 0 additions, 2 deletionsarch/s390/mm/init.c
- arch/x86/include/asm/pgtable.h 1 addition, 2 deletionsarch/x86/include/asm/pgtable.h
- arch/x86/mm/dump_pagetables.c 3 additions, 0 deletionsarch/x86/mm/dump_pagetables.c
- arch/x86/mm/init_32.c 0 additions, 2 deletionsarch/x86/mm/init_32.c
- arch/x86/mm/init_64.c 0 additions, 2 deletionsarch/x86/mm/init_64.c
- include/linux/ptdump.h 7 additions, 0 deletionsinclude/linux/ptdump.h
- init/main.c 2 additions, 0 deletionsinit/main.c
Please register or sign in to comment