linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Ryan Roberts <ryan.roberts@arm.com>
Cc: Samuel Holland <samuel.holland@sifive.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	David Hildenbrand <david@kernel.org>,
	Vlastimil Babka <vbabka@suse.cz>, Jann Horn <jannh@google.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Anshuman Khandual <anshuman.khandual@arm.com>,
	Gavin Shan <gshan@redhat.com>, Zi Yan <ziy@nvidia.com>
Subject: Re: [PATCH 1/2] mm/debug_vm_pgtable: Use set_pXd() to write page tables
Date: Mon, 15 Dec 2025 10:33:54 +0000	[thread overview]
Message-ID: <56560af0-6a94-43f7-ba9b-49ec476d1a1c@lucifer.local> (raw)
In-Reply-To: <12ac22e3-d943-431e-a3da-15987fbb458e@arm.com>

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... :)


  reply	other threads:[~2025-12-15 10:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-11  8:11 [PATCH 0/2] mm: Always use set_pXX() helpers " Samuel Holland
2025-12-11  8:11 ` [PATCH 1/2] mm/debug_vm_pgtable: Use set_pXd() " Samuel Holland
2025-12-11  9:36   ` Ryan Roberts
2025-12-15 10:33     ` Lorenzo Stoakes [this message]
2025-12-12  0:48   ` kernel test robot
2025-12-12 12:11   ` kernel test robot
2025-12-11  8:11 ` [PATCH 2/2] mm/madvise: Use set_pte() " Samuel Holland
2025-12-11  9:43   ` Ryan Roberts
2025-12-15 10:37     ` Lorenzo Stoakes
2025-12-15 10:57       ` Ryan Roberts
2025-12-16 10:16         ` Lorenzo Stoakes
2025-12-11 23:40   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56560af0-6a94-43f7-ba9b-49ec476d1a1c@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --cc=david@kernel.org \
    --cc=gshan@redhat.com \
    --cc=jannh@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=samuel.holland@sifive.com \
    --cc=vbabka@suse.cz \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox