* [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL
@ 2026-10-08 19:17 Rosen Penev
2026-10-09 19:13 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Rosen Penev @ 2026-10-08 19:17 UTC (permalink / raw)
To: sparclinux
Cc: David S. Miller, Andreas Larsson, Nathan Chancellor,
Nick Desaulniers, Bill Wendling, Justin Stitt, open list,
open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b
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
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v2: use a NULL function instead.
arch/sparc/include/asm/pgtable_64.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index 35a217bf6e5c..54e563eb0efd 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -851,7 +851,7 @@ 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) static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
#define pud_leaf pud_leaf
static inline bool pud_leaf(pud_t pud)
--
2.56.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL
2026-10-08 19:17 [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL Rosen Penev
@ 2026-10-09 19:13 ` Nathan Chancellor
2026-10-09 21:33 ` Rosen Penev
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2026-10-09 19:13 UTC (permalink / raw)
To: Rosen Penev
Cc: sparclinux, David S. Miller, Andreas Larsson, Nick Desaulniers,
Bill Wendling, Justin Stitt, open list,
open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b
On Thu, Oct 08, 2026 at 12:17:11PM -0700, Rosen Penev wrote:
> 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
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
> v2: use a NULL function instead.
> arch/sparc/include/asm/pgtable_64.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
> index 35a217bf6e5c..54e563eb0efd 100644
> --- a/arch/sparc/include/asm/pgtable_64.h
> +++ b/arch/sparc/include/asm/pgtable_64.h
> @@ -851,7 +851,7 @@ 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) static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
Huh? Why did you keep the macro instead of replacing it with the static
inline function wholesale? This should have just be
-#define p4d_page(p4d) NULL
+static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
no?
> #define pud_leaf pud_leaf
> static inline bool pud_leaf(pud_t pud)
> --
> 2.56.0
>
--
Cheers,
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL
2026-10-09 19:13 ` Nathan Chancellor
@ 2026-10-09 21:33 ` Rosen Penev
0 siblings, 0 replies; 3+ messages in thread
From: Rosen Penev @ 2026-10-09 21:33 UTC (permalink / raw)
To: Nathan Chancellor
Cc: sparclinux, David S. Miller, Andreas Larsson, Nick Desaulniers,
Bill Wendling, Justin Stitt, open list,
open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b
On Fri, Oct 9, 2026 at 12:13 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> On Thu, Oct 08, 2026 at 12:17:11PM -0700, Rosen Penev wrote:
> > 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
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > ---
> > v2: use a NULL function instead.
> > arch/sparc/include/asm/pgtable_64.h | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
> > index 35a217bf6e5c..54e563eb0efd 100644
> > --- a/arch/sparc/include/asm/pgtable_64.h
> > +++ b/arch/sparc/include/asm/pgtable_64.h
> > @@ -851,7 +851,7 @@ 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) static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
>
> Huh? Why did you keep the macro instead of replacing it with the static
> inline function wholesale? This should have just be
>
> -#define p4d_page(p4d) NULL
> +static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
>
> no?
Was not thinking. I sent a v3 and actually tested compilation this time.
>
> > #define pud_leaf pud_leaf
> > static inline bool pud_leaf(pud_t pud)
> > --
> > 2.56.0
> >
>
> --
> Cheers,
> Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-09 21:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 19:17 [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL Rosen Penev
2026-10-09 19:13 ` Nathan Chancellor
2026-10-09 21:33 ` Rosen Penev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®