FAILED: patch "[PATCH] arm64: pgtable: Ensure dirty bit is preserved across" failed to apply to 4.9-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 4.9-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ff1712f953e27f0b0718762ec17d0adb15c9fd0b Mon Sep 17 00:00:00 2001
From: Will Deacon <[email protected]>
Date: Fri, 20 Nov 2020 13:57:48 +0000
Subject: [PATCH] arm64: pgtable: Ensure dirty bit is preserved across
pte_wrprotect()
With hardware dirty bit management, calling pte_wrprotect() on a writable, dirty PTE will lose the dirty state and return a read-only, clean entry.
Move the logic from ptep_set_wrprotect() into pte_wrprotect() to ensure that the dirty bit is preserved for writable entries, as this is required for soft-dirty bit management if we enable it in the future.
arch/arm64/include/asm/pgtable.h +14 -13
@@ -165,13 +165,6 @@ static inline pmd_t set_pmd_bit(pmd_t pmd, pgprot_t prot)return pmd; } -static inline pte_t pte_wrprotect (pte_t pte) -{ - pte =clear_pte_bit (pte,__pgprot (PTE_WRITE )); - pte =set_pte_bit (pte,__pgprot (PTE_RDONLY )); -return pte; -} -static inline pte_t pte_mkwrite (pte_t pte) { pte =set_pte_bit (pte,__pgprot (PTE_WRITE ));
@@ -197,6 +190,20 @@ static inline pte_t pte_mkdirty(pte_t pte)return pte; } +static inline pte_t pte_wrprotect (pte_t pte) +{ +/* +* If hardware-dirty (PTE_WRITE/DBM bit set and PTE_RDONLY +* clear), set the PTE_DIRTY bit. +*/ +if (pte_hw_dirty (pte)) + pte =pte_mkdirty (pte); + + pte =clear_pte_bit (pte,__pgprot (PTE_WRITE )); + pte =set_pte_bit (pte,__pgprot (PTE_RDONLY )); +return pte; +} +static inline pte_t pte_mkold (pte_t pte) {return clear_pte_bit (pte,__pgprot (PTE_AF ));
@@ -846,12 +853,6 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres pte =READ_ONCE (*ptep); do { old_pte = pte; - /* - * If hardware-dirty (PTE_WRITE/DBM bit set and PTE_RDONLY - * clear), set the PTE_DIRTY bit. - */ - if (pte_hw_dirty(pte)) - pte = pte_mkdirty(pte); pte = pte_wrprotect(pte); pte_val(pte) = cmpxchg_relaxed(&pte_val(*ptep), pte_val(old_pte), pte_val(pte));