Re: [PATCH] sparc64: Define p4d_page() instead of stubbing it to NULL
From: Nathan Chancellor
Date: Tue Oct 06 2026 - 04:32:06 EST
On Tue, Oct 06, 2026 at 09:59:19AM +0200, Kjetil Oftedal wrote:
> On Mon, 5 Oct 2026 at 22:41, Rosen Penev <rosenp@xxxxxxxxx> 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.
> >
>
> Has this been reported as a bug to the clang project?
> As it throwing an error on a rather obviously unreachable branch.
Technically the error part is self-inflicted on the part of the kernel
since allmodconfig enables CONFIG_WERROR. That said, while it might be
nice for the compiler not to warn in any case of dead code, that's just
not how it works for either GCC or clang (none of these should be
visible if that were the case):
https://godbolt.org/z/K3nfW4n5f
--
Cheers,
Nathan