arm64: pgtable: implement pte_accessible()
authorWill Deacon <will.deacon@arm.com>
Fri, 30 Oct 2015 18:56:19 +0000 (18:56 +0000)
committerAlex Shi <alex.shi@linaro.org>
Wed, 11 May 2016 07:56:34 +0000 (15:56 +0800)
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 <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
(cherry picked from commit 76c714be0e5e60c935a53b31be58939510ba1d0f)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
arch/arm64/include/asm/pgtable.h

index c63868ae9a4a42728fd191279d10ba984816026a..cd5dfc97268e1913a3cf708d4366a62ed6bb9b0c 100644 (file)
@@ -168,6 +168,16 @@ extern struct page *empty_zero_page;
 #define pte_valid(pte)         (!!(pte_val(pte) & PTE_VALID))
 #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))
+
+/*
+ * Could the pte be present in the TLB? We must check mm_tlb_flush_pending
+ * so that we don't erroneously return false for pages that have been
+ * remapped as PROT_NONE but are yet to be flushed from the TLB.
+ */
+#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)
 {