aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCatalin Marinas <catalin.marinas@arm.com>2015-09-11 13:22:00 -0400
committerWill Deacon <will.deacon@arm.com>2015-09-14 07:28:31 -0400
commitb847415ce96efef819534b230d84695b1bc6d36b (patch)
tree2a1d016f5eaae2b9d00fa1d5d2e06a64b73e105c
parentba9cc453c400049f632d4eb2f2835e2f96654ddc (diff)
arm64: Fix the pte_hw_dirty() check when AF/DBM is enabled
Commit 2f4b829c625e ("arm64: Add support for hardware updates of the access and dirty pte bits") introduced support for handling hardware updates of the access flag and dirty status. The PTE is automatically dirtied in hardware (if supported) by clearing the PTE_RDONLY bit when the PTE_DBM/PTE_WRITE bit is set. The pte_hw_dirty() macro was added to detect a hardware dirtied pte. The pte_dirty() macro checks for both software PTE_DIRTY and pte_hw_dirty(). Functions like pte_modify() clear the PTE_RDONLY bit since it is meant to be set in set_pte_at() when written to memory. In such cases, pte_hw_dirty() would return true even though such pte is clean. This patch changes pte_hw_dirty() to test the PTE_DBM/PTE_WRITE bit together with PTE_RDONLY. Fixes: 2f4b829c625e ("arm64: Add support for hardware updates of the access and dirty pte bits") Reported-by: Julien Grall <julien.grall@citrix.com> Tested-by: Julien Grall <julien.grall@citrix.com> Tested-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
-rw-r--r--arch/arm64/include/asm/pgtable.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index 6900b2d95371..69207f016891 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -146,7 +146,7 @@ extern struct page *empty_zero_page;
146#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN)) 146#define pte_exec(pte) (!(pte_val(pte) & PTE_UXN))
147 147
148#ifdef CONFIG_ARM64_HW_AFDBM 148#ifdef CONFIG_ARM64_HW_AFDBM
149#define pte_hw_dirty(pte) (!(pte_val(pte) & PTE_RDONLY)) 149#define pte_hw_dirty(pte) (pte_write(pte) && !(pte_val(pte) & PTE_RDONLY))
150#else 150#else
151#define pte_hw_dirty(pte) (0) 151#define pte_hw_dirty(pte) (0)
152#endif 152#endif
@@ -238,7 +238,7 @@ extern void __sync_icache_dcache(pte_t pteval, unsigned long addr);
238 * When hardware DBM is not present, the sofware PTE_DIRTY bit is updated via 238 * When hardware DBM is not present, the sofware PTE_DIRTY bit is updated via
239 * the page fault mechanism. Checking the dirty status of a pte becomes: 239 * the page fault mechanism. Checking the dirty status of a pte becomes:
240 * 240 *
241 * PTE_DIRTY || !PTE_RDONLY 241 * PTE_DIRTY || (PTE_WRITE && !PTE_RDONLY)
242 */ 242 */
243static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 243static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
244 pte_t *ptep, pte_t pte) 244 pte_t *ptep, pte_t pte)