Skip to contentSkip to conversation

sparc64: Define p4d_page() instead of stubbing it to NULL

PATCH New Rosen Penev 1 participant 1 message Oct 9 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 sparc64: Define p4d_page() instead of stubbing it to NULL

A sparc64 allmodconfig build with LLVM fails in vmalloc_to_page():

mm/vmalloc.c: error: performing pointer arithmetic on a null pointer has undefined behavior [-Werror,-Wnull-pointer-arithmetic]

sparc64 defines p4d_page() as NULL, on the assumption that it is only used by stubbed out hugetlb gup code. Generic code now uses it in vmalloc_to_page(), ptdump and KASAN. In vmalloc_to_page() the NULL is used in pointer arithmetic, which clang diagnoses even though the branch is unreachable on sparc64.

Define p4d_page() as a NULL function to silence clang's warning on an unreachable branch. sparc64 has no p4d leaf mappings, so there is no functional change.

Assisted-by LLM

---
v3: do it properly.
v2: use a NULL function instead.

 arch/sparc/include/asm/pgtable_64.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
arch/sparc/include/asm/pgtable_64.h +5 -1
index 35a217bf6e5c..bd4fc65e4bfe 100644
@@ -851,7 +851,11 @@ static inline pmd_t *pud_pgtable(pud_t pud)
 #define p4d_clear(p4dp)			(p4d_val(*(p4dp)) = 0UL)
 
 /* only used by the stubbed out hugetlb gup code, should never be called */
-#define p4d_page(p4d)			NULL
+#define p4d_page p4d_page
+static inline struct page *p4d_page(p4d_t p4d)
+{
+	return NULL;
+}
 
 #define pud_leaf pud_leaf
 static inline bool pud_leaf(pud_t pud)
Signature · 1 line
2.56.0