[RFC PATCH 3/4] mm: introduce __ptent sparse attribute

From: Alexander Gordeev

Date: Fri Jul 17 2026 - 09:35:03 EST


Introduce a new __ptent sparse attribute to enable type checking for
page table entries. This attribute would mark architecture-specific
pte_t type, whose pointers should only be accessed through proper
accessors, such like ptep_get(), set_pte() etc.

The corresponding sparse tool rework for this attribute is required
to cause the "dereference of PTE pointer" warning.

Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx>
---
include/linux/compiler_types.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index c5921f139007..472af4fb2546 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -58,6 +58,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
# define __nocast __attribute__((nocast))
# define __safe __attribute__((safe))
# define __private __attribute__((noderef))
+# define __ptent __attribute__((ptent))
# define ACCESS_PRIVATE(p, member) (*((typeof((p)->member) __force *) &(p)->member))
#else /* __CHECKER__ */
/* address spaces */
@@ -78,6 +79,7 @@ static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }
# define __nocast
# define __safe
# define __private
+# define __ptent
# define ACCESS_PRIVATE(p, member) ((p)->member)
# define __builtin_warning(x, y...) (1)
#endif /* __CHECKER__ */
--
2.53.0