mm: Drop pxd_ERROR()
Subsystems (26)
cover mm: Drop pxd_ERROR()
pxd_ERROR() macros have been provided by all platforms, which are very much identical and can be dropped off completely if these pgtable printing could be moved to callers in generic MM aka all pxd_clear_bad().
But first cleanups and re-organizations are required in some platforms that are using these macros internally. Afterwards [pte|pmd|pud|p4d|pgd]_ERROR() macros have been completely dropped from the entire tree.
This series is based on v7.3-rc1 after the following patch and has also been built tested on multiple platforms.
Changes in V1:
- Moved ptval_to_str() and adjcent declarations inside <include/linux/pgtable.h>
- Fixed type s/ptrval_to_str/ptval_to_str in [PATCH 1/8]
- Dropped PTE_FMT from riscv platform
- Added all tags received
Changes in RFC V3:
https://lore.kernel.org/all/[email protected]/
- Moved ptrval_to_str() as header in a separate patch
- Stopped using pxd_ERROR() in generic MM in a separate patch
- Dropped pxd_ERRO() macros from all platforms in a separate patch
- Dropped print_bad_pte() and also cleaned up set_pte_phys()
- Added some pr_error() messages in __get_pte_phys()
- Cleaned up error messages and used ptrval_to_str() in platforms
Changes in RFC V2:
https://lore.kernel.org/all/[email protected]/
- Added clean up patches for platforms with existing pxd_ERROR() usage
- Dropped __FILE__ and __LINE__ from all print sections per David
Changes in RFC V1:
https://lore.kernel.org/all/[email protected]/
Anshuman Khandual (8):
mm: Make ptval_to_str() generally available
mm: Stop using pxd_ERROR()
loongarch/mm: Stop using pte_ERROR() parisc/mm: Directly use generic [pmd|pgd]_clear_bad() sh/mm: Stop using pte_ERROR()
sh/mm: Stop using [p4d|pud|pmd]_ERROR() sh/mm: Stop using pgd_ERROR()
mm: Drop pxd_ERROR()
arch/alpha/include/asm/pgtable.h | 7 ------- arch/arc/include/asm/pgtable-levels.h | 11 ---------- arch/arm/include/asm/pgtable.h | 7 ------- arch/arm/kernel/traps.c | 17 ---------------- arch/arm64/include/asm/pgtable.h | 15 -------------- arch/csky/include/asm/pgtable.h | 4 ---- arch/hexagon/include/asm/pgtable.h | 3 --- arch/loongarch/include/asm/pgtable.h | 13 ------------ arch/loongarch/mm/init.c | 4 +++- arch/m68k/include/asm/mcf_pgtable.h | 6 ------ arch/m68k/include/asm/motorola_pgtable.h | 8 -------- arch/m68k/include/asm/sun3_pgtable.h | 7 ------- arch/microblaze/include/asm/pgtable.h | 7 ------- arch/mips/include/asm/pgtable-32.h | 10 ---------- arch/mips/include/asm/pgtable-64.h | 13 ------------ arch/nios2/include/asm/pgtable.h | 7 ------- arch/openrisc/include/asm/pgtable.h | 7 ------- arch/parisc/include/asm/pgtable.h | 9 --------- arch/parisc/kernel/pci-dma.c | 6 ++---- arch/powerpc/include/asm/book3s/32/pgtable.h | 2 -- arch/powerpc/include/asm/book3s/64/pgtable.h | 7 ------- arch/powerpc/include/asm/nohash/32/pgtable.h | 2 -- .../include/asm/nohash/64/pgtable-4k.h | 3 --- arch/powerpc/include/asm/nohash/64/pgtable.h | 5 ----- arch/riscv/include/asm/page.h | 6 ------ arch/riscv/include/asm/pgtable-64.h | 9 --------- arch/riscv/include/asm/pgtable.h | 4 ---- arch/s390/include/asm/pgtable.h | 11 ---------- arch/sh/include/asm/pgtable-3level.h | 3 --- arch/sh/include/asm/pgtable_32.h | 13 ------------ arch/sh/mm/init.c | 16 ++++++++------- arch/sparc/include/asm/pgtable_32.h | 3 --- arch/sparc/include/asm/pgtable_64.h | 10 ---------- arch/um/include/asm/pgtable-2level.h | 7 ------- arch/um/include/asm/pgtable-4level.h | 13 ------------ arch/x86/include/asm/pgtable-2level.h | 5 ----- arch/x86/include/asm/pgtable-3level.h | 11 ---------- arch/x86/include/asm/pgtable_64.h | 18 ----------------- arch/xtensa/include/asm/pgtable.h | 4 ---- include/asm-generic/pgtable-nop4d.h | 1 - include/asm-generic/pgtable-nopmd.h | 1 - include/asm-generic/pgtable-nopud.h | 1 - include/linux/pgtable.h | 14 +++++++++++++ mm/memory.c | 15 +------------- mm/pgtable-generic.c | 20 +++++++++++++++---- 45 files changed, 45 insertions(+), 320 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/8 mm: Make ptval_to_str() generally available
Move ptval_to_str() inside a header thus making the helper more generally available for new users which are being added later. While here, also move another related string size macro PTVAL_STR_MAX inside the header as well.
---
Changes in V1:
- Moved ptval_to_str() and adjcent declarations inside <include/linux/pgtable.h>
- Fixed type s/ptrval_to_str/ptval_to_str in [PATCH 1/8]
include/linux/pgtable.h | 14 ++++++++++++++ mm/memory.c | 15 +-------------- 2 files changed, 15 insertions(+), 14 deletions(-)
include/linux/pgtable.h +14 -0
@@ -2313,6 +2313,20 @@ static inline const char *pgtable_level_to_str(enum pgtable_level level) } } +void ptval_bytes_to_hex_str (char *buf,size_t buf_size,const void *entry,size_t entry_size); + +#define ptval_to_str (buf, val) \ + do { \ + auto __val = (val); \ + \ + ptval_bytes_to_hex_str((buf), sizeof(buf), &__val, sizeof(__val)); \ + } while (0) + +#if defined(__SIZEOF_INT128__) +#define PTVAL_STR_MAX (32 + 1)/* Max 128-bit value in hex + NUL */ +#else +#define PTVAL_STR_MAX (16 + 1)/* Max 64-bit value in hex + NUL */ +#endif #endif /* !__ASSEMBLER__ */ #if !defined(MAX_POSSIBLE_PHYSMEM_BITS ) && !defined(CONFIG_64BIT )
mm/memory.c +1 -14
@@ -519,7 +519,7 @@ static bool is_bad_page_map_ratelimited(void)return false; } -static void ptval_bytes_to_hex_str (char *buf,size_t buf_size,const void *entry,size_t entry_size) +void ptval_bytes_to_hex_str (char *buf,size_t buf_size,const void *entry,size_t entry_size) {if (WARN_ON_ONCE (buf_size < entry_size *2 +1 )) {snprintf (buf, buf_size,"overflow" );
@@ -546,19 +546,6 @@ static void ptval_bytes_to_hex_str(char *buf, size_t buf_size, const void *entry } } -#define ptval_to_str (buf, val) \ - do { \ - auto __val = (val); \ - \ - ptval_bytes_to_hex_str((buf), sizeof(buf), &__val, sizeof(__val)); \ - } while (0) - -#if defined(__SIZEOF_INT128__) -#define PTVAL_STR_MAX (32 + 1)/* Max 128-bit value in hex + NUL */ -#else -#define PTVAL_STR_MAX (16 + 1)/* Max 64-bit value in hex + NUL */ -#endif -static void __print_bad_page_map_pgtable (struct mm_struct *mm,unsigned long addr) {char pgd_str[PTVAL_STR_MAX ];
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 1/8] mm: Make ptval_to_str() generally available
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Move
ptval_to_str()inside a header thus making the helper more generally available for new users which are being added later. While here, also move another related string size macroPTVAL_STR_MAXinside the header as well.
Quoted 8 lines
Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH 2/8 mm: Stop using pxd_ERROR()
In reply to Anshuman Khandualpxd_ERROR() has been used in generic mm just to print the page table entry in pxd_clear_bad() before clearing those out with pxd_clear() later. These pxd_ERROR() macros have been provided by all platforms which basically did the same thing.
Make pxd_clear_bad() use recently added ptval_to_str() instead for printing page table entries thus completely dropping dependency on platform provided pxd_ERROR() macros which can then be dropped off later on.
---
Changes in V1:
- Dropped including mm_type.h
mm/pgtable-generic.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
mm/pgtable-generic.c +16 -4
@@ -26,14 +26,20 @@void pgd_clear_bad (pgd_t *pgd) { -pgd_ERROR (*pgd); +char str[PTVAL_STR_MAX ]; + +ptval_to_str (str,pgd_val (*pgd)); +pr_err ("bad pgd %s.\n" , str);pgd_clear (pgd); }#ifndef __PAGETABLE_P4D_FOLDEDvoid p4d_clear_bad (p4d_t *p4d) { -p4d_ERROR (*p4d); +char str[PTVAL_STR_MAX ]; + +ptval_to_str (str,p4d_val (*p4d)); +pr_err ("bad p4d %s.\n" , str);p4d_clear (p4d); }#endif
@@ -41,7 +47,10 @@ void p4d_clear_bad(p4d_t *p4d)#ifndef __PAGETABLE_PUD_FOLDEDvoid pud_clear_bad (pud_t *pud) { -pud_ERROR (*pud); +char str[PTVAL_STR_MAX ]; + +ptval_to_str (str,pud_val (*pud)); +pr_err ("bad pud %s.\n" , str);pud_clear (pud); }#endif
@@ -53,7 +62,10 @@ void pud_clear_bad(pud_t *pud)*/ void pmd_clear_bad (pmd_t *pmd) { -pmd_ERROR (*pmd); +char str[PTVAL_STR_MAX ]; + +ptval_to_str (str,pmd_val (*pmd)); +pr_err ("bad pmd %s.\n" , str);pmd_clear (pmd); }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 2/8] mm: Stop using pxd_ERROR()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines
pxd_ERROR()has been used in generic mm just to print the page table entry inpxd_clear_bad()before clearing those out withpxd_clear()later. Thesepxd_ERROR()macros have been provided by all platforms which basically did the same thing.Make
pxd_clear_bad()use recently addedptval_to_str()instead for printing page table entries thus completely dropping dependency on platform providedpxd_ERROR()macros which can then be dropped off later on.
Quoted 8 lines
Cc Andrew Morton <[email protected]>Cc David Hildenbrand <[email protected]>Cc Lorenzo Stoakes <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
PATCH 3/8 loongarch/mm: Stop using pte_ERROR()
In reply to Anshuman KhandualDirectly use pr_err() in __set_fixmap() and drop pte_ERROR() which helps in eventually dropping pte_ERROR() macro across the tree. In this new printing __FILE__ and __LINE__ has been dropped because they are always the same and don't really add any value. The new ptval_to_str() helper is being used for converting pgtable entry value into a string. The error message itself has been cleaned up as well.
--- arch/loongarch/include/asm/pgtable.h | 2 -- arch/loongarch/mm/init.c | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/loongarch/include/asm/pgtable.h +0 -2
@@ -135,8 +135,6 @@ struct vm_area_struct;#define ptep_get (ptep) READ_ONCE(*(ptep))#define pmdp_get (pmdp) READ_ONCE(*(pmdp)) -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e))#ifndef __PAGETABLE_PMD_FOLDED#define pmd_ERROR (e) \ pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e))
arch/loongarch/mm/init.c +3 -1
@@ -197,13 +197,15 @@ void __init __set_fixmap(enum fixed_addresses idx, phys_addr_t phys, pgprot_t flags) {unsigned long addr =__fix_to_virt (idx); +char str[PTVAL_STR_MAX ];pte_t *ptep;BUG_ON (idx <=FIX_HOLE || idx >= __end_of_fixed_addresses); ptep =populate_kernel_pte (addr);if (!pte_none (ptep_get (ptep))) { -pte_ERROR (*ptep); +ptval_to_str (str,pte_val (*ptep)); +pr_err ("unexpected set PTE at %lx in %s: %s\n" , addr, __func__, str);return ; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 3/8] loongarch/mm: Stop using pte_ERROR()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
Directly use
pr_err()in__set_fixmap()and droppte_ERROR()which helps in eventually droppingpte_ERROR()macro across the tree. In this new printing__FILE__and__LINE__has been dropped because they are always the same and don't really add any value. The newptval_to_str()helper is being used for converting pgtable entry value into a string. The error message itself has been cleaned up as well.
Quoted 7 lines
Cc Huacai Chen <[email protected]>Cc WANG Xuerui <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH 4/8 parisc/mm: Directly use generic [pmd|pgd]_clear_bad()
In reply to Anshuman KhandualDrop [pmd|pgd]_ERROR() followed by [pmd|pgd]_clear() instances. But instead directly use semantically equivalent generic helpers [pmd|pgd]_clear_bad() in unmap_uncached_[pte|pmd]() which helps in dropping their corresponding [pmd|pgd]_ERROR() macros across the tree.
--- arch/parisc/kernel/pci-dma.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
arch/parisc/kernel/pci-dma.c +2 -4
@@ -160,8 +160,7 @@ static inline void unmap_uncached_pte(pmd_t * pmd, unsigned long vaddr,if (pmd_none (*pmd))return ;if (pmd_bad (*pmd)) { -pmd_ERROR (*pmd); -pmd_clear (pmd); +pmd_clear_bad (pmd);return ; } pte =pte_offset_kernel (pmd, vaddr);
@@ -196,8 +195,7 @@ static inline void unmap_uncached_pmd(pgd_t * dir, unsigned long vaddr,if (pgd_none (*dir))return ;if (pgd_bad (*dir)) { -pgd_ERROR (*dir); -pgd_clear (dir); +pgd_clear_bad (dir);return ; } pmd =pmd_offset (pud_offset (p4d_offset (dir, vaddr), vaddr), vaddr);
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 4/8] parisc/mm: Directly use generic [pmd|pgd]_clear_bad()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines
Drop [pmd|pgd]_ERROR() followed by [pmd|pgd]_clear() instances. But instead directly use semantically equivalent generic helpers [pmd|pgd]_clear_bad() in unmap_uncached_[pte|pmd]() which helps in dropping their corresponding [pmd|pgd]_ERROR() macros across the tree.
Quoted 7 lines
Cc James E.J. Bottomley <[email protected]>Cc Helge Deller <[email protected]>Reviewed-by David Hildenbrand (Arm) <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
PATCH 5/8 sh/mm: Stop using pte_ERROR()
In reply to Anshuman KhandualDirectly use pr_err() in set_pte_phys() and drop pte_ERROR() which helps in eventually dropping pte_ERROR() macro across the tree. In this new printing __FILE__ and __LINE__ has been dropped because they are always the same and don't really add any value. Besides ptrval_to_str() has been able to handle different PTE representation with and without CONFIG_X2TLB, which helped in unifying error message printing.
--- arch/sh/include/asm/pgtable_32.h | 5 ----- arch/sh/mm/init.c | 6 +++++- 2 files changed, 5 insertions(+), 6 deletions(-)
arch/sh/include/asm/pgtable_32.h +0 -5
@@ -401,14 +401,9 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)#define pmd_page (pmd) (virt_to_page(pmd_val(pmd)))#ifdef CONFIG_X2TLB -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %p(%08lx%08lx).\n", __FILE__, __LINE__, \ - &(e), (e).pte_high, (e).pte_low)#define pgd_ERROR (e) \ printk("%s:%d: bad pgd %016llx.\n", __FILE__, __LINE__, pgd_val(e))#else -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e))#define pgd_ERROR (e) \ printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))#endif
arch/sh/mm/init.c +5 -1
@@ -84,7 +84,11 @@ static void set_pte_phys(unsigned long addr, unsigned long phys, pgprot_t prot) pte =__get_pte_phys (addr);if (!pte_none (*pte)) { -pte_ERROR (*pte); +char str[PTVAL_STR_MAX ]; + +ptval_to_str (str,pte_val (*pte)); +pr_err ("unexpected set PTE at %lx in %s: bad pte %p(%s).\n" , + addr, __func__, pte, str);return ; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 5/8] sh/mm: Stop using pte_ERROR()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 7 lines
Directly use
pr_err()inset_pte_phys()and droppte_ERROR()which helps in eventually droppingpte_ERROR()macro across the tree. In this new printing__FILE__and__LINE__has been dropped because they are always the same and don't really add any value. Besidesptrval_to_str()has been able to handle different PTE representation with and withoutCONFIG_X2TLB, which helped in unifying error message printing.
Quoted 8 lines
Cc Yoshinori Sato <[email protected]>Cc Rich Felker <[email protected]>Cc John Paul Adrian Glaubitz <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
PATCH 6/8 sh/mm: Stop using [p4d|pud|pmd]_ERROR()
In reply to Anshuman KhandualStop using [p4d|pud|pmd]_ERROR() in __get_pte_phys() as the pgtable entries are known to be NULL and hence could not really be accessed.
--- arch/sh/mm/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/sh/mm/init.c +3 -3
@@ -59,19 +59,19 @@ static pte_t *__get_pte_phys(unsigned long addr) p4d =p4d_alloc (NULL , pgd, addr);if (unlikely (!p4d)) { -p4d_ERROR (*p4d); +pr_err ("allocating p4d table failed\n" );return NULL ; } pud =pud_alloc (NULL , p4d, addr);if (unlikely (!pud)) { -pud_ERROR (*pud); +pr_err ("allocating pud table failed\n" );return NULL ; } pmd =pmd_alloc (NULL , pud, addr);if (unlikely (!pmd)) { -pmd_ERROR (*pmd); +pr_err ("allocating pmd table failed\n" );return NULL ; }
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 6/8] sh/mm: Stop using [p4d|pud|pmd]_ERROR()
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] __get_pte_phys() can return NULL on error, but its callers (set_pte_phys() and clear_pte_phys()) immediately dereference the returned pointer without checking, leading to a guaranteed kernel crash.
- [High] __get_pte_phys() uses allocation functions (p4d_alloc, pud_alloc, pmd_alloc) passing NULL for the mm argument, which will cause a kernel crash if allocation is actually needed. --
commit 0098935d861a1c9cf1496880ca35e1a49aecdf51
Author: Anshuman Khandual <[email protected]>
sh/mm: Stop using [p4d|pud|pmd]_ERROR()
This commit replaces the use of [p4d|pud|pmd]_ERROR() with pr_err() in __get_pte_phys() when page table allocations fail. This avoids a NULL pointer dereference when attempting to pass the failed allocation result to the error macros.
arch/sh/mm/init.c static pte_t *__get_pte_phys(unsigned long addr) · line 60
Quoted 7 lines
arch/sh/mm/init.c +0
-0@@ -59,19 +59,19 @@ static pte_t *__get_pte_phys(unsigned long addr) p4d =p4d_alloc (NULL , pgd, addr);
[Severity: High]
This isn't a bug introduced by this patch, but passing NULL for the mm argument to p4d_alloc() will cause a kernel panic if allocation is actually needed. The slow path requires a valid mm_struct to acquire the page table lock. Should this be passing &init_mm instead?
arch/sh/mm/init.c static pte_t *__get_pte_phys(unsigned long addr) · line 64
Quoted 5 lines
arch/sh/mm/init.c +1
-1if (unlikely (!p4d)) { -p4d_ERROR (*p4d); +pr_err ("allocating p4d table failed\n" );return NULL ; }
[Severity: High]
This isn't a bug introduced by this patch, but while this fixes a NULL pointer dereference here in the callee, the callers still unconditionally dereference the returned pointer.
For example, in set_pte_phys():
pte = __get_pte_phys(addr);
if (!pte_none(*pte)) {And in clear_pte_phys():
pte = __get_pte_phys(addr);
if (pgprot_val(prot) & _PAGE_WIRED)
tlb_unwire_entry();
set_pte(pte, pfn_pte(0, __pgprot(0)));Could these callers be updated to check if the returned pte is NULL before dereferencing it to avoid guaranteed crashes on the error paths?
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
Andrew Morton
maintainerRe: [PATCH 6/8] sh/mm: Stop using [p4d|pud|pmd]_ERROR()
In reply to Anshuman KhandualQuoted 2 lines · On Mon, 31 Aug 2026 11:13:28 +0530 Anshuman Khandual…
Stop using [p4d|pud|pmd]_ERROR() in
__get_pte_phys()as the pgtable entries are known to be NULL and hence could not really be accessed.
A note to the sh maintainers: Sashiko might have found a couple of bugs in __get_pte_phys():
https://sashiko.dev/#/patchset/[email protected]
PATCH 7/8 sh/mm: Stop using pgd_ERROR()
In reply to Anshuman KhandualStop using pgd_ERROR() in __get_pte_phys() when page table entry is already known to be empty.
--- arch/sh/mm/init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/sh/mm/init.c +1 -3
@@ -52,10 +52,8 @@ static pte_t *__get_pte_phys(unsigned long addr)pmd_t *pmd; pgd =pgd_offset_k (addr); -if (pgd_none (*pgd)) { -pgd_ERROR (*pgd); +if (pgd_none (*pgd))return NULL ; - } p4d =p4d_alloc (NULL , pgd, addr);if (unlikely (!p4d)) {
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH 7/8] sh/mm: Stop using pgd_ERROR()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 11 lines
Stop using
pgd_ERROR()in__get_pte_phys()when page table entry is already known to be empty.Cc Yoshinori Sato <[email protected]>Cc Rich Felker <[email protected]>Cc John Paul Adrian Glaubitz <[email protected]>Reviewed-by David Hildenbrand (Arm) <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH 8/8 mm: Drop pxd_ERROR()
In reply to Anshuman KhandualThere are no more users left for any pxd_ERROR() either in generic MM or in the platform MM. Hence all these platform macros along with their generic fallback could be dropped across the tree.
---
Changes in V1:
- Dropped PTE_FMT from riscv platform
arch/alpha/include/asm/pgtable.h | 7 ------- arch/arc/include/asm/pgtable-levels.h | 11 ----------- arch/arm/include/asm/pgtable.h | 7 ------- arch/arm/kernel/traps.c | 17 ----------------- arch/arm64/include/asm/pgtable.h | 15 --------------- arch/csky/include/asm/pgtable.h | 4 ---- arch/hexagon/include/asm/pgtable.h | 3 --- arch/loongarch/include/asm/pgtable.h | 11 ----------- arch/m68k/include/asm/mcf_pgtable.h | 6 ------ arch/m68k/include/asm/motorola_pgtable.h | 8 -------- arch/m68k/include/asm/sun3_pgtable.h | 7 ------- arch/microblaze/include/asm/pgtable.h | 7 ------- arch/mips/include/asm/pgtable-32.h | 10 ---------- arch/mips/include/asm/pgtable-64.h | 13 ------------- arch/nios2/include/asm/pgtable.h | 7 ------- arch/openrisc/include/asm/pgtable.h | 7 ------- arch/parisc/include/asm/pgtable.h | 9 --------- arch/powerpc/include/asm/book3s/32/pgtable.h | 2 -- arch/powerpc/include/asm/book3s/64/pgtable.h | 7 ------- arch/powerpc/include/asm/nohash/32/pgtable.h | 2 -- .../powerpc/include/asm/nohash/64/pgtable-4k.h | 3 --- arch/powerpc/include/asm/nohash/64/pgtable.h | 5 ----- arch/riscv/include/asm/page.h | 6 ------ arch/riscv/include/asm/pgtable-64.h | 9 --------- arch/riscv/include/asm/pgtable.h | 4 ---- arch/s390/include/asm/pgtable.h | 11 ----------- arch/sh/include/asm/pgtable-3level.h | 3 --- arch/sh/include/asm/pgtable_32.h | 8 -------- arch/sparc/include/asm/pgtable_32.h | 3 --- arch/sparc/include/asm/pgtable_64.h | 10 ---------- arch/um/include/asm/pgtable-2level.h | 7 ------- arch/um/include/asm/pgtable-4level.h | 13 ------------- arch/x86/include/asm/pgtable-2level.h | 5 ----- arch/x86/include/asm/pgtable-3level.h | 11 ----------- arch/x86/include/asm/pgtable_64.h | 18 ------------------ arch/xtensa/include/asm/pgtable.h | 4 ---- include/asm-generic/pgtable-nop4d.h | 1 - include/asm-generic/pgtable-nopmd.h | 1 - include/asm-generic/pgtable-nopud.h | 1 - 39 files changed, 283 deletions(-)
arch/alpha/include/asm/pgtable.h +0 -7
@@ -357,13 +357,6 @@ static inline pte_t pte_swp_clear_exclusive(pte_t pte)return pte; } -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e)) -#define pmd_ERROR (e) \ - printk("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e)) -extern void paging_init (void );/* We have our own get_unmapped_area */
arch/arc/include/asm/pgtable-levels.h +0 -11
@@ -98,8 +98,6 @@/* * 1st level paging: pgd */ -#define pgd_ERROR (e) \ - pr_crit("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))#if CONFIG_PGTABLE_LEVELS >3
@@ -115,9 +113,6 @@/* * 2nd level paging: pud */ -#define pud_ERROR (e) \ - pr_crit("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e)) -#endif #if CONFIG_PGTABLE_LEVELS >2
@@ -137,9 +132,6 @@/* * 3rd level paging: pmd */ -#define pmd_ERROR (e) \ - pr_crit("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pmd_pfn (pmd) ((pmd_val(pmd) & PMD_MASK) >> PAGE_SHIFT)#define pfn_pmd (pfn,prot) __pmd(((pfn) << PAGE_SHIFT) | pgprot_val(prot))
@@ -165,9 +157,6 @@/* * 4th level paging: pte */ -#define pte_ERROR (e) \ - pr_crit("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) -#define PFN_PTE_SHIFT PAGE_SHIFT#define pte_none (x) (!pte_val(x))#define pte_present (x) (pte_val(x) & _PAGE_PRESENT)
arch/arm/include/asm/pgtable.h +0 -7
@@ -44,13 +44,6 @@#define LIBRARY_TEXT_START 0x0c000000#ifndef __ASSEMBLY__ -extern void __pte_error (const char *file,int line,pte_t ); -extern void __pmd_error (const char *file,int line,pmd_t ); -extern void __pgd_error (const char *file,int line,pgd_t ); - -#define pte_ERROR (pte) __pte_error(__FILE__, __LINE__, pte) -#define pmd_ERROR (pmd) __pmd_error(__FILE__, __LINE__, pmd) -#define pgd_ERROR (pgd) __pgd_error(__FILE__, __LINE__, pgd)/* * This is the lowest virtual address we can permit any user space
arch/arm/kernel/traps.c +0 -17
@@ -753,23 +753,6 @@ void __readwrite_bug(const char *fn) }EXPORT_SYMBOL (__readwrite_bug); -#ifdef CONFIG_MMU -void __pte_error (const char *file,int line,pte_t pte) -{ -pr_err ("%s:%d: bad pte %08llx.\n" , file, line, (long long )pte_val (pte)); -} - -void __pmd_error (const char *file,int line,pmd_t pmd) -{ -pr_err ("%s:%d: bad pmd %08llx.\n" , file, line, (long long )pmd_val (pmd)); -} - -void __pgd_error (const char *file,int line,pgd_t pgd) -{ -pr_err ("%s:%d: bad pgd %08llx.\n" , file, line, (long long )pgd_val (pgd)); -} -#endif - asmlinkage void __div0(void) {pr_err ("Division by zero in kernel.\n" );
arch/arm64/include/asm/pgtable.h +0 -15
@@ -107,9 +107,6 @@ static inline void arch_leave_lazy_mmu_mode(void)__flush_tlb_range (vma, address, address +PMD_SIZE ,PMD_SIZE ,2 , \ TLBF_NOBROADCAST | TLBF_NONOTIFY | TLBF_NOWALKCACHE) -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %016llx.\n", __FILE__, __LINE__, pte_val(e)) -#ifdef CONFIG_ARM64_PA_BITS_52 static inline phys_addr_t __pte_to_phys (pte_t pte) {
@@ -866,9 +863,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)#if CONFIG_PGTABLE_LEVELS >2 -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %016llx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pud_none (pud) (!pud_val(pud))#define pud_bad (pud) ((pud_val(pud) & PUD_TYPE_MASK) != \ PUD_TYPE_TABLE)
@@ -960,9 +954,6 @@ static inline bool mm_pud_folded(const struct mm_struct *mm) }#define mm_pud_folded mm_pud_folded -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %016llx.\n", __FILE__, __LINE__, pud_val(e)) -#define p4d_none (p4d) (pgtable_l4_enabled() && !p4d_val(p4d))#define p4d_bad (p4d) (pgtable_l4_enabled() && \ ((p4d_val(p4d) & P4D_TYPE_MASK) != \
@@ -1088,9 +1079,6 @@ static inline bool mm_p4d_folded(const struct mm_struct *mm) }#define mm_p4d_folded mm_p4d_folded -#define p4d_ERROR (e) \ - pr_err("%s:%d: bad p4d %016llx.\n", __FILE__, __LINE__, p4d_val(e)) -#define pgd_none (pgd) (pgtable_l5_enabled() && !pgd_val(pgd))#define pgd_bad (pgd) (pgtable_l5_enabled() && \ ((pgd_val(pgd) & PGD_TYPE_MASK) != \
@@ -1217,9 +1205,6 @@ p4d_t *p4d_offset_lockless_folded(pgd_t *pgdp, pgd_t pgd, unsigned long addr)#endif /* CONFIG_PGTABLE_LEVELS > 4 */ -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %016llx.\n", __FILE__, __LINE__, pgd_val(e)) -#define pgd_set_fixmap (addr) ((pgd_t *)set_fixmap_offset(FIX_PGD, addr))#define pgd_clear_fixmap () clear_fixmap(FIX_PGD)
arch/csky/include/asm/pgtable.h +0 -4
@@ -23,10 +23,6 @@#define PTRS_PER_PMD 1#define PTRS_PER_PTE (PAGE_SIZE / sizeof(pte_t)) -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, (e).pte_low) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))#define PFN_PTE_SHIFT PAGE_SHIFT#define pmd_pfn (pmd) (pmd_phys(pmd) >> PAGE_SHIFT)
arch/hexagon/include/asm/pgtable.h +0 -3
@@ -94,9 +94,6 @@#endif /* Any bigger and the PTE disappears. */ -#define pgd_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__,\ - pgd_val(e))/* * Page Protection Constants. Includes (in this variant) cache attributes.
arch/loongarch/include/asm/pgtable.h +0 -11
@@ -135,17 +135,6 @@ struct vm_area_struct;#define ptep_get (ptep) READ_ONCE(*(ptep))#define pmdp_get (pmdp) READ_ONCE(*(pmdp)) -#ifndef __PAGETABLE_PMD_FOLDED -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) -#endif -#ifndef __PAGETABLE_PUD_FOLDED -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %016lx.\n", __FILE__, __LINE__, pud_val(e)) -#endif -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e)) -extern pte_t invalid_pte_table[PTRS_PER_PTE ];#ifndef __PAGETABLE_PUD_FOLDED
arch/m68k/include/asm/mcf_pgtable.h +0 -6
@@ -137,12 +137,6 @@ static inline int pmd_bad2(pmd_t *pmd) { return 0; }#define pmd_present (pmd) (!pmd_none2(&(pmd)))static inline void pmd_clear (pmd_t *pmdp) {pmd_val (*pmdp) =0 ; } -#define pte_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pte %08lx.\n", \ - __FILE__, __LINE__, pte_val(e)) -#define pgd_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \ - __FILE__, __LINE__, pgd_val(e))/* * The following only work if pte_present() is true.
arch/m68k/include/asm/motorola_pgtable.h +0 -8
@@ -131,14 +131,6 @@ static inline void pud_set(pud_t *pudp, pmd_t *pmdp)#define pud_clear (pudp) ({ pud_val(*pudp) = 0; })#define pud_page (pud) (mem_map + ((unsigned long)(__va(pud_val(pud)) - PAGE_OFFSET) >> PAGE_SHIFT)) -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) -#define pmd_ERROR (e) \ - printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) - -/* * The following only work if pte_present() is true. * Undefined behaviour if not..
arch/m68k/include/asm/sun3_pgtable.h +0 -7
@@ -119,13 +119,6 @@ static inline int pmd_present2 (pmd_t *pmd) { return pmd_val (*pmd) & SUN3_PMD_V#define pmd_present (pmd) (!pmd_none2(&(pmd)))static inline void pmd_clear (pmd_t *pmdp) {pmd_val (*pmdp) =0 ; } - -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) - -/* * The following only work if pte_present() is true. * Undefined behaviour if not...
arch/microblaze/include/asm/pgtable.h +0 -7
@@ -103,13 +103,6 @@ extern pte_t *va_to_pte(unsigned long address);#define USER_PGD_PTRS (PAGE_OFFSET >> PGDIR_SHIFT)#define KERNEL_PGD_PTRS (PTRS_PER_PGD-USER_PGD_PTRS) -#define pte_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pte "PTE_FMT".\n", \ - __FILE__, __LINE__, pte_val(e)) -#define pgd_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pgd %08lx.\n", \ - __FILE__, __LINE__, pgd_val(e)) -/* * Bits in a linux-style PTE. These match the bits in the * (hardware-defined) PTE as closely as possible.
arch/mips/include/asm/pgtable-32.h +0 -10
@@ -104,16 +104,6 @@ extern int add_temporary_entry(unsigned long entrylo0, unsigned long entrylo1,# define VMALLOC_END (FIXADDR_START-2*PAGE_SIZE)#endif -#ifdef CONFIG_PHYS_ADDR_T_64BIT -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %016Lx.\n", __FILE__, __LINE__, pte_val(e)) -#else -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) -#endif -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -extern void load_pgd (unsigned long pg_dir);extern pte_t invalid_pte_table[PTRS_PER_PTE ];
arch/mips/include/asm/pgtable-64.h +0 -13
@@ -151,19 +151,6 @@#define MODULES_END (FIXADDR_START-2*PAGE_SIZE)#endif -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e)) -#ifndef __PAGETABLE_PMD_FOLDED -#define pmd_ERROR (e) \ - printk("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) -#endif -#ifndef __PAGETABLE_PUD_FOLDED -#define pud_ERROR (e) \ - printk("%s:%d: bad pud %016lx.\n", __FILE__, __LINE__, pud_val(e)) -#endif -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e)) -extern pte_t invalid_pte_table[PTRS_PER_PTE ];#ifndef __PAGETABLE_PUD_FOLDED
arch/nios2/include/asm/pgtable.h +0 -7
@@ -223,13 +223,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)return pmd_val (pmd); } -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %08lx.\n", \ - __FILE__, __LINE__, pte_val(e)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx.\n", \ - __FILE__, __LINE__, pgd_val(e)) -/* * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that * are !pte_none() && !pte_present().
arch/openrisc/include/asm/pgtable.h +0 -7
@@ -338,13 +338,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)#define pte_pfn (x) ((unsigned long)(((x).pte)) >> PAGE_SHIFT)#define pfn_pte (pfn, prot) __pte((((pfn) << PAGE_SHIFT)) | pgprot_val(prot)) -#define pte_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pte %p(%08lx).\n", \ - __FILE__, __LINE__, &(e), pte_val(e)) -#define pgd_ERROR (e) \ - printk(KERN_ERR "%s:%d: bad pgd %p(%08lx).\n", \ - __FILE__, __LINE__, &(e), pgd_val(e)) -extern pgd_t swapper_pg_dir[PTRS_PER_PGD ];/* defined in head.S */ struct vm_area_struct ;
arch/parisc/include/asm/pgtable.h +0 -9
@@ -75,15 +75,6 @@ extern void __update_cache(pte_t pte);#endif /* !__ASSEMBLER__ */ -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) -#if CONFIG_PGTABLE_LEVELS ==3 -#define pmd_ERROR (e) \ - printk("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, (unsigned long)pmd_val(e)) -#endif -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, (unsigned long)pgd_val(e)) -/* This is the size of the initially mapped kernel memory */ #if defined(CONFIG_64BIT ) || defined(CONFIG_KALLSYMS )#define KERNEL_INITIAL_ORDER 26/* 1<<26 = 64MB */
arch/powerpc/include/asm/book3s/32/pgtable.h +0 -2
@@ -203,8 +203,6 @@ void unmap_kernel_page(unsigned long va);/* Bits to mask out from a PGD to get to the PUD page */ #define PGD_MASKED_BITS 0 -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e))/* * Bits in a linux-style PTE. These match the bits in the * (hardware-defined) PowerPC PTE as closely as possible.
arch/powerpc/include/asm/book3s/64/pgtable.h +0 -7
@@ -991,13 +991,6 @@ static inline pmd_t *pud_pgtable(pud_t pud)return (pmd_t *)__va (pud_val (pud) & ~PUD_MASKED_BITS ); } -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -static inline int map_kernel_page (unsigned long ea,unsigned long pa,pgprot_t prot) {if (radix_enabled ()) {
arch/powerpc/include/asm/nohash/32/pgtable.h +0 -2
@@ -51,8 +51,6 @@#define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08llx.\n", __FILE__, __LINE__, (unsigned long long)pgd_val(e))/* * This is the bottom of the PKMAP area with HIGHMEM or an arbitrary
arch/powerpc/include/asm/nohash/64/pgtable-4k.h +0 -3
@@ -82,9 +82,6 @@ extern struct page *p4d_page(p4d_t p4d);#endif /* !__ASSEMBLER__ */ -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %08lx.\n", __FILE__, __LINE__, pud_val(e)) -/* * On all 4K setups, remap_4k_pfn() equates to remap_pfn_range() */ #define remap_4k_pfn (vma, addr, pfn, prot) \
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -5
@@ -159,11 +159,6 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, __young; \ }) -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %08lx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -/* * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that * are !pte_none() && !pte_present().
arch/riscv/include/asm/page.h +0 -6
@@ -76,12 +76,6 @@ typedef struct page *pgtable_t;#define __pgd (x) ((pgd_t) { (x) })#define __pgprot (x) ((pgprot_t) { (x) }) -#ifdef CONFIG_64BIT -#define PTE_FMT "%016lx" -#else -#define PTE_FMT "%08lx" -#endif -#if defined(CONFIG_64BIT ) && defined(CONFIG_MMU )/* * We override this value as its generic definition uses __pa too early in
arch/riscv/include/asm/pgtable-64.h +0 -9
@@ -264,15 +264,6 @@ static inline unsigned long _pmd_pfn(pmd_t pmd)return __page_val_to_pfn (pmd_val (pmd)); } -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) - -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %016lx.\n", __FILE__, __LINE__, pud_val(e)) - -#define p4d_ERROR (e) \ - pr_err("%s:%d: bad p4d %016lx.\n", __FILE__, __LINE__, p4d_val(e)) -static inline void set_p4d (p4d_t *p4dp,p4d_t p4d) {if (pgtable_l4_enabled)
arch/riscv/include/asm/pgtable.h +0 -4
@@ -556,10 +556,6 @@ static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)return __pte ((pte_val (pte) & _PAGE_CHG_MASK) | newprot_val); } -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd " PTE_FMT ".\n", __FILE__, __LINE__, pgd_val(e)) - -/* Commit new configuration to MMU hardware */ static inline void update_mmu_cache_range(struct vm_fault *vmf, struct vm_area_struct *vma, unsigned long address,
arch/s390/include/asm/pgtable.h +0 -11
@@ -68,17 +68,6 @@ extern unsigned long zero_page_mask;/* TODO: s390 cannot support io_remap_pfn_range... */ -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %016lx.\n", __FILE__, __LINE__, pte_val(e)) -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %016lx.\n", __FILE__, __LINE__, pmd_val(e)) -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %016lx.\n", __FILE__, __LINE__, pud_val(e)) -#define p4d_ERROR (e) \ - pr_err("%s:%d: bad p4d %016lx.\n", __FILE__, __LINE__, p4d_val(e)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %016lx.\n", __FILE__, __LINE__, pgd_val(e)) -/* * The vmalloc and module area will always be on the topmost area of the * kernel mapping. 512GB are reserved for vmalloc by default.
arch/sh/include/asm/pgtable-3level.h +0 -3
@@ -25,9 +25,6 @@#define PTRS_PER_PMD ((1 << PGDIR_SHIFT) / PMD_SIZE) -#define pmd_ERROR (e) \ - printk("%s:%d: bad pmd %016llx.\n", __FILE__, __LINE__, pmd_val(e)) - typedef union { struct { unsigned long pmd_low;
arch/sh/include/asm/pgtable_32.h +0 -8
@@ -400,14 +400,6 @@ static inline unsigned long pmd_page_vaddr(pmd_t pmd)#define pmd_pfn (pmd) (__pa(pmd_val(pmd)) >> PAGE_SHIFT)#define pmd_page (pmd) (virt_to_page(pmd_val(pmd))) -#ifdef CONFIG_X2TLB -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %016llx.\n", __FILE__, __LINE__, pgd_val(e)) -#else -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %08lx.\n", __FILE__, __LINE__, pgd_val(e)) -#endif -/* * Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that * are !pte_none() && !pte_present().
arch/sparc/include/asm/pgtable_32.h +0 -3
@@ -40,9 +40,6 @@ void load_mmu(void);unsigned long calc_highpages (void );unsigned long __init bootmem_init (unsigned long *pages_avail); -#define pte_ERROR (e) __builtin_trap() -#define pmd_ERROR (e) __builtin_trap() -#define pgd_ERROR (e) __builtin_trap()#define PTRS_PER_PTE 64#define PTRS_PER_PMD 64
arch/sparc/include/asm/pgtable_64.h +0 -10
@@ -96,16 +96,6 @@ bool kern_addr_valid(unsigned long addr);#define PTRS_PER_PUD (1UL << PUD_BITS)#define PTRS_PER_PGD (1UL << PGDIR_BITS) -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pmd_val(e), __builtin_return_address(0)) -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pud_val(e), __builtin_return_address(0)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pgd_val(e), __builtin_return_address(0)) -#endif /* !(__ASSEMBLER__) */ /* PTE bits which are the same in SUN4U and SUN4V format. */
arch/um/include/asm/pgtable-2level.h +0 -7
@@ -24,13 +24,6 @@#define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE)#define PTRS_PER_PGD 1024 -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %p(%08lx).\n", __FILE__, __LINE__, &(e), \ - pte_val(e)) -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %p(%08lx).\n", __FILE__, __LINE__, &(e), \ - pgd_val(e)) -static inline int pgd_needsync (pgd_t pgd) {return 0 ; }static inline void pgd_mkuptodate (pgd_t pgd) { }
arch/um/include/asm/pgtable-4level.h +0 -13
@@ -42,19 +42,6 @@#define USER_PTRS_PER_PGD ((TASK_SIZE + (PGDIR_SIZE - 1)) / PGDIR_SIZE) -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %p(%016lx).\n", __FILE__, __LINE__, &(e), \ - pte_val(e)) -#define pmd_ERROR (e) \ - printk("%s:%d: bad pmd %p(%016lx).\n", __FILE__, __LINE__, &(e), \ - pmd_val(e)) -#define pud_ERROR (e) \ - printk("%s:%d: bad pud %p(%016lx).\n", __FILE__, __LINE__, &(e), \ - pud_val(e)) -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd %p(%016lx).\n", __FILE__, __LINE__, &(e), \ - pgd_val(e)) -#define pud_none (x) (!(pud_val(x) & ~_PAGE_NEEDSYNC))#define pud_bad (x) ((pud_val(x) & (~PAGE_MASK & ~_PAGE_USER)) != _KERNPG_TABLE)#define pud_present (x) (pud_val(x) & _PAGE_PRESENT)
arch/x86/include/asm/pgtable-2level.h +0 -5
@@ -2,11 +2,6 @@#ifndef _ASM_X86_PGTABLE_2LEVEL_H#define _ASM_X86_PGTABLE_2LEVEL_H -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %08lx\n", __FILE__, __LINE__, (e).pte_low) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %08lx\n", __FILE__, __LINE__, pgd_val(e)) -/* * Certain architectures need to do special things when PTEs * within a page table are directly modified. Thus, the following
arch/x86/include/asm/pgtable-3level.h +0 -11
@@ -8,17 +8,6 @@* * Copyright (C) 1999 Ingo Molnar <[email protected]> */ - -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %p(%08lx%08lx)\n", \ - __FILE__, __LINE__, &(e), (e).pte_high, (e).pte_low) -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %p(%016Lx)\n", \ - __FILE__, __LINE__, &(e), pmd_val(e)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %p(%016Lx)\n", \ - __FILE__, __LINE__, &(e), pgd_val(e)) -#define pxx_xchg64 (_pxx, _ptr, _val) ({ \ _pxx##val_t *_p = (_pxx##val_t *)_ptr; \ _pxx##val_t _o = *_p; \
arch/x86/include/asm/pgtable_64.h +0 -18
@@ -29,24 +29,6 @@ extern pgd_t init_top_pgt[];extern void paging_init (void );static inline void sync_initial_page_table (void ) { } -#define pte_ERROR (e) \ - pr_err("%s:%d: bad pte %p(%016lx)\n", \ - __FILE__, __LINE__, &(e), pte_val(e)) -#define pmd_ERROR (e) \ - pr_err("%s:%d: bad pmd %p(%016lx)\n", \ - __FILE__, __LINE__, &(e), pmd_val(e)) -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %p(%016lx)\n", \ - __FILE__, __LINE__, &(e), pud_val(e)) - -#define p4d_ERROR (e) \ - pr_err("%s:%d: bad p4d %p(%016lx)\n", \ - __FILE__, __LINE__, &(e), p4d_val(e)) - -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %p(%016lx)\n", \ - __FILE__, __LINE__, &(e), pgd_val(e)) -struct mm_struct ;#define mm_p4d_folded mm_p4d_folded
arch/xtensa/include/asm/pgtable.h +0 -4
@@ -204,10 +204,6 @@*/ #ifndef __ASSEMBLER__ -#define pte_ERROR (e) \ - printk("%s:%d: bad pte %08lx.\n", __FILE__, __LINE__, pte_val(e)) -#define pgd_ERROR (e) \ - printk("%s:%d: bad pgd entry %08lx.\n", __FILE__, __LINE__, pgd_val(e))#ifdef CONFIG_MMU extern pgd_t swapper_pg_dir[PAGE_SIZE /sizeof (pgd_t)];
include/asm-generic/pgtable-nop4d.h +0 -1
@@ -22,7 +22,6 @@ static inline int pgd_none(pgd_t pgd) { return 0; }static inline int pgd_bad (pgd_t pgd) {return 0 ; }static inline int pgd_present (pgd_t pgd) {return 1 ; }static inline void pgd_clear (pgd_t *pgd) { } -#define p4d_ERROR (p4d) (pgd_ERROR((p4d).pgd))#define pgd_populate (mm, pgd, p4d) do { } while (0)#define pgd_populate_safe (mm, pgd, p4d) do { } while (0)
include/asm-generic/pgtable-nopmd.h +0 -1
@@ -33,7 +33,6 @@ static inline int pud_present(pud_t pud) { return 1; }static inline int pud_user (pud_t pud) {return 0 ; }static inline int pud_leaf (pud_t pud) {return 0 ; }static inline void pud_clear (pud_t *pud) { } -#define pmd_ERROR (pmd) (pud_ERROR((pmd).pud))#define pud_populate (mm, pmd, pte) do { } while (0)
include/asm-generic/pgtable-nopud.h +0 -1
@@ -29,7 +29,6 @@ static inline int p4d_none(p4d_t p4d) { return 0; }static inline int p4d_bad (p4d_t p4d) {return 0 ; }static inline int p4d_present (p4d_t p4d) {return 1 ; }static inline void p4d_clear (p4d_t *p4d) { } -#define pud_ERROR (pud) (p4d_ERROR((pud).p4d))#define p4d_populate (mm, p4d, pud) do { } while (0)#define p4d_populate_safe (mm, p4d, pud) do { } while (0)
Signature · 1 line
2.43.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 19 lines
There are no more users left for any
pxd_ERROR()either in generic MM or in the platform MM. Hence all these platform macros along with their generic fallback could be dropped across the tree.
Quoted 8 lines
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
Quoted 19 lines · Anshuman Khandual
There are no more users left for any
pxd_ERROR()either in generic MM or in the platform MM. Hence all these platform macros along with their generic fallback could be dropped across the tree.
Quoted 8 lines
...> /*
Quoted 25 lines
* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
* are !pte_none() && !pte_present().arch/sparc/include/asm/pgtable_32.h +0
-3@@ -40,9 +40,6 @@ void load_mmu(void);unsigned long calc_highpages (void );unsigned long __init bootmem_init (unsigned long *pages_avail); -#define pte_ERROR (e) __builtin_trap() -#define pmd_ERROR (e) __builtin_trap() -#define pgd_ERROR (e) __builtin_trap()#define PTRS_PER_PTE 64#define PTRS_PER_PMD 64arch/sparc/include/asm/pgtable_64.h +0
-1@@ -96,16 +96,6 @@ bool kern_addr_valid(unsigned long addr);#define PTRS_PER_PUD (1UL << PUD_BITS)#define PTRS_PER_PGD (1UL << PGDIR_BITS) -#define pmd_ERROR (e) \
arch/sparc/include/asm/pgtable_64.h bool kern_addr_valid(unsigned long addr); · line 99
Quoted 10 lines
arch/sparc/include/asm/pgtable_64.h +0
-9-pr_err ("%s:%d: bad pmd %p(%016lx) seen at (%pS)\n" , \ - __FILE__, __LINE__, &(e), pmd_val(e), __builtin_return_address(0)) -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pud_val(e), __builtin_return_address(0)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pgd_val(e), __builtin_return_address(0)) -#endif /* !(__ASSEMBLER__) */
Perhaps a bit of a pity to lose the printing of the address of the pxd that a number of architectures did before this series, but i have no strong opinion.
Cheers,
Andreas
Quoted 69 lines · Andreas Larsson
Quoted 19 lines · Anshuman Khandual
There are no more users left for any
pxd_ERROR()either in generic MM or in the platform MM. Hence all these platform macros along with their generic fallback could be dropped across the tree.Quoted 8 lines
...> /*
Quoted 25 lines
* Encode/decode swap entries and swap PTEs. Swap PTEs are all PTEs that
* are !pte_none() && !pte_present().arch/sparc/include/asm/pgtable_32.h +0
-3@@ -40,9 +40,6 @@ void load_mmu(void);unsigned long calc_highpages (void );unsigned long __init bootmem_init (unsigned long *pages_avail); -#define pte_ERROR (e) __builtin_trap() -#define pmd_ERROR (e) __builtin_trap() -#define pgd_ERROR (e) __builtin_trap()#define PTRS_PER_PTE 64#define PTRS_PER_PMD 64arch/sparc/include/asm/pgtable_64.h +0
-1@@ -96,16 +96,6 @@ bool kern_addr_valid(unsigned long addr);#define PTRS_PER_PUD (1UL << PUD_BITS)#define PTRS_PER_PGD (1UL << PGDIR_BITS) -#define pmd_ERROR (e) \arch/sparc/include/asm/pgtable_64.h bool kern_addr_valid(unsigned long addr); · line 99
Quoted 10 lines
arch/sparc/include/asm/pgtable_64.h +0
-9-pr_err ("%s:%d: bad pmd %p(%016lx) seen at (%pS)\n" , \ - __FILE__, __LINE__, &(e), pmd_val(e), __builtin_return_address(0)) -#define pud_ERROR (e) \ - pr_err("%s:%d: bad pud %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pud_val(e), __builtin_return_address(0)) -#define pgd_ERROR (e) \ - pr_err("%s:%d: bad pgd %p(%016lx) seen at (%pS)\n", \ - __FILE__, __LINE__, &(e), pgd_val(e), __builtin_return_address(0)) -#endif /* !(__ASSEMBLER__) */ Perhaps a bit of a pity to lose the printing of the address of the pxd that a number of architectures did before this series, but i have no strong opinion.
Quoted 1 line
Thanks Andreas.
John Paul Adrian Glaubitz
maintainerHi Anshuman,
Quoted 3 lines · Anshuman Khandual
pxd_ERROR()macros have been provided by all platforms, which are very much identical and can be dropped off completely if these pgtable printing could be moved to callers in generic MM aka allpxd_clear_bad().
If pxd_ERROR() macros are really all identical, why not provide a common definiton of that macro? I'm always a bit concerned about such changes as there is always a risk to oversee arch-specific peculiarities.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Quoted 10 lines · John Paul Adrian Glaubitz
Hi Anshuman,
Quoted 3 lines · Anshuman Khandual
pxd_ERROR()macros have been provided by all platforms, which are very much identical and can be dropped off completely if these pgtable printing could be moved to callers in generic MM aka allpxd_clear_bad().If
pxd_ERROR()macros are really all identical, why not provide a common definiton of that macro? I'm always a bit concerned about such changes as there is always a risk to oversee arch-specific peculiarities.
We don't those platform macros any more after converting generic MM into using ptval_bytes_to_hex_str() which now handles different pgtable entry types.
Quoted 3 lines
Adrian
Andrew Morton
maintainerQuoted 7 lines · On Mon, 31 Aug 2026 11:13:22 +0530 Anshuman Khandual…
pxd_ERROR()macros have been provided by all platforms, which are very much identical and can be dropped off completely if these pgtable printing could be moved to callers in generic MM aka allpxd_clear_bad().But first cleanups and re-organizations are required in some platforms that are using these macros internally. Afterwards [pte|pmd|pud|p4d|pgd]_ERROR() macros have been completely dropped from the entire tree.
All was going nicely until...
Quoted 2 lines
This series is based on v7.3-rc1 after the following patch and has also been built tested on multiple platforms.
*what* following patch???
Oh well, I'll queue it all up and shall hope for the arch maintainer acks to roll in. Please.
Quoted 10 lines · Andrew Morton
Quoted 7 lines · On Mon, 31 Aug 2026 11:13:22 +0530 Anshuman Khandual…
pxd_ERROR()macros have been provided by all platforms, which are very much identical and can be dropped off completely if these pgtable printing could be moved to callers in generic MM aka allpxd_clear_bad().But first cleanups and re-organizations are required in some platforms that are using these macros internally. Afterwards [pte|pmd|pud|p4d|pgd]_ERROR() macros have been completely dropped from the entire tree.
Quoted 6 lines
All was going nicely until...
Quoted 2 lines
This series is based on v7.3-rc1 after the following patch and has also been built tested on multiple platforms.
*what* following patch???
The dependency patch has already been merged upstream.
092836fedd82 (mm: standardize printing for pgtable entries)
Please ignore this.
Quoted 3 lines
Oh well, I'll queue it all up and shall hope for the arch maintainer acks to roll in. Please.
Thanks !
This series was applied to riscv/linux.git (fixes) by Andrew Morton <[email protected]>:
Hello:
This series was applied to riscv/linux.git (fixes) by Andrew Morton <[email protected]>:
Quoted 9 lines · On Mon, 31 Aug 2026 11:13:22 +0530 you wrote:
pxd_ERROR()macros have been provided by all platforms, which are very much identical and can be dropped off completely if these pgtable printing could be moved to callers in generic MM aka allpxd_clear_bad().But first cleanups and re-organizations are required in some platforms that are using these macros internally. Afterwards [pte|pmd|pud|p4d|pgd]_ERROR() macros have been completely dropped from the entire tree.
[...]
Here is the summary with links:
- [1/8] mm: Make ptval_to_str() generally available (no matching commit)
- [2/8] mm: Stop using pxd_ERROR()
https://git.kernel.org/riscv/c/0666fc9d4432 - [3/8] loongarch/mm: Stop using pte_ERROR() https://git.kernel.org/riscv/c/ea8763ac3af7 - [4/8] parisc/mm: Directly use generic [pmd|pgd]_clear_bad() https://git.kernel.org/riscv/c/94d6c5466d1a - [5/8] sh/mm: Stop using pte_ERROR() https://git.kernel.org/riscv/c/6858e42cc2bc - [6/8] sh/mm: Stop using [p4d|pud|pmd]_ERROR() https://git.kernel.org/riscv/c/3b225ce37f62 - [7/8] sh/mm: Stop using pgd_ERROR() https://git.kernel.org/riscv/c/66a0441a1791 - [8/8] mm: Drop pxd_ERROR() https://git.kernel.org/riscv/c/c970236c300f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
David Hildenbrand (Arm)
maintainerQuoted 4 lines · On 11/1/26 23:16, [email protected] wrote:
Hello:
This series was applied to riscv/linux.git (fixes) by Andrew Morton <[email protected]>:
What's up with these weird messages? Can we ... stop them please?
Signature · 3 lines
Cheers, David