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(-)
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);
}
--
2.41.0
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> -- Cheers, David / dhildenb
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> -- Oscar Salvador SUSE Labs
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 >
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: e62c7a4bd1d1e99e1ddd947cb526f833992c5bd4
Gitweb: https://git.kernel.org/tip/e62c7a4bd1d1e99e1ddd947cb526f833992c5bd4
Author: Baoquan He <bhe@redhat.com>
AuthorDate: Mon, 31 Mar 2025 16:13:25 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 31 Mar 2025 12:08:17 +02:00
x86/mm: Simplify the pgd_leaf() and p4d_leaf() checks a bit
The functions return bool, simplify the checks.
[ mingo: Split off from two other patches. ]
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250331081327.256412-6-bhe@redhat.com
---
arch/x86/mm/pti.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 5f0d579..1902998 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);
}
@@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address)
if (!p4d)
return NULL;
- BUILD_BUG_ON(p4d_leaf(*p4d) != 0);
+ BUILD_BUG_ON(p4d_leaf(*p4d));
if (p4d_none(*p4d)) {
unsigned long new_pud_page = __get_free_page(gfp);
if (WARN_ON_ONCE(!new_pud_page))
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 2b00d9031e42eabc8d32847d231ef48b8be0373d
Gitweb: https://git.kernel.org/tip/2b00d9031e42eabc8d32847d231ef48b8be0373d
Author: Baoquan He <bhe@redhat.com>
AuthorDate: Mon, 31 Mar 2025 16:13:25 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 01 Apr 2025 22:48:56 +02:00
x86/mm: Simplify the pgd_leaf() and p4d_leaf() checks a bit
The functions return bool, simplify the checks.
[ mingo: Split off from two other patches. ]
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250331081327.256412-6-bhe@redhat.com
---
arch/x86/mm/pti.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 5f0d579..1902998 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);
}
@@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address)
if (!p4d)
return NULL;
- BUILD_BUG_ON(p4d_leaf(*p4d) != 0);
+ BUILD_BUG_ON(p4d_leaf(*p4d));
if (p4d_none(*p4d)) {
unsigned long new_pud_page = __get_free_page(gfp);
if (WARN_ON_ONCE(!new_pud_page))
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 65525a3787ff082575fe29381d4dc8fd535634f2
Gitweb: https://git.kernel.org/tip/65525a3787ff082575fe29381d4dc8fd535634f2
Author: Baoquan He <bhe@redhat.com>
AuthorDate: Mon, 31 Mar 2025 16:13:25 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Mon, 31 Mar 2025 12:08:17 +02:00
x86/mm: Remove the arch-specific pgd_leaf() definition
PGD huge pages are not supported yet, let's use the generic definition
in <linux/pgtable.h>.
[ mingo: Cleaned up the changelog. ]
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250331081327.256412-6-bhe@redhat.com
---
arch/x86/include/asm/pgtable.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 7bd6bd6..5f4fcc0 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
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: b0510ac74e189442dde8799c1b212bd106f2300c
Gitweb: https://git.kernel.org/tip/b0510ac74e189442dde8799c1b212bd106f2300c
Author: Baoquan He <bhe@redhat.com>
AuthorDate: Mon, 31 Mar 2025 16:13:25 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 01 Apr 2025 22:46:51 +02:00
x86/mm: Remove the arch-specific pgd_leaf() definition
PGD huge pages are not supported yet, let's use the generic definition
in <linux/pgtable.h>.
[ mingo: Cleaned up the changelog. ]
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Link: https://lore.kernel.org/r/20250331081327.256412-6-bhe@redhat.com
---
arch/x86/include/asm/pgtable.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 7bd6bd6..5f4fcc0 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
The following commit has been merged into the x86/mm branch of tip:
Commit-ID: 4a490be3cb59c71dc84a363a251d466e2886ecd2
Gitweb: https://git.kernel.org/tip/4a490be3cb59c71dc84a363a251d466e2886ecd2
Author: Baoquan He <bhe@redhat.com>
AuthorDate: Mon, 31 Mar 2025 16:13:25 +08:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 01 Apr 2025 22:47:02 +02:00
x86/mm: Simplify the pgd_leaf() and p4d_leaf() checks a bit
The functions return bool, simplify the checks.
[ mingo: Split off from two other patches. ]
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20250331081327.256412-6-bhe@redhat.com
---
arch/x86/mm/pti.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 5f0d579..1902998 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);
}
@@ -206,7 +206,7 @@ static pmd_t *pti_user_pagetable_walk_pmd(unsigned long address)
if (!p4d)
return NULL;
- BUILD_BUG_ON(p4d_leaf(*p4d) != 0);
+ BUILD_BUG_ON(p4d_leaf(*p4d));
if (p4d_none(*p4d)) {
unsigned long new_pud_page = __get_free_page(gfp);
if (WARN_ON_ONCE(!new_pud_page))
© 2016 - 2025 Red Hat, Inc.