We want to rework how set_pXd() behaves for generic comiple-time folded
page tables by disallowing its use and triggering a compile-time error
when it is used improperly, ensuring that the actual first-level
set_pXd() function is used instead.

Therefore, call the proper set_pXd() in case of generic compile-time
folded pgtable to handle vmalloc_fault case with pXd_present() and
drop pgd_present() and set_pgd() usage since mips doesn't support
5 page-table levels.

There should be no functional change.

Signed-off-by: Yeoreum Yun <[email protected]>
---
 arch/mips/mm/fault.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 37fedeaca2e9a..4ad281a3bf97a 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -289,28 +289,31 @@ static void __do_page_fault(struct pt_regs *regs, 
unsigned long write,
                pmd_t *pmd, *pmd_k;
                pte_t *pte_k;
 
+               BUILD_BUG_ON(CONFIG_PGTABLE_LEVELS > 4);
+
                pgd = (pgd_t *) pgd_current[raw_smp_processor_id()] + offset;
                pgd_k = init_mm.pgd + offset;
 
-               if (!pgd_present(*pgd_k))
-                       goto no_context;
-               set_pgd(pgd, *pgd_k);
-
                p4d = p4d_offset(pgd, address);
                p4d_k = p4d_offset(pgd_k, address);
                if (!p4d_present(*p4d_k))
                        goto no_context;
+               if (CONFIG_PGTABLE_LEVELS == 4)
+                       set_p4d(p4d, *p4d_k);
 
                pud = pud_offset(p4d, address);
                pud_k = pud_offset(p4d_k, address);
                if (!pud_present(*pud_k))
                        goto no_context;
+               if (CONFIG_PGTABLE_LEVELS == 3)
+                       set_pud(pud, *pud_k);
 
                pmd = pmd_offset(pud, address);
                pmd_k = pmd_offset(pud_k, address);
                if (!pmd_present(*pmd_k))
                        goto no_context;
-               set_pmd(pmd, *pmd_k);
+               if (CONFIG_PGTABLE_LEVELS == 2)
+                       set_pmd(pmd, *pmd_k);
 
                pte_k = pte_offset_kernel(pmd_k, address);
                if (!pte_present(*pte_k))
-- 
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}


Reply via email to