Skip to content

Commit 76c714b

Browse files
committed
arm64: pgtable: implement pte_accessible()
This patch implements the pte_accessible() macro, which can be used to test whether or not a given pte is a candidate for allocation in the TLB. Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent 9c4e08a commit 76c714b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

arch/arm64/include/asm/pgtable.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ extern struct page *empty_zero_page;
167167
((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
168168
#define pte_valid_not_user(pte) \
169169
((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
170+
#define pte_valid_young(pte) \
171+
((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
172+
173+
/*
174+
* Could the pte be present in the TLB? We must check mm_tlb_flush_pending
175+
* so that we don't erroneously return false for pages that have been
176+
* remapped as PROT_NONE but are yet to be flushed from the TLB.
177+
*/
178+
#define pte_accessible(mm, pte) \
179+
(mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid_young(pte))
170180

171181
static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
172182
{

0 commit comments

Comments
 (0)