mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
MIPS&LoongArch&NIOS2: adjust prototypes of p?d_init()
Patch series "mm/sparse-vmemmap: Generalise helpers and enable for LoongArch", v14. This series is in order to enable sparse-vmemmap for LoongArch. But LoongArch cannot use generic helpers directly because MIPS&LoongArch need to call pgd_init()/pud_init()/pmd_init() when populating page tables. So we adjust the prototypes of p?d_init() to make generic helpers can call them, then enable sparse-vmemmap with generic helpers, and to be further, generalise vmemmap_populate_hugepages() for ARM64, X86 and LoongArch. This patch (of 4): We are preparing to add sparse vmemmap support to LoongArch. MIPS and LoongArch need to call pgd_init()/pud_init()/pmd_init() when populating page tables, so adjust their prototypes to make generic helpers can call them. NIOS2 declares pmd_init() but doesn't use, just remove it to avoid build errors. Link: https://lkml.kernel.org/r/20221027125253.3458989-1-chenhuacai@loongson.cn Link: https://lkml.kernel.org/r/20221027125253.3458989-2-chenhuacai@loongson.cn Signed-off-by: Feiyang Chen <chenfeiyang@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Cc: Dinh Nguyen <dinguyen@kernel.org> Cc: Guo Ren <guoren@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de> Cc: Will Deacon <will@kernel.org> Cc: Xuefeng Li <lixuefeng@loongson.cn> Cc: Xuerui Wang <kernel@xen0n.name> Cc: Min Zhou <zhoumin@loongson.cn> Cc: Muchun Song <songmuchun@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
85716a80c1
commit
22c4e80466
@ -42,15 +42,6 @@ static inline void p4d_populate(struct mm_struct *mm, p4d_t *p4d, pud_t *pud)
|
||||
|
||||
extern void pagetable_init(void);
|
||||
|
||||
/*
|
||||
* Initialize a new pmd table with invalid pointers.
|
||||
*/
|
||||
extern void pmd_init(unsigned long page, unsigned long pagetable);
|
||||
|
||||
/*
|
||||
* Initialize a new pgd / pmd table with invalid pointers.
|
||||
*/
|
||||
extern void pgd_init(unsigned long page);
|
||||
extern pgd_t *pgd_alloc(struct mm_struct *mm);
|
||||
|
||||
#define __pte_free_tlb(tlb, pte, address) \
|
||||
@ -76,7 +67,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
|
||||
}
|
||||
|
||||
pmd = (pmd_t *)page_address(pg);
|
||||
pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
|
||||
pmd_init(pmd);
|
||||
return pmd;
|
||||
}
|
||||
|
||||
@ -92,7 +83,7 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
|
||||
|
||||
pud = (pud_t *) __get_free_page(GFP_KERNEL);
|
||||
if (pud)
|
||||
pud_init((unsigned long)pud, (unsigned long)invalid_pmd_table);
|
||||
pud_init(pud);
|
||||
return pud;
|
||||
}
|
||||
|
||||
|
@ -237,11 +237,11 @@ extern void set_pmd_at(struct mm_struct *mm, unsigned long addr, pmd_t *pmdp, pm
|
||||
#define pfn_pmd(pfn, prot) __pmd(((pfn) << _PFN_SHIFT) | pgprot_val(prot))
|
||||
|
||||
/*
|
||||
* Initialize a new pgd / pmd table with invalid pointers.
|
||||
* Initialize a new pgd / pud / pmd table with invalid pointers.
|
||||
*/
|
||||
extern void pgd_init(unsigned long page);
|
||||
extern void pud_init(unsigned long page, unsigned long pagetable);
|
||||
extern void pmd_init(unsigned long page, unsigned long pagetable);
|
||||
extern void pgd_init(void *addr);
|
||||
extern void pud_init(void *addr);
|
||||
extern void pmd_init(void *addr);
|
||||
|
||||
/*
|
||||
* Non-present pages: high 40 bits are offset, next 8 bits type,
|
||||
|
@ -78,7 +78,7 @@ void __init pcpu_populate_pte(unsigned long addr)
|
||||
new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
||||
pgd_populate(&init_mm, pgd, new);
|
||||
#ifndef __PAGETABLE_PUD_FOLDED
|
||||
pud_init((unsigned long)new, (unsigned long)invalid_pmd_table);
|
||||
pud_init(new);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ void __init pcpu_populate_pte(unsigned long addr)
|
||||
new = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
|
||||
pud_populate(&init_mm, pud, new);
|
||||
#ifndef __PAGETABLE_PMD_FOLDED
|
||||
pmd_init((unsigned long)new, (unsigned long)invalid_pte_table);
|
||||
pmd_init(new);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
|
||||
ret = (pgd_t *) __get_free_page(GFP_KERNEL);
|
||||
if (ret) {
|
||||
init = pgd_offset(&init_mm, 0UL);
|
||||
pgd_init((unsigned long)ret);
|
||||
pgd_init(ret);
|
||||
memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
|
||||
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
||||
}
|
||||
@ -25,7 +25,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pgd_alloc);
|
||||
|
||||
void pgd_init(unsigned long page)
|
||||
void pgd_init(void *addr)
|
||||
{
|
||||
unsigned long *p, *end;
|
||||
unsigned long entry;
|
||||
@ -38,7 +38,7 @@ void pgd_init(unsigned long page)
|
||||
entry = (unsigned long)invalid_pte_table;
|
||||
#endif
|
||||
|
||||
p = (unsigned long *) page;
|
||||
p = (unsigned long *)addr;
|
||||
end = p + PTRS_PER_PGD;
|
||||
|
||||
do {
|
||||
@ -56,11 +56,12 @@ void pgd_init(unsigned long page)
|
||||
EXPORT_SYMBOL_GPL(pgd_init);
|
||||
|
||||
#ifndef __PAGETABLE_PMD_FOLDED
|
||||
void pmd_init(unsigned long addr, unsigned long pagetable)
|
||||
void pmd_init(void *addr)
|
||||
{
|
||||
unsigned long *p, *end;
|
||||
unsigned long pagetable = (unsigned long)invalid_pte_table;
|
||||
|
||||
p = (unsigned long *) addr;
|
||||
p = (unsigned long *)addr;
|
||||
end = p + PTRS_PER_PMD;
|
||||
|
||||
do {
|
||||
@ -79,9 +80,10 @@ EXPORT_SYMBOL_GPL(pmd_init);
|
||||
#endif
|
||||
|
||||
#ifndef __PAGETABLE_PUD_FOLDED
|
||||
void pud_init(unsigned long addr, unsigned long pagetable)
|
||||
void pud_init(void *addr)
|
||||
{
|
||||
unsigned long *p, *end;
|
||||
unsigned long pagetable = (unsigned long)invalid_pmd_table;
|
||||
|
||||
p = (unsigned long *)addr;
|
||||
end = p + PTRS_PER_PUD;
|
||||
@ -98,6 +100,7 @@ void pud_init(unsigned long addr, unsigned long pagetable)
|
||||
p[-1] = pagetable;
|
||||
} while (p != end);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pud_init);
|
||||
#endif
|
||||
|
||||
pmd_t mk_pmd(struct page *page, pgprot_t prot)
|
||||
@ -119,12 +122,12 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr,
|
||||
void __init pagetable_init(void)
|
||||
{
|
||||
/* Initialize the entire pgd. */
|
||||
pgd_init((unsigned long)swapper_pg_dir);
|
||||
pgd_init((unsigned long)invalid_pg_dir);
|
||||
pgd_init(swapper_pg_dir);
|
||||
pgd_init(invalid_pg_dir);
|
||||
#ifndef __PAGETABLE_PUD_FOLDED
|
||||
pud_init((unsigned long)invalid_pud_table, (unsigned long)invalid_pmd_table);
|
||||
pud_init(invalid_pud_table);
|
||||
#endif
|
||||
#ifndef __PAGETABLE_PMD_FOLDED
|
||||
pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
|
||||
pmd_init(invalid_pmd_table);
|
||||
#endif
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
|
||||
/*
|
||||
* Initialize a new pmd table with invalid pointers.
|
||||
*/
|
||||
extern void pmd_init(unsigned long page, unsigned long pagetable);
|
||||
extern void pmd_init(void *addr);
|
||||
|
||||
#ifndef __PAGETABLE_PMD_FOLDED
|
||||
|
||||
@ -44,9 +44,9 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize a new pgd / pmd table with invalid pointers.
|
||||
* Initialize a new pgd table with invalid pointers.
|
||||
*/
|
||||
extern void pgd_init(unsigned long page);
|
||||
extern void pgd_init(void *addr);
|
||||
extern pgd_t *pgd_alloc(struct mm_struct *mm);
|
||||
|
||||
static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
|
||||
@ -77,7 +77,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
|
||||
}
|
||||
|
||||
pmd = (pmd_t *)page_address(pg);
|
||||
pmd_init((unsigned long)pmd, (unsigned long)invalid_pte_table);
|
||||
pmd_init(pmd);
|
||||
return pmd;
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address)
|
||||
|
||||
pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_TABLE_ORDER);
|
||||
if (pud)
|
||||
pud_init((unsigned long)pud, (unsigned long)invalid_pmd_table);
|
||||
pud_init(pud);
|
||||
return pud;
|
||||
}
|
||||
|
||||
|
@ -313,11 +313,11 @@ static inline pmd_t *pud_pgtable(pud_t pud)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize a new pgd / pmd table with invalid pointers.
|
||||
* Initialize a new pgd / pud / pmd table with invalid pointers.
|
||||
*/
|
||||
extern void pgd_init(unsigned long page);
|
||||
extern void pud_init(unsigned long page, unsigned long pagetable);
|
||||
extern void pmd_init(unsigned long page, unsigned long pagetable);
|
||||
extern void pgd_init(void *addr);
|
||||
extern void pud_init(void *addr);
|
||||
extern void pmd_init(void *addr);
|
||||
|
||||
/*
|
||||
* Non-present pages: high 40 bits are offset, next 8 bits type,
|
||||
|
@ -122,8 +122,7 @@ static pte_t *kvm_mips_walk_pgd(pgd_t *pgd, struct kvm_mmu_memory_cache *cache,
|
||||
if (!cache)
|
||||
return NULL;
|
||||
new_pmd = kvm_mmu_memory_cache_alloc(cache);
|
||||
pmd_init((unsigned long)new_pmd,
|
||||
(unsigned long)invalid_pte_table);
|
||||
pmd_init(new_pmd);
|
||||
pud_populate(NULL, pud, new_pmd);
|
||||
}
|
||||
pmd = pmd_offset(pud, addr);
|
||||
|
@ -13,9 +13,9 @@
|
||||
#include <asm/pgalloc.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
||||
void pgd_init(unsigned long page)
|
||||
void pgd_init(void *addr)
|
||||
{
|
||||
unsigned long *p = (unsigned long *) page;
|
||||
unsigned long *p = (unsigned long *)addr;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < USER_PTRS_PER_PGD; i+=8) {
|
||||
@ -61,9 +61,8 @@ void __init pagetable_init(void)
|
||||
#endif
|
||||
|
||||
/* Initialize the entire pgd. */
|
||||
pgd_init((unsigned long)swapper_pg_dir);
|
||||
pgd_init((unsigned long)swapper_pg_dir
|
||||
+ sizeof(pgd_t) * USER_PTRS_PER_PGD);
|
||||
pgd_init(swapper_pg_dir);
|
||||
pgd_init(&swapper_pg_dir[USER_PTRS_PER_PGD]);
|
||||
|
||||
pgd_base = swapper_pg_dir;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <asm/pgalloc.h>
|
||||
#include <asm/tlbflush.h>
|
||||
|
||||
void pgd_init(unsigned long page)
|
||||
void pgd_init(void *addr)
|
||||
{
|
||||
unsigned long *p, *end;
|
||||
unsigned long entry;
|
||||
@ -26,7 +26,7 @@ void pgd_init(unsigned long page)
|
||||
entry = (unsigned long)invalid_pte_table;
|
||||
#endif
|
||||
|
||||
p = (unsigned long *) page;
|
||||
p = (unsigned long *) addr;
|
||||
end = p + PTRS_PER_PGD;
|
||||
|
||||
do {
|
||||
@ -43,11 +43,12 @@ void pgd_init(unsigned long page)
|
||||
}
|
||||
|
||||
#ifndef __PAGETABLE_PMD_FOLDED
|
||||
void pmd_init(unsigned long addr, unsigned long pagetable)
|
||||
void pmd_init(void *addr)
|
||||
{
|
||||
unsigned long *p, *end;
|
||||
unsigned long pagetable = (unsigned long)invalid_pte_table;
|
||||
|
||||
p = (unsigned long *) addr;
|
||||
p = (unsigned long *)addr;
|
||||
end = p + PTRS_PER_PMD;
|
||||
|
||||
do {
|
||||
@ -66,9 +67,10 @@ EXPORT_SYMBOL_GPL(pmd_init);
|
||||
#endif
|
||||
|
||||
#ifndef __PAGETABLE_PUD_FOLDED
|
||||
void pud_init(unsigned long addr, unsigned long pagetable)
|
||||
void pud_init(void *addr)
|
||||
{
|
||||
unsigned long *p, *end;
|
||||
unsigned long pagetable = (unsigned long)invalid_pmd_table;
|
||||
|
||||
p = (unsigned long *)addr;
|
||||
end = p + PTRS_PER_PUD;
|
||||
@ -108,12 +110,12 @@ void __init pagetable_init(void)
|
||||
pgd_t *pgd_base;
|
||||
|
||||
/* Initialize the entire pgd. */
|
||||
pgd_init((unsigned long)swapper_pg_dir);
|
||||
pgd_init(swapper_pg_dir);
|
||||
#ifndef __PAGETABLE_PUD_FOLDED
|
||||
pud_init((unsigned long)invalid_pud_table, (unsigned long)invalid_pmd_table);
|
||||
pud_init(invalid_pud_table);
|
||||
#endif
|
||||
#ifndef __PAGETABLE_PMD_FOLDED
|
||||
pmd_init((unsigned long)invalid_pmd_table, (unsigned long)invalid_pte_table);
|
||||
pmd_init(invalid_pmd_table);
|
||||
#endif
|
||||
pgd_base = swapper_pg_dir;
|
||||
/*
|
||||
|
@ -15,7 +15,7 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
|
||||
ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER);
|
||||
if (ret) {
|
||||
init = pgd_offset(&init_mm, 0UL);
|
||||
pgd_init((unsigned long)ret);
|
||||
pgd_init(ret);
|
||||
memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,
|
||||
(PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t));
|
||||
}
|
||||
|
@ -26,11 +26,6 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd,
|
||||
set_pmd(pmd, __pmd((unsigned long)page_address(pte)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize a new pmd table with invalid pointers.
|
||||
*/
|
||||
extern void pmd_init(unsigned long page, unsigned long pagetable);
|
||||
|
||||
extern pgd_t *pgd_alloc(struct mm_struct *mm);
|
||||
|
||||
#define __pte_free_tlb(tlb, pte, addr) \
|
||||
|
Loading…
Reference in New Issue
Block a user