All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL
@ 2026-10-08 19:17 Rosen Penev
  2026-10-09 10:12 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ 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 related	[flat|nested] 5+ 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 10:12 ` kernel test robot
  2026-10-09 19:13 ` Nathan Chancellor
  2026-10-09 20:51 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-10-09 10:12 UTC (permalink / raw)
  To: Rosen Penev, sparclinux

Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on v7.3-rc6]
[also build test ERROR on linus/master next-20261008]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/sparc64-Define-p4d_page-instead-of-stubbing-it-to-NULL/20261008-121711
base:   v7.3-rc6
patch link:    https://lore.kernel.org/r/20261008191711.223236-1-rosenp%40gmail.com
patch subject: [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL
config: sparc64-defconfig (https://download.01.org/0day-ci/archive/20261009/202610091839.WCEBCL4p-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 242243a5814307de825db3428662d67b064e2cbc)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261009/202610091839.WCEBCL4p-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610091839.WCEBCL4p-lkp@intel.com/

All errors (new ones prefixed by >>):

>> mm/vmalloc.c:849:10: error: expected expression
     849 |                 return p4d_page(*p4d) + ((addr & ~P4D_MASK) >> PAGE_SHIFT);
         |                        ^
   arch/sparc/include/asm/pgtable_64.h:864:25: note: expanded from macro 'p4d_page'
     864 | #define p4d_page(p4d)                   static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
         |                                         ^
   1 error generated.


vim +849 mm/vmalloc.c

73bdf0a60e607f Linus Torvalds    2008-10-15  816  
48667e7a43c1a1 Christoph Lameter 2008-02-04  817  /*
c0eb315ad9719e Nicholas Piggin   2021-04-29  818   * Walk a vmap address to the struct page it maps. Huge vmap mappings will
c0eb315ad9719e Nicholas Piggin   2021-04-29  819   * return the tail page that corresponds to the base page address, which
c0eb315ad9719e Nicholas Piggin   2021-04-29  820   * matches small vmap mappings.
48667e7a43c1a1 Christoph Lameter 2008-02-04  821   */
add688fbd32158 malc              2014-01-27  822  struct page *vmalloc_to_page(const void *vmalloc_addr)
48667e7a43c1a1 Christoph Lameter 2008-02-04  823  {
48667e7a43c1a1 Christoph Lameter 2008-02-04  824  	unsigned long addr = (unsigned long) vmalloc_addr;
add688fbd32158 malc              2014-01-27  825  	struct page *page = NULL;
48667e7a43c1a1 Christoph Lameter 2008-02-04  826  	pgd_t *pgd = pgd_offset_k(addr);
c2febafc67734a Kiryl Shutsemau   2017-03-09  827  	p4d_t *p4d;
c2febafc67734a Kiryl Shutsemau   2017-03-09  828  	pud_t *pud;
c2febafc67734a Kiryl Shutsemau   2017-03-09  829  	pmd_t *pmd;
c2febafc67734a Kiryl Shutsemau   2017-03-09  830  	pte_t *ptep, pte;
48667e7a43c1a1 Christoph Lameter 2008-02-04  831  
7aa413def76146 Ingo Molnar       2008-06-19  832  	/*
7aa413def76146 Ingo Molnar       2008-06-19  833  	 * XXX we might need to change this if we add VIRTUAL_BUG_ON for
7aa413def76146 Ingo Molnar       2008-06-19  834  	 * architectures that do not vmalloc module space
7aa413def76146 Ingo Molnar       2008-06-19  835  	 */
73bdf0a60e607f Linus Torvalds    2008-10-15  836  	VIRTUAL_BUG_ON(!is_vmalloc_or_module_addr(vmalloc_addr));
59ea746337c69f Jiri Slaby        2008-06-12  837  
c2febafc67734a Kiryl Shutsemau   2017-03-09  838  	if (pgd_none(*pgd))
c2febafc67734a Kiryl Shutsemau   2017-03-09  839  		return NULL;
c0eb315ad9719e Nicholas Piggin   2021-04-29  840  	if (WARN_ON_ONCE(pgd_leaf(*pgd)))
c0eb315ad9719e Nicholas Piggin   2021-04-29  841  		return NULL; /* XXX: no allowance for huge pgd */
c0eb315ad9719e Nicholas Piggin   2021-04-29  842  	if (WARN_ON_ONCE(pgd_bad(*pgd)))
c0eb315ad9719e Nicholas Piggin   2021-04-29  843  		return NULL;
c0eb315ad9719e Nicholas Piggin   2021-04-29  844  
c2febafc67734a Kiryl Shutsemau   2017-03-09  845  	p4d = p4d_offset(pgd, addr);
c2febafc67734a Kiryl Shutsemau   2017-03-09  846  	if (p4d_none(*p4d))
c2febafc67734a Kiryl Shutsemau   2017-03-09  847  		return NULL;
c0eb315ad9719e Nicholas Piggin   2021-04-29  848  	if (p4d_leaf(*p4d))
c0eb315ad9719e Nicholas Piggin   2021-04-29 @849  		return p4d_page(*p4d) + ((addr & ~P4D_MASK) >> PAGE_SHIFT);
c0eb315ad9719e Nicholas Piggin   2021-04-29  850  	if (WARN_ON_ONCE(p4d_bad(*p4d)))
c0eb315ad9719e Nicholas Piggin   2021-04-29  851  		return NULL;
029c54b0959957 Ard Biesheuvel    2017-06-23  852  
c0eb315ad9719e Nicholas Piggin   2021-04-29  853  	pud = pud_offset(p4d, addr);
c0eb315ad9719e Nicholas Piggin   2021-04-29  854  	if (pud_none(*pud))
c0eb315ad9719e Nicholas Piggin   2021-04-29  855  		return NULL;
c0eb315ad9719e Nicholas Piggin   2021-04-29  856  	if (pud_leaf(*pud))
c0eb315ad9719e Nicholas Piggin   2021-04-29  857  		return pud_page(*pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
c0eb315ad9719e Nicholas Piggin   2021-04-29  858  	if (WARN_ON_ONCE(pud_bad(*pud)))
c2febafc67734a Kiryl Shutsemau   2017-03-09  859  		return NULL;
c0eb315ad9719e Nicholas Piggin   2021-04-29  860  
c2febafc67734a Kiryl Shutsemau   2017-03-09  861  	pmd = pmd_offset(pud, addr);
c0eb315ad9719e Nicholas Piggin   2021-04-29  862  	if (pmd_none(*pmd))
c0eb315ad9719e Nicholas Piggin   2021-04-29  863  		return NULL;
c0eb315ad9719e Nicholas Piggin   2021-04-29  864  	if (pmd_leaf(*pmd))
c0eb315ad9719e Nicholas Piggin   2021-04-29  865  		return pmd_page(*pmd) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
c0eb315ad9719e Nicholas Piggin   2021-04-29  866  	if (WARN_ON_ONCE(pmd_bad(*pmd)))
c2febafc67734a Kiryl Shutsemau   2017-03-09  867  		return NULL;
db64fe02258f15 Nicholas Piggin   2008-10-18  868  
0d1c81edc61e55 Hugh Dickins      2023-06-08  869  	ptep = pte_offset_kernel(pmd, addr);
c33c794828f212 Ryan Roberts      2023-06-12  870  	pte = ptep_get(ptep);
48667e7a43c1a1 Christoph Lameter 2008-02-04  871  	if (pte_present(pte))
add688fbd32158 malc              2014-01-27  872  		page = pte_page(pte);
c0eb315ad9719e Nicholas Piggin   2021-04-29  873  
add688fbd32158 malc              2014-01-27  874  	return page;
48667e7a43c1a1 Christoph Lameter 2008-02-04  875  }
add688fbd32158 malc              2014-01-27  876  EXPORT_SYMBOL(vmalloc_to_page);
48667e7a43c1a1 Christoph Lameter 2008-02-04  877  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ 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 10:12 ` kernel test robot
@ 2026-10-09 19:13 ` Nathan Chancellor
  2026-10-09 21:33   ` Rosen Penev
  2026-10-09 20:51 ` kernel test robot
  2 siblings, 1 reply; 5+ 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] 5+ 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 10:12 ` kernel test robot
  2026-10-09 19:13 ` Nathan Chancellor
@ 2026-10-09 20:51 ` kernel test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-10-09 20:51 UTC (permalink / raw)
  To: Rosen Penev, sparclinux

Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on v7.3-rc6]
[also build test ERROR on linus/master next-20261008]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/sparc64-Define-p4d_page-instead-of-stubbing-it-to-NULL/20261008-121711
base:   v7.3-rc6
patch link:    https://lore.kernel.org/r/20261008191711.223236-1-rosenp%40gmail.com
patch subject: [PATCH v2] sparc64: Define p4d_page() instead of stubbing it to NULL
config: sparc-randconfig-1000-20261010 (https://download.01.org/0day-ci/archive/20261010/202610100432.gMvyFk85-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261010/202610100432.gMvyFk85-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202610100432.gMvyFk85-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from arch/sparc/include/asm/pgtable.h:5,
                    from include/linux/pgtable.h:6,
                    from include/linux/mm.h:31,
                    from mm/vmalloc.c:12:
   mm/vmalloc.c: In function 'vmalloc_to_page':
>> arch/sparc/include/asm/pgtable_64.h:864:25: error: expected expression before 'static'
    #define p4d_page(p4d)   static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
                            ^~~~~~
   mm/vmalloc.c:849:10: note: in expansion of macro 'p4d_page'
      return p4d_page(*p4d) + ((addr & ~P4D_MASK) >> PAGE_SHIFT);
             ^~~~~~~~


vim +/static +864 arch/sparc/include/asm/pgtable_64.h

   862	
   863	/* only used by the stubbed out hugetlb gup code, should never be called */
 > 864	#define p4d_page(p4d)			static inline struct page *p4d_page(p4d_t p4d) { return NULL; }
   865	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 5+ 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; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2026-10-09 21:33 UTC | newest]

Thread overview: 5+ 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 10:12 ` kernel test robot
2026-10-09 19:13 ` Nathan Chancellor
2026-10-09 21:33   ` Rosen Penev
2026-10-09 20:51 ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.