Skip to content

Commit 6477c38

Browse files
Anshuman Khandualwilldeacon
authored andcommitted
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. Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Mark Rutland <[email protected]> Cc: [email protected] Cc: [email protected] Signed-off-by: Anshuman Khandual <[email protected]> Reviewed-by: David Hildenbrand <[email protected]> Acked-by: Catalin Marinas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent d0ba961 commit 6477c38

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static inline pte_t pte_wrprotect(pte_t pte)
213213
* clear), set the PTE_DIRTY bit.
214214
*/
215215
if (pte_hw_dirty(pte))
216-
pte = pte_mkdirty(pte);
216+
pte = set_pte_bit(pte, __pgprot(PTE_DIRTY));
217217

218218
pte = clear_pte_bit(pte, __pgprot(PTE_WRITE));
219219
pte = set_pte_bit(pte, __pgprot(PTE_RDONLY));
@@ -824,7 +824,8 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
824824
PTE_ATTRINDX_MASK;
825825
/* preserve the hardware dirty information */
826826
if (pte_hw_dirty(pte))
827-
pte = pte_mkdirty(pte);
827+
pte = set_pte_bit(pte, __pgprot(PTE_DIRTY));
828+
828829
pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
829830
return pte;
830831
}

0 commit comments

Comments
 (0)