• Gerald Schaefer's avatar
    s390/mm: clean up pte/pmd encoding · bc29b7ac
    Gerald Schaefer authored
    The hugetlbfs pte<->pmd conversion functions currently assume that the pmd
    bit layout is consistent with the pte layout, which is not really true.
    
    The SW read and write bits are encoded as the sequence "wr" in a pte, but
    in a pmd it is "rw". The hugetlbfs conversion assumes that the sequence
    is identical in both cases, which results in swapped read and write bits
    in the pmd. In practice this is not a problem, because those pmd bits are
    only relevant for THP pmds and not for hugetlbfs pmds. The hugetlbfs code
    works on (fake) ptes, and the converted pte bits are correct.
    
    There is another variation in pte/pmd encoding which affects dirty
    prot-none ptes/pmds. In this case, a pmd has both its HW read-only and
    invalid bit set, while it is only the invalid bit for a pte. This also has
    no effect in practice, but it should better be consistent.
    
    This patch fixes both inconsistencies by changing the SW read/write bit
    layout for pmds as well as the PAGE_NONE encoding for ptes. It also makes
    the hugetlbfs conversion functions more robust by introducing a
    move_set_bit() macro that uses the pte/pmd bit #defines instead of
    constant shifts.
    Signed-off-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
    Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
    bc29b7ac
hugetlbpage.c 6.5 KB