Generic code must always use the architecture-provided helper function
to write page tables.
Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers")
Fixes: c0fe07b0aa72 ("mm/debug_vm_pgtable: use struct pgtable_debug_args in PMD modifying tests")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---
mm/debug_vm_pgtable.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
index ae9b9310d96fd..8c7996d6c1f2a 100644
--- a/mm/debug_vm_pgtable.c
+++ b/mm/debug_vm_pgtable.c
@@ -445,7 +445,7 @@ static void __init pmd_huge_tests(struct pgtable_debug_args *args)
* X86 defined pmd_set_huge() verifies that the given
* PMD is not a populated non-leaf entry.
*/
- WRITE_ONCE(*args->pmdp, __pmd(0));
+ set_pmd(args->pmdp, __pmd(0));
WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
WARN_ON(!pmd_clear_huge(args->pmdp));
pmd = pmdp_get(args->pmdp);
@@ -465,7 +465,7 @@ static void __init pud_huge_tests(struct pgtable_debug_args *args)
* X86 defined pud_set_huge() verifies that the given
* PUD is not a populated non-leaf entry.
*/
- WRITE_ONCE(*args->pudp, __pud(0));
+ set_pud(args->pudp, __pud(0));
WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
WARN_ON(!pud_clear_huge(args->pudp));
pud = pudp_get(args->pudp);
--
2.47.2
Hi Samuel,
kernel test robot noticed the following build errors:
[auto build test ERROR on d358e5254674b70f34c847715ca509e46eb81e6f]
url: https://github.com/intel-lab-lkp/linux/commits/Samuel-Holland/mm-debug_vm_pgtable-Use-set_pXd-to-write-page-tables/20251211-161254
base: d358e5254674b70f34c847715ca509e46eb81e6f
patch link: https://lore.kernel.org/r/20251211081117.1126521-2-samuel.holland%40sifive.com
patch subject: [PATCH 1/2] mm/debug_vm_pgtable: Use set_pXd() to write page tables
config: powerpc64-randconfig-r064-20251212 (https://download.01.org/0day-ci/archive/20251212/202512121948.74kTIiJi-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 1335a05ab8bc8339ce24be3a9da89d8c3f4e0571)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251212/202512121948.74kTIiJi-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/202512121948.74kTIiJi-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/debug_vm_pgtable.c:448:2: error: call to undeclared function 'set_pmd'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
448 | set_pmd(args->pmdp, __pmd(0));
| ^
>> mm/debug_vm_pgtable.c:468:2: error: call to undeclared function 'set_pud'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
468 | set_pud(args->pudp, __pud(0));
| ^
2 errors generated.
vim +/set_pmd +448 mm/debug_vm_pgtable.c
433
434 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
435 static void __init pmd_huge_tests(struct pgtable_debug_args *args)
436 {
437 pmd_t pmd;
438
439 if (!arch_vmap_pmd_supported(args->page_prot) ||
440 args->fixed_alignment < PMD_SIZE)
441 return;
442
443 pr_debug("Validating PMD huge\n");
444 /*
445 * X86 defined pmd_set_huge() verifies that the given
446 * PMD is not a populated non-leaf entry.
447 */
> 448 set_pmd(args->pmdp, __pmd(0));
449 WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
450 WARN_ON(!pmd_clear_huge(args->pmdp));
451 pmd = pmdp_get(args->pmdp);
452 WARN_ON(!pmd_none(pmd));
453 }
454
455 static void __init pud_huge_tests(struct pgtable_debug_args *args)
456 {
457 pud_t pud;
458
459 if (!arch_vmap_pud_supported(args->page_prot) ||
460 args->fixed_alignment < PUD_SIZE)
461 return;
462
463 pr_debug("Validating PUD huge\n");
464 /*
465 * X86 defined pud_set_huge() verifies that the given
466 * PUD is not a populated non-leaf entry.
467 */
> 468 set_pud(args->pudp, __pud(0));
469 WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
470 WARN_ON(!pud_clear_huge(args->pudp));
471 pud = pudp_get(args->pudp);
472 WARN_ON(!pud_none(pud));
473 }
474 #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
475 static void __init pmd_huge_tests(struct pgtable_debug_args *args) { }
476 static void __init pud_huge_tests(struct pgtable_debug_args *args) { }
477 #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
478
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Samuel,
kernel test robot noticed the following build errors:
[auto build test ERROR on d358e5254674b70f34c847715ca509e46eb81e6f]
url: https://github.com/intel-lab-lkp/linux/commits/Samuel-Holland/mm-debug_vm_pgtable-Use-set_pXd-to-write-page-tables/20251211-161254
base: d358e5254674b70f34c847715ca509e46eb81e6f
patch link: https://lore.kernel.org/r/20251211081117.1126521-2-samuel.holland%40sifive.com
patch subject: [PATCH 1/2] mm/debug_vm_pgtable: Use set_pXd() to write page tables
config: powerpc64-randconfig-r054-20251212 (https://download.01.org/0day-ci/archive/20251212/202512120808.akRJJMa7-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 10.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251212/202512120808.akRJJMa7-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/202512120808.akRJJMa7-lkp@intel.com/
All errors (new ones prefixed by >>):
mm/debug_vm_pgtable.c: In function 'pmd_huge_tests':
>> mm/debug_vm_pgtable.c:448:2: error: implicit declaration of function 'set_pmd'; did you mean 'set_pgd'? [-Werror=implicit-function-declaration]
448 | set_pmd(args->pmdp, __pmd(0));
| ^~~~~~~
| set_pgd
mm/debug_vm_pgtable.c: In function 'pud_huge_tests':
>> mm/debug_vm_pgtable.c:468:2: error: implicit declaration of function 'set_pud'; did you mean 'set_pgd'? [-Werror=implicit-function-declaration]
468 | set_pud(args->pudp, __pud(0));
| ^~~~~~~
| set_pgd
cc1: some warnings being treated as errors
Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for CAN_DEV
Depends on [n]: NETDEVICES [=n] && CAN [=y]
Selected by [y]:
- CAN [=y] && NET [=y]
vim +448 mm/debug_vm_pgtable.c
433
434 #ifdef CONFIG_HAVE_ARCH_HUGE_VMAP
435 static void __init pmd_huge_tests(struct pgtable_debug_args *args)
436 {
437 pmd_t pmd;
438
439 if (!arch_vmap_pmd_supported(args->page_prot) ||
440 args->fixed_alignment < PMD_SIZE)
441 return;
442
443 pr_debug("Validating PMD huge\n");
444 /*
445 * X86 defined pmd_set_huge() verifies that the given
446 * PMD is not a populated non-leaf entry.
447 */
> 448 set_pmd(args->pmdp, __pmd(0));
449 WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
450 WARN_ON(!pmd_clear_huge(args->pmdp));
451 pmd = pmdp_get(args->pmdp);
452 WARN_ON(!pmd_none(pmd));
453 }
454
455 static void __init pud_huge_tests(struct pgtable_debug_args *args)
456 {
457 pud_t pud;
458
459 if (!arch_vmap_pud_supported(args->page_prot) ||
460 args->fixed_alignment < PUD_SIZE)
461 return;
462
463 pr_debug("Validating PUD huge\n");
464 /*
465 * X86 defined pud_set_huge() verifies that the given
466 * PUD is not a populated non-leaf entry.
467 */
> 468 set_pud(args->pudp, __pud(0));
469 WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
470 WARN_ON(!pud_clear_huge(args->pudp));
471 pud = pudp_get(args->pudp);
472 WARN_ON(!pud_none(pud));
473 }
474 #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */
475 static void __init pmd_huge_tests(struct pgtable_debug_args *args) { }
476 static void __init pud_huge_tests(struct pgtable_debug_args *args) { }
477 #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */
478
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On 11/12/2025 08:11, Samuel Holland wrote:
> Generic code must always use the architecture-provided helper function
> to write page tables.
>
> Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers")
> Fixes: c0fe07b0aa72 ("mm/debug_vm_pgtable: use struct pgtable_debug_args in PMD modifying tests")
> Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> ---
>
> mm/debug_vm_pgtable.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index ae9b9310d96fd..8c7996d6c1f2a 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -445,7 +445,7 @@ static void __init pmd_huge_tests(struct pgtable_debug_args *args)
> * X86 defined pmd_set_huge() verifies that the given
> * PMD is not a populated non-leaf entry.
> */
> - WRITE_ONCE(*args->pmdp, __pmd(0));
> + set_pmd(args->pmdp, __pmd(0));
My guess is that this should actually be:
pmd_clear(args->pmdp);
As the "clear" value may not be zero on some arches (see um) or there may be
more to do on other arches (see arm32's 2 level pgtable).
> WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
> WARN_ON(!pmd_clear_huge(args->pmdp));
> pmd = pmdp_get(args->pmdp);
> @@ -465,7 +465,7 @@ static void __init pud_huge_tests(struct pgtable_debug_args *args)
> * X86 defined pud_set_huge() verifies that the given
> * PUD is not a populated non-leaf entry.
> */
> - WRITE_ONCE(*args->pudp, __pud(0));
> + set_pud(args->pudp, __pud(0));
Likewise, I think this should be:
pud_clear(args->pudp);
Thanks,
Ryan
> WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
> WARN_ON(!pud_clear_huge(args->pudp));
> pud = pudp_get(args->pudp);
On Thu, Dec 11, 2025 at 09:36:27AM +0000, Ryan Roberts wrote:
> On 11/12/2025 08:11, Samuel Holland wrote:
> > Generic code must always use the architecture-provided helper function
> > to write page tables.
> >
> > Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers")
> > Fixes: c0fe07b0aa72 ("mm/debug_vm_pgtable: use struct pgtable_debug_args in PMD modifying tests")
> > Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
> > ---
> >
> > mm/debug_vm_pgtable.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> > index ae9b9310d96fd..8c7996d6c1f2a 100644
> > --- a/mm/debug_vm_pgtable.c
> > +++ b/mm/debug_vm_pgtable.c
> > @@ -445,7 +445,7 @@ static void __init pmd_huge_tests(struct pgtable_debug_args *args)
> > * X86 defined pmd_set_huge() verifies that the given
> > * PMD is not a populated non-leaf entry.
> > */
> > - WRITE_ONCE(*args->pmdp, __pmd(0));
> > + set_pmd(args->pmdp, __pmd(0));
>
> My guess is that this should actually be:
>
> pmd_clear(args->pmdp);
>
> As the "clear" value may not be zero on some arches (see um) or there may be
> more to do on other arches (see arm32's 2 level pgtable).
Yeah, seems on looooongarch too for instance there's an invalid value being set
that is later checked by e.g. pmd_none().
>
> > WARN_ON(!pmd_set_huge(args->pmdp, __pfn_to_phys(args->fixed_pmd_pfn), args->page_prot));
> > WARN_ON(!pmd_clear_huge(args->pmdp));
> > pmd = pmdp_get(args->pmdp);
> > @@ -465,7 +465,7 @@ static void __init pud_huge_tests(struct pgtable_debug_args *args)
> > * X86 defined pud_set_huge() verifies that the given
> > * PUD is not a populated non-leaf entry.
> > */
> > - WRITE_ONCE(*args->pudp, __pud(0));
> > + set_pud(args->pudp, __pud(0));
>
> Likewise, I think this should be:
>
> pud_clear(args->pudp);
>
> Thanks,
> Ryan
>
> > WARN_ON(!pud_set_huge(args->pudp, __pfn_to_phys(args->fixed_pud_pfn), args->page_prot));
> > WARN_ON(!pud_clear_huge(args->pudp));
> > pud = pudp_get(args->pudp);
>
Yeah I'm with Ryan on this, also as the kernel build bot attests, it turns out
we don't even define set_pmd()/set_pud() for powerpc... :)
© 2016 - 2025 Red Hat, Inc.