Add the page table check helpers needed for CONFIG_PAGE_TABLE_CHECK
and select ARCH_SUPPORTS_PAGE_TABLE_CHECK in Kconfig.

Alpha does not support huge pages, so pmd_user_accessible_page() and
pud_user_accessible_page() always return false. pte_user_accessible_page()
checks for present PTEs with user read access (_PAGE_URE).

Assisted-by: Claude:claude-opus-4-6
Signed-off-by: Matt Turner <[email protected]>

Update the helpers to the three-argument pxx_user_accessible_page(mm,
addr, pxx) signature introduced by commit cf8771ca4cdb ("mm/page_table_check:
Pass mm_struct to pxx_user_accessible_page()"), matching the other
architectures.
---
 arch/alpha/Kconfig               |  1 +
 arch/alpha/include/asm/pgtable.h | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 1d28fa8d3b66..da4ec8399517 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -19,6 +19,7 @@ config ALPHA
        select ARCH_NO_SG_CHAIN
        select ARCH_SUPPORTS_ATOMIC_RMW
        select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
+       select ARCH_SUPPORTS_PAGE_TABLE_CHECK
        select ARCH_USE_CMPXCHG_LOCKREF
        select FORCE_PCI
        select PCI_DOMAINS if PCI
diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
index bdff33b505bc..6ebdd90f3035 100644
--- a/arch/alpha/include/asm/pgtable.h
+++ b/arch/alpha/include/asm/pgtable.h
@@ -232,6 +232,25 @@ extern inline void pud_clear(pud_t * pudp) { 
pud_val(*pudp) = 0; }
 extern inline int pte_write(pte_t pte)         { return !(pte_val(pte) & 
_PAGE_FOW); }
 extern inline int pte_dirty(pte_t pte)         { return pte_val(pte) & 
_PAGE_DIRTY; }
 extern inline int pte_young(pte_t pte)         { return pte_val(pte) & 
_PAGE_ACCESSED; }
+extern inline int pte_user(pte_t pte)          { return pte_val(pte) & 
_PAGE_URE; }
+
+static inline bool pte_user_accessible_page(struct mm_struct *mm,
+                                            unsigned long addr, pte_t pte)
+{
+       return pte_present(pte) && pte_user(pte);
+}
+
+static inline bool pmd_user_accessible_page(struct mm_struct *mm,
+                                            unsigned long addr, pmd_t pmd)
+{
+       return false;
+}
+
+static inline bool pud_user_accessible_page(struct mm_struct *mm,
+                                            unsigned long addr, pud_t pud)
+{
+       return false;
+}
 
 extern inline pte_t pte_wrprotect(pte_t pte)   { pte_val(pte) |= _PAGE_FOW; 
return pte; }
 extern inline pte_t pte_mkclean(pte_t pte)     { pte_val(pte) &= 
~(__DIRTY_BITS); return pte; }

-- 
2.54.0


Reply via email to