• Russell Currey's avatar
    powerpc/mm: Implement set_memory() routines · 1f9ad21c
    Russell Currey authored
    The set_memory_{ro/rw/nx/x}() functions are required for
    STRICT_MODULE_RWX, and are generally useful primitives to have.  This
    implementation is designed to be generic across powerpc's many MMUs.
    It's possible that this could be optimised to be faster for specific
    MMUs.
    
    This implementation does not handle cases where the caller is attempting
    to change the mapping of the page it is executing from, or if another
    CPU is concurrently using the page being altered.  These cases likely
    shouldn't happen, but a more complex implementation with MMU-specific code
    could safely handle them.
    
    On hash, the linear mapping is not kept in the linux pagetable, so this
    will not change the protection if used on that range. Currently these
    functions are not used on the linear map so just WARN for now.
    
    apply_to_existing_page_range() does not work on huge pages so for now
    disallow changing the protection of huge pages.
    
    [jpn: - Allow set memory functions to be used without Strict RWX
          - Hash: Disallow certain regions
          - Have change_page_attr() take function pointers to manipulate ptes
          - Radix: Add ptesync after set_pte_at()]
    Signed-off-by: default avatarRussell Currey <ruscur@russell.cc>
    Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
    Signed-off-by: default avatarJordan Niethe <jniethe5@gmail.com>
    Reviewed-by: default avatarDaniel Axtens <dja@axtens.net>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    Link: https://lore.kernel.org/r/20210609013431.9805-2-jniethe5@gmail.com
    1f9ad21c
Kconfig 36.7 KB