[PATCH v4 05/20] LoongArch: mm: define pud_leaf() only when PUD exists

From: Yeoreum Yun

Date: Tue Dec 01 2026 - 12:08:19 EST


From: "David Hildenbrand (Arm)" <david@xxxxxxxxxx>

In include/asm-generic/pgtable-nopmd.h, pud_leaf() is hardcoded
to return false as inline function, but it misses the "define pud_leaf
pud_leaf" part.

To prepare for fixing that, define pud_leaf() only when
__PAGETABLE_PMD_FOLDED isn't defined.

Tested-by: Muhammad Usama Anjum <usama.anjum@xxxxxxx>
Link: [1] https://lore.kernel.org/all/0019d675-ce3d-4a5c-89ed-f126c45145c9@xxxxxxxxxx/
Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
---
arch/loongarch/include/asm/pgtable.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/loongarch/include/asm/pgtable.h b/arch/loongarch/include/asm/pgtable.h
index f876031351319..9a62b87c246de 100644
--- a/arch/loongarch/include/asm/pgtable.h
+++ b/arch/loongarch/include/asm/pgtable.h
@@ -631,7 +631,9 @@ static inline long pmd_protnone(pmd_t pmd)
#endif /* CONFIG_ARCH_HAS_PTE_PROTNONE */

#define pmd_leaf(pmd) ((pmd_val(pmd) & _PAGE_HUGE) != 0)
+#ifndef __PAGETABLE_PMD_FOLDED
#define pud_leaf(pud) ((pud_val(pud) & _PAGE_HUGE) != 0)
+#endif

/*
* We provide our own get_unmapped area to cope with the virtual aliasing

--
2.43.0