Skip to contentSkip to conversation

arm64: pgtable: implement pte_accessible()

PATCH New Will Deacon 2 participants 2 messages Nov 17, 2015 – Nov 18, 2015 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 arch/arm64/include/asm/pgtable.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/include/asm/pgtable.h +5 -0
index b3f04393e0f1..3850ae460ee7 100644
@@ -167,6 +167,11 @@ extern struct page *empty_zero_page;
 	((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
 #define pte_valid_not_user(pte) \
 	((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
+#define pte_valid_young(pte) \
+	((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
+
+#define pte_accessible(mm, pte)	\
+	(mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid_young(pte))
 
 static inline pte_t clear_pte_bit(pte_t pte, pgprot_t prot)
 {
Signature · 1 line
2.1.4
maintainer
#1 lore raw

PATCH 1/1 arm64: pgtable: implement pte_accessible()

Quoted 14 lines · Will Deacon

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.

---
 arch/arm64/include/asm/pgtable.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/include/asm/pgtable.h +0 -0
index b3f04393e0f1..3850ae460ee7 100644

arch/arm64/include/asm/pgtable.h extern struct page *empty_zero_page; · line 174

Quoted 8 lines
arch/arm64/include/asm/pgtable.h +5 -0
@@ -167,6 +167,11 @@ extern struct page *empty_zero_page;
 	((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER))
 #define pte_valid_not_user(pte) \
 	((pte_val(pte) & (PTE_VALID | PTE_USER)) == PTE_VALID)
+#define pte_valid_young(pte) \
+	((pte_val(pte) & (PTE_VALID | PTE_AF)) == (PTE_VALID | PTE_AF))
+
+#define pte_accessible(mm, pte)	\
+	(mm_tlb_flush_pending(mm) ? pte_present(pte) : pte_valid_young(pte))

However, it would be nice to add a comment on the need for mm_tlb_flush_pending() check. We may look at this in the future and won't remember.

Signature · 1 line
Catalin