arm64/mm: Set only the PTE_DIRTY bit while preserving the HW dirty state
PATCH 1/1 arm64/mm: Set only the PTE_DIRTY bit while preserving the HW dirty state
pte_mkdirty() creates dirty states both in SW and HW bits, which is really not required, either in pte_wrprotect() or pte_modify() for preserving the HW dirty state. Because pte_mkdirty() sets PTE_DIRTY and clears PTE_RDONLY as pte_write() always evaluates to be true - otherwise pte_hw_dirty() will not test out in the first place. Clearing PTE_RDONLY again is not required here because the pte is already in pte_hw_dirty() but might soon loose its dirty state thus requiring preservation in SW dirty bit i.e PTE_DIRTY.
---
This applies on v6.5-rc1
arch/arm64/include/asm/pgtable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/pgtable.h +3 -2
@@ -212,7 +212,7 @@ static inline pte_t pte_wrprotect(pte_t pte)* clear), set the PTE_DIRTY bit. */ if (pte_hw_dirty (pte)) - pte =pte_mkdirty (pte); + pte =set_pte_bit (pte,__pgprot (PTE_DIRTY )); pte =clear_pte_bit (pte,__pgprot (PTE_WRITE )); pte =set_pte_bit (pte,__pgprot (PTE_RDONLY ));
@@ -823,7 +823,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)PTE_ATTRINDX_MASK ;/* preserve the hardware dirty information */ if (pte_hw_dirty (pte)) - pte =pte_mkdirty (pte); + pte =set_pte_bit (pte,__pgprot (PTE_DIRTY )); +pte_val (pte) = (pte_val (pte) & ~mask) | (pgprot_val (newprot) & mask);return pte; }
Signature · 1 line
2.30.2
Quoted 34 lines · Anshuman Khandual
pte_mkdirty()creates dirty states both in SW and HW bits, which is really not required, either inpte_wrprotect()orpte_modify()for preserving the HW dirty state. Becausepte_mkdirty()setsPTE_DIRTYand clearsPTE_RDONLYaspte_write()always evaluates to be true - otherwisepte_hw_dirty()will not test out in the first place. ClearingPTE_RDONLYagain is not required here because the pte is already inpte_hw_dirty()but might soon loose its dirty state thus requiring preservation in SW dirty bit i.ePTE_DIRTY.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
This applies on v6.5-rc1arch/arm64/include/asm/pgtable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)arch/arm64/include/asm/pgtable.h +1
-1@@ -212,7 +212,7 @@ static inline pte_t pte_wrprotect(pte_t pte)* clear), set the PTE_DIRTY bit. */ if (pte_hw_dirty (pte)) - pte =pte_mkdirty (pte); + pte =set_pte_bit (pte,__pgprot (PTE_DIRTY )); pte =clear_pte_bit (pte,__pgprot (PTE_WRITE )); pte =set_pte_bit (pte,__pgprot (PTE_RDONLY ));
arch/arm64/include/asm/pgtable.h static inline pte_t pte_modify(pte_t pte, pgprot_t newprot) · line 830
Quoted 9 lines
arch/arm64/include/asm/pgtable.h +2
-1@@ -823,7 +823,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)PTE_ATTRINDX_MASK ;/* preserve the hardware dirty information */ if (pte_hw_dirty (pte)) - pte =pte_mkdirty (pte); + pte =set_pte_bit (pte,__pgprot (PTE_DIRTY )); +pte_val (pte) = (pte_val (pte) & ~mask) | (pgprot_val (newprot) & mask);return pte; }
Signature · 9 lines
Cheers, David / dhildenb _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 8 lines · Anshuman Khandual
pte_mkdirty()creates dirty states both in SW and HW bits, which is really not required, either inpte_wrprotect()orpte_modify()for preserving the HW dirty state. Becausepte_mkdirty()setsPTE_DIRTYand clearsPTE_RDONLYaspte_write()always evaluates to be true - otherwisepte_hw_dirty()will not test out in the first place. ClearingPTE_RDONLYagain is not required here because the pte is already inpte_hw_dirty()but might soon loose its dirty state thus requiring preservation in SW dirty bit i.ePTE_DIRTY.
Quoted 6 lines
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mark Rutland <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Quoted 9 lines · Anshuman Khandual
pte_mkdirty()creates dirty states both in SW and HW bits, which is really not required, either inpte_wrprotect()orpte_modify()for preserving the HW dirty state. Becausepte_mkdirty()setsPTE_DIRTYand clearsPTE_RDONLYaspte_write()always evaluates to be true - otherwisepte_hw_dirty()will not test out in the first place. ClearingPTE_RDONLYagain is not required here because the pte is already inpte_hw_dirty()but might soon loose its dirty state thus requiring preservation in SW dirty bit i.ePTE_DIRTY.[...]
Applied to arm64 (for-next/mm), thanks!
[1/1] arm64/mm: Set only the PTE_DIRTY bit while preserving the HW dirty state
https://git.kernel.org/arm64/c/6477c3886ae1
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev