[RFC PATCH 3/4] mm: introduce __ptent sparse attribute
Alexander Gordeev <[email protected]> Fri, 17 Jul 2026 15:32:21 +0200
| Newsgroups | org.kernel.vger.linux-sparse,org.kernel.vger.linux-kernel,org.kernel.vger.linux-s390,org.kvack.linux-mm |
|---|---|
| Message-ID | <80bfffc76cb5a270aeabda26f50f65d10742a1df.1784292223.git.agordeev@linux.ibm.com> |
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 <[email protected]> --- include/linux/compiler_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_type= s.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 __i= omem *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 __i= omem *ptr) { } # define __nocast # define __safe # define __private +# define __ptent # define ACCESS_PRIVATE(p, member) ((p)->member) # define __builtin_warning(x, y...) (1) #endif /* __CHECKER__ */ --=20 2.53.0