• Christophe Leroy's avatar
    arm64, powerpc, riscv, s390, x86: ptdump: refactor CONFIG_DEBUG_WX · a5e8131a
    Christophe Leroy authored
    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/a59b102d7964261d31ead0316a9f18...
    a5e8131a
mmu_decl.h 5.07 KB