diff mbox series

[v2,5/7] x86/mm: remove pgd_leaf definition in arch

Message ID 20250331081327.256412-6-bhe@redhat.com (mailing list archive)
State New
Headers show
Series mm/gup: Minor fix, cleanup and improvements | expand

Commit Message

Baoquan He March 31, 2025, 8:13 a.m. UTC
pgd huge page is not supported yet, let's use the generic definition
in linux/pgtable.h.

And also update the BUILD_BUG_ON() checking for pgd_leaf() in
pti_user_pagetable_walk_p4d() because pgd_leaf() returns boolean value.

Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: x86@kernel.org
---
 arch/x86/include/asm/pgtable.h | 3 ---
 arch/x86/mm/pti.c              | 2 +-
 2 files changed, 1 insertion(+), 4 deletions(-)

Comments

David Hildenbrand April 1, 2025, 8:21 a.m. UTC | #1
On 31.03.25 10:13, Baoquan He wrote:
> pgd huge page is not supported yet, let's use the generic definition
> in linux/pgtable.h.
> 
> And also update the BUILD_BUG_ON() checking for pgd_leaf() in
> pti_user_pagetable_walk_p4d() because pgd_leaf() returns boolean value.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> Cc: x86@kernel.org
> ---

Acked-by: David Hildenbrand <david@redhat.com>
Oscar Salvador April 1, 2025, 2:03 p.m. UTC | #2
On Mon, Mar 31, 2025 at 04:13:25PM +0800, Baoquan He wrote:
> pgd huge page is not supported yet, let's use the generic definition
> in linux/pgtable.h.
> 
> And also update the BUILD_BUG_ON() checking for pgd_leaf() in
> pti_user_pagetable_walk_p4d() because pgd_leaf() returns boolean value.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> Cc: x86@kernel.org

I have been carrying a sort of this patch in my tree as well for quite
some time now, and I think that Christophe also sent it some time ago,
so glad someone finally pushed it

https://patchwork.kernel.org/project/linux-mm/patch/20240704043132.28501-2-osalvador@suse.de/

Reviewed-by: Oscar Salvador <osalvador@suse.de>
Baoquan He April 2, 2025, 3:39 a.m. UTC | #3
On 04/01/25 at 04:03pm, Oscar Salvador wrote:
> On Mon, Mar 31, 2025 at 04:13:25PM +0800, Baoquan He wrote:
> > pgd huge page is not supported yet, let's use the generic definition
> > in linux/pgtable.h.
> > 
> > And also update the BUILD_BUG_ON() checking for pgd_leaf() in
> > pti_user_pagetable_walk_p4d() because pgd_leaf() returns boolean value.
> > 
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > Cc: x86@kernel.org
> 
> I have been carrying a sort of this patch in my tree as well for quite
> some time now, and I think that Christophe also sent it some time ago,
> so glad someone finally pushed it
> 
> https://patchwork.kernel.org/project/linux-mm/patch/20240704043132.28501-2-osalvador@suse.de/

Oops, I even commented in Christophe's patch thread to ask why the
patchset hasn't been merged yet. Later when I focused on mm/gup.c code
reading, I forgot that posting completely. Hope you don't mind I grab
you and Christophe's credit since Ingo has picked it into x86/tip tree.

[PATCH v3 1/5] arch/x86: Drop own definition of pgd,p4d_leaf

> 
> Reviewed-by: Oscar Salvador <osalvador@suse.de>
> 
> 
> -- 
> Oscar Salvador
> SUSE Labs
>
diff mbox series

Patch

diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 7bd6bd6df4a1..5f4fcc0eea17 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -1472,9 +1472,6 @@  static inline bool pgdp_maps_userspace(void *__ptr)
 	return (((ptr & ~PAGE_MASK) / sizeof(pgd_t)) < PGD_KERNEL_START);
 }
 
-#define pgd_leaf	pgd_leaf
-static inline bool pgd_leaf(pgd_t pgd) { return false; }
-
 #ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
 /*
  * All top-level MITIGATION_PAGE_TABLE_ISOLATION page tables are order-1 pages
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 5f0d579932c6..c2e1de40136f 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -185,7 +185,7 @@  static p4d_t *pti_user_pagetable_walk_p4d(unsigned long address)
 
 		set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(new_p4d_page)));
 	}
-	BUILD_BUG_ON(pgd_leaf(*pgd) != 0);
+	BUILD_BUG_ON(pgd_leaf(*pgd));
 
 	return p4d_offset(pgd, address);
 }