提交 6e4beb5e 编写于 作者: R Russell King

ARM: pgtable: use pXd_none_or_clear_bad() in pgd_free()

Remove knowledge of the 2-level wrapping in pgd_free(), and use the
pXd_none_or_clear_bad() macros when checking the entries.
Signed-off-by: NRussell King <rmk+kernel@arm.linux.org.uk>
上级 b0d03745
...@@ -73,28 +73,29 @@ pgd_t *pgd_alloc(struct mm_struct *mm) ...@@ -73,28 +73,29 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
return NULL; return NULL;
} }
void pgd_free(struct mm_struct *mm, pgd_t *pgd) void pgd_free(struct mm_struct *mm, pgd_t *pgd_base)
{ {
pgd_t *pgd;
pmd_t *pmd; pmd_t *pmd;
pgtable_t pte; pgtable_t pte;
if (!pgd) if (!pgd_base)
return; return;
/* pgd is always present and good */ pgd = pgd_base + pgd_index(0);
pmd = pmd_off(pgd, 0); if (pgd_none_or_clear_bad(pgd))
if (pmd_none(*pmd)) goto no_pgd;
goto free;
if (pmd_bad(*pmd)) { pmd = pmd_offset(pgd, 0);
pmd_ERROR(*pmd); if (pmd_none_or_clear_bad(pmd))
pmd_clear(pmd); goto no_pmd;
goto free;
}
pte = pmd_pgtable(*pmd); pte = pmd_pgtable(*pmd);
pmd_clear(pmd); pmd_clear(pmd);
pte_free(mm, pte); pte_free(mm, pte);
no_pmd:
pgd_clear(pgd);
pmd_free(mm, pmd); pmd_free(mm, pmd);
free: no_pgd:
free_pages((unsigned long) pgd, 2); free_pages((unsigned long) pgd_base, 2);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册