LoongArch: Code improvements in function pcpu_populate_pte()
Do some code improvements in function pcpu_populate_pte(): 1. Add memory allocation failure handling; 2. Replace pgd_populate() with p4d_populate(), it will be useful if there are four-level page tables. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
parent
ad3ff10561
commit
f33efa905c
@ -73,32 +73,34 @@ void __init pcpu_populate_pte(unsigned long addr)
|
|||||||
pmd_t *pmd;
|
pmd_t *pmd;
|
||||||
|
|
||||||
if (p4d_none(*p4d)) {
|
if (p4d_none(*p4d)) {
|
||||||
pud_t *new;
|
pud = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
||||||
|
if (!pud)
|
||||||
new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
panic("%s: Failed to allocate memory\n", __func__);
|
||||||
pgd_populate(&init_mm, pgd, new);
|
p4d_populate(&init_mm, p4d, pud);
|
||||||
#ifndef __PAGETABLE_PUD_FOLDED
|
#ifndef __PAGETABLE_PUD_FOLDED
|
||||||
pud_init(new);
|
pud_init(pud);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pud = pud_offset(p4d, addr);
|
pud = pud_offset(p4d, addr);
|
||||||
if (pud_none(*pud)) {
|
if (pud_none(*pud)) {
|
||||||
pmd_t *new;
|
pmd = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
||||||
|
if (!pmd)
|
||||||
new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
panic("%s: Failed to allocate memory\n", __func__);
|
||||||
pud_populate(&init_mm, pud, new);
|
pud_populate(&init_mm, pud, pmd);
|
||||||
#ifndef __PAGETABLE_PMD_FOLDED
|
#ifndef __PAGETABLE_PMD_FOLDED
|
||||||
pmd_init(new);
|
pmd_init(pmd);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
pmd = pmd_offset(pud, addr);
|
pmd = pmd_offset(pud, addr);
|
||||||
if (!pmd_present(*pmd)) {
|
if (!pmd_present(*pmd)) {
|
||||||
pte_t *new;
|
pte_t *pte;
|
||||||
|
|
||||||
new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
pte = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
||||||
pmd_populate_kernel(&init_mm, pmd, new);
|
if (!pte)
|
||||||
|
panic("%s: Failed to allocate memory\n", __func__);
|
||||||
|
pmd_populate_kernel(&init_mm, pmd, pte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user