• David Hildenbrand's avatar
    sparc/mm: don't unconditionally set HW writable bit when setting PTE dirty on 64bit · fa2e71a6
    David Hildenbrand authored
    On sparc64, there is no HW modified bit, therefore, SW tracks via a SW bit
    if the PTE is dirty via pte_mkdirty().  However, pte_mkdirty() currently
    also unconditionally sets the HW writable bit, which is wrong.
    
    pte_mkdirty() is not supposed to make a PTE actually writable, unless the
    SW writable bit -- pte_write() -- indicates that the PTE is not
    write-protected.  Fortunately, sparc64 also defines a SW writable bit.
    
    For example, this already turned into a problem in the context of THP
    splitting as documented in commit 624a2c94 ("Partly revert "mm/thp:
    carry over dirty bit when thp splits on pmd""), and for page migration, as
    documented in commit 96a9c287 ("mm/migrate: fix wrongly apply write
    bit after mkdirty on sparc64").
    
    Also, we might want to use the dirty PTE bit in the context of KSM with
    shared zeropage [1], whereby setting the page writable would be
    problematic.
    
    But more general, any code that might end ...
    fa2e71a6
pgtable_64.h 32.5 KB