Commit 9a996c67 authored by Heiko Carstens's avatar Heiko Carstens

s390/vmemmap: coding style updates

Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
parent 2c114df0
...@@ -169,17 +169,17 @@ static int __ref modify_pte_table(pmd_t *pmd, unsigned long addr, ...@@ -169,17 +169,17 @@ static int __ref modify_pte_table(pmd_t *pmd, unsigned long addr,
pte_clear(&init_mm, addr, pte); pte_clear(&init_mm, addr, pte);
} else if (pte_none(*pte)) { } else if (pte_none(*pte)) {
if (!direct) { if (!direct) {
void *new_page = vmemmap_alloc_block(PAGE_SIZE, void *new_page = vmemmap_alloc_block(PAGE_SIZE, NUMA_NO_NODE);
NUMA_NO_NODE);
if (!new_page) if (!new_page)
goto out; goto out;
pte_val(*pte) = __pa(new_page) | prot; pte_val(*pte) = __pa(new_page) | prot;
} else } else {
pte_val(*pte) = addr | prot; pte_val(*pte) = addr | prot;
} else }
} else {
continue; continue;
}
pages++; pages++;
} }
ret = 0; ret = 0;
...@@ -196,10 +196,10 @@ static void try_free_pte_table(pmd_t *pmd, unsigned long start) ...@@ -196,10 +196,10 @@ static void try_free_pte_table(pmd_t *pmd, unsigned long start)
/* We can safely assume this is fully in 1:1 mapping & vmemmap area */ /* We can safely assume this is fully in 1:1 mapping & vmemmap area */
pte = pte_offset_kernel(pmd, start); pte = pte_offset_kernel(pmd, start);
for (i = 0; i < PTRS_PER_PTE; i++, pte++) for (i = 0; i < PTRS_PER_PTE; i++, pte++) {
if (!pte_none(*pte)) if (!pte_none(*pte))
return; return;
}
vmem_pte_free(__va(pmd_deref(*pmd))); vmem_pte_free(__va(pmd_deref(*pmd)));
pmd_clear(pmd); pmd_clear(pmd);
} }
...@@ -220,7 +220,6 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr, ...@@ -220,7 +220,6 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
pmd = pmd_offset(pud, addr); pmd = pmd_offset(pud, addr);
for (; addr < end; addr = next, pmd++) { for (; addr < end; addr = next, pmd++) {
next = pmd_addr_end(addr, end); next = pmd_addr_end(addr, end);
if (!add) { if (!add) {
if (pmd_none(*pmd)) if (pmd_none(*pmd))
continue; continue;
...@@ -228,14 +227,11 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr, ...@@ -228,14 +227,11 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
if (IS_ALIGNED(addr, PMD_SIZE) && if (IS_ALIGNED(addr, PMD_SIZE) &&
IS_ALIGNED(next, PMD_SIZE)) { IS_ALIGNED(next, PMD_SIZE)) {
if (!direct) if (!direct)
vmem_free_pages(pmd_deref(*pmd), vmem_free_pages(pmd_deref(*pmd), get_order(PMD_SIZE));
get_order(PMD_SIZE));
pmd_clear(pmd); pmd_clear(pmd);
pages++; pages++;
} else if (!direct && } else if (!direct && vmemmap_unuse_sub_pmd(addr, next)) {
vmemmap_unuse_sub_pmd(addr, next)) { vmem_free_pages(pmd_deref(*pmd), get_order(PMD_SIZE));
vmem_free_pages(pmd_deref(*pmd),
get_order(PMD_SIZE));
pmd_clear(pmd); pmd_clear(pmd);
} }
continue; continue;
...@@ -258,14 +254,12 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr, ...@@ -258,14 +254,12 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
* page tables since vmemmap_populate gets * page tables since vmemmap_populate gets
* called for each section separately. * called for each section separately.
*/ */
new_page = vmemmap_alloc_block(PMD_SIZE, new_page = vmemmap_alloc_block(PMD_SIZE, NUMA_NO_NODE);
NUMA_NO_NODE);
if (new_page) { if (new_page) {
pmd_val(*pmd) = __pa(new_page) | prot; pmd_val(*pmd) = __pa(new_page) | prot;
if (!IS_ALIGNED(addr, PMD_SIZE) || if (!IS_ALIGNED(addr, PMD_SIZE) ||
!IS_ALIGNED(next, PMD_SIZE)) { !IS_ALIGNED(next, PMD_SIZE)) {
vmemmap_use_new_sub_pmd(addr, vmemmap_use_new_sub_pmd(addr, next);
next);
} }
continue; continue;
} }
...@@ -279,7 +273,6 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr, ...@@ -279,7 +273,6 @@ static int __ref modify_pmd_table(pud_t *pud, unsigned long addr,
vmemmap_use_sub_pmd(addr, next); vmemmap_use_sub_pmd(addr, next);
continue; continue;
} }
ret = modify_pte_table(pmd, addr, next, add, direct); ret = modify_pte_table(pmd, addr, next, add, direct);
if (ret) if (ret)
goto out; goto out;
...@@ -306,12 +299,10 @@ static void try_free_pmd_table(pud_t *pud, unsigned long start) ...@@ -306,12 +299,10 @@ static void try_free_pmd_table(pud_t *pud, unsigned long start)
if (start < KASAN_SHADOW_END && KASAN_SHADOW_START > end) if (start < KASAN_SHADOW_END && KASAN_SHADOW_START > end)
return; return;
#endif #endif
pmd = pmd_offset(pud, start); pmd = pmd_offset(pud, start);
for (i = 0; i < PTRS_PER_PMD; i++, pmd++) for (i = 0; i < PTRS_PER_PMD; i++, pmd++)
if (!pmd_none(*pmd)) if (!pmd_none(*pmd))
return; return;
vmem_free_pages(pud_deref(*pud), CRST_ALLOC_ORDER); vmem_free_pages(pud_deref(*pud), CRST_ALLOC_ORDER);
pud_clear(pud); pud_clear(pud);
} }
...@@ -327,11 +318,9 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end, ...@@ -327,11 +318,9 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,
prot = pgprot_val(REGION3_KERNEL); prot = pgprot_val(REGION3_KERNEL);
if (!MACHINE_HAS_NX) if (!MACHINE_HAS_NX)
prot &= ~_REGION_ENTRY_NOEXEC; prot &= ~_REGION_ENTRY_NOEXEC;
pud = pud_offset(p4d, addr); pud = pud_offset(p4d, addr);
for (; addr < end; addr = next, pud++) { for (; addr < end; addr = next, pud++) {
next = pud_addr_end(addr, end); next = pud_addr_end(addr, end);
if (!add) { if (!add) {
if (pud_none(*pud)) if (pud_none(*pud))
continue; continue;
...@@ -356,9 +345,9 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end, ...@@ -356,9 +345,9 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,
if (!pmd) if (!pmd)
goto out; goto out;
pud_populate(&init_mm, pud, pmd); pud_populate(&init_mm, pud, pmd);
} else if (pud_large(*pud)) } else if (pud_large(*pud)) {
continue; continue;
}
ret = modify_pmd_table(pud, addr, next, add, direct); ret = modify_pmd_table(pud, addr, next, add, direct);
if (ret) if (ret)
goto out; goto out;
...@@ -387,10 +376,10 @@ static void try_free_pud_table(p4d_t *p4d, unsigned long start) ...@@ -387,10 +376,10 @@ static void try_free_pud_table(p4d_t *p4d, unsigned long start)
#endif #endif
pud = pud_offset(p4d, start); pud = pud_offset(p4d, start);
for (i = 0; i < PTRS_PER_PUD; i++, pud++) for (i = 0; i < PTRS_PER_PUD; i++, pud++) {
if (!pud_none(*pud)) if (!pud_none(*pud))
return; return;
}
vmem_free_pages(p4d_deref(*p4d), CRST_ALLOC_ORDER); vmem_free_pages(p4d_deref(*p4d), CRST_ALLOC_ORDER);
p4d_clear(p4d); p4d_clear(p4d);
} }
...@@ -406,7 +395,6 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long end, ...@@ -406,7 +395,6 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long end,
p4d = p4d_offset(pgd, addr); p4d = p4d_offset(pgd, addr);
for (; addr < end; addr = next, p4d++) { for (; addr < end; addr = next, p4d++) {
next = p4d_addr_end(addr, end); next = p4d_addr_end(addr, end);
if (!add) { if (!add) {
if (p4d_none(*p4d)) if (p4d_none(*p4d))
continue; continue;
...@@ -415,7 +403,6 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long end, ...@@ -415,7 +403,6 @@ static int modify_p4d_table(pgd_t *pgd, unsigned long addr, unsigned long end,
if (!pud) if (!pud)
goto out; goto out;
} }
ret = modify_pud_table(p4d, addr, next, add, direct); ret = modify_pud_table(p4d, addr, next, add, direct);
if (ret) if (ret)
goto out; goto out;
...@@ -442,10 +429,10 @@ static void try_free_p4d_table(pgd_t *pgd, unsigned long start) ...@@ -442,10 +429,10 @@ static void try_free_p4d_table(pgd_t *pgd, unsigned long start)
#endif #endif
p4d = p4d_offset(pgd, start); p4d = p4d_offset(pgd, start);
for (i = 0; i < PTRS_PER_P4D; i++, p4d++) for (i = 0; i < PTRS_PER_P4D; i++, p4d++) {
if (!p4d_none(*p4d)) if (!p4d_none(*p4d))
return; return;
}
vmem_free_pages(pgd_deref(*pgd), CRST_ALLOC_ORDER); vmem_free_pages(pgd_deref(*pgd), CRST_ALLOC_ORDER);
pgd_clear(pgd); pgd_clear(pgd);
} }
...@@ -460,7 +447,6 @@ static int modify_pagetable(unsigned long start, unsigned long end, bool add, ...@@ -460,7 +447,6 @@ static int modify_pagetable(unsigned long start, unsigned long end, bool add,
if (WARN_ON_ONCE(!PAGE_ALIGNED(start | end))) if (WARN_ON_ONCE(!PAGE_ALIGNED(start | end)))
return -EINVAL; return -EINVAL;
for (addr = start; addr < end; addr = next) { for (addr = start; addr < end; addr = next) {
next = pgd_addr_end(addr, end); next = pgd_addr_end(addr, end);
pgd = pgd_offset_k(addr); pgd = pgd_offset_k(addr);
...@@ -474,7 +460,6 @@ static int modify_pagetable(unsigned long start, unsigned long end, bool add, ...@@ -474,7 +460,6 @@ static int modify_pagetable(unsigned long start, unsigned long end, bool add,
goto out; goto out;
pgd_populate(&init_mm, pgd, p4d); pgd_populate(&init_mm, pgd, p4d);
} }
ret = modify_p4d_table(pgd, addr, next, add, direct); ret = modify_p4d_table(pgd, addr, next, add, direct);
if (ret) if (ret)
goto out; goto out;
...@@ -518,7 +503,7 @@ static void vmem_remove_range(unsigned long start, unsigned long size) ...@@ -518,7 +503,7 @@ static void vmem_remove_range(unsigned long start, unsigned long size)
* Add a backed mem_map array to the virtual mem_map array. * Add a backed mem_map array to the virtual mem_map array.
*/ */
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
struct vmem_altmap *altmap) struct vmem_altmap *altmap)
{ {
int ret; int ret;
...@@ -532,7 +517,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node, ...@@ -532,7 +517,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
} }
void vmemmap_free(unsigned long start, unsigned long end, void vmemmap_free(unsigned long start, unsigned long end,
struct vmem_altmap *altmap) struct vmem_altmap *altmap)
{ {
mutex_lock(&vmem_mutex); mutex_lock(&vmem_mutex);
remove_pagetable(start, end, false); remove_pagetable(start, end, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment