• Catalin Marinas's avatar
    arm64: Update PTE_RDONLY in set_pte_at() for PROT_NONE permission · a47d746e
    Catalin Marinas authored
    commit fdc69e7d upstream.
    
    The set_pte_at() function must update the hardware PTE_RDONLY bit
    depending on the state of the PTE_WRITE and PTE_DIRTY bits of the given
    entry value. However, it currently only performs this for pte_valid()
    entries, ignoring PTE_PROT_NONE. The side-effect is that PROT_NONE
    mappings would not have the PTE_RDONLY bit set. Without
    CONFIG_ARM64_HW_AFDBM, this is not an issue since such PROT_NONE pages
    are not accessible anyway.
    
    With commit 2f4b829c ("arm64: Add support for hardware updates of
    the access and dirty pte bits"), the ptep_set_wrprotect() function was
    re-written to cope with automatic hardware updates of the dirty state.
    As an optimisation, only PTE_RDONLY is checked to assess the "dirty"
    status. Since set_pte_at() does not set this bit for PROT_NONE mappings,
    such pages may be considered "dirty" as a result of
    ptep_set_wrprotect().
    
    This patch updates the pte_valid() check to pte_present() in
    set_pte_at(). It also adds PTE_PROT_NONE to the swap entry bits comment.
    
    Fixes: 2f4b829c ("arm64: Add support for hardware updates of the access and dirty pte bits")
    Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
    Reported-by: default avatarGanapatrao Kulkarni <gkulkarni@caviumnetworks.com>
    Tested-by: default avatarGanapatrao Kulkarni <gkulkarni@cavium.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    a47d746e
pgtable.h 21.3 KB