Commit 007480fe authored by Björn Töpel's avatar Björn Töpel Committed by Palmer Dabbelt

riscv: mm: Refactor create_linear_mapping_range() for memory hot add

Add a parameter to the direct map setup function, so it can be used in
arch_add_memory() later.
Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarOscar Salvador <osalvador@suse.de>
Signed-off-by: default avatarBjörn Töpel <bjorn@rivosinc.com>
Link: https://lore.kernel.org/r/20240605114100.315918-5-bjorn@kernel.orgSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent fe122b89
...@@ -1231,7 +1231,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) ...@@ -1231,7 +1231,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
} }
static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t end, static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t end,
uintptr_t fixed_map_size) uintptr_t fixed_map_size, const pgprot_t *pgprot)
{ {
phys_addr_t pa; phys_addr_t pa;
uintptr_t va, map_size; uintptr_t va, map_size;
...@@ -1242,7 +1242,7 @@ static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t ...@@ -1242,7 +1242,7 @@ static void __meminit create_linear_mapping_range(phys_addr_t start, phys_addr_t
best_map_size(pa, va, end - pa); best_map_size(pa, va, end - pa);
create_pgd_mapping(swapper_pg_dir, va, pa, map_size, create_pgd_mapping(swapper_pg_dir, va, pa, map_size,
pgprot_from_va(va)); pgprot ? *pgprot : pgprot_from_va(va));
} }
} }
...@@ -1286,22 +1286,19 @@ static void __init create_linear_mapping_page_table(void) ...@@ -1286,22 +1286,19 @@ static void __init create_linear_mapping_page_table(void)
if (end >= __pa(PAGE_OFFSET) + memory_limit) if (end >= __pa(PAGE_OFFSET) + memory_limit)
end = __pa(PAGE_OFFSET) + memory_limit; end = __pa(PAGE_OFFSET) + memory_limit;
create_linear_mapping_range(start, end, 0); create_linear_mapping_range(start, end, 0, NULL);
} }
#ifdef CONFIG_STRICT_KERNEL_RWX #ifdef CONFIG_STRICT_KERNEL_RWX
create_linear_mapping_range(ktext_start, ktext_start + ktext_size, 0); create_linear_mapping_range(ktext_start, ktext_start + ktext_size, 0, NULL);
create_linear_mapping_range(krodata_start, create_linear_mapping_range(krodata_start, krodata_start + krodata_size, 0, NULL);
krodata_start + krodata_size, 0);
memblock_clear_nomap(ktext_start, ktext_size); memblock_clear_nomap(ktext_start, ktext_size);
memblock_clear_nomap(krodata_start, krodata_size); memblock_clear_nomap(krodata_start, krodata_size);
#endif #endif
#ifdef CONFIG_KFENCE #ifdef CONFIG_KFENCE
create_linear_mapping_range(kfence_pool, create_linear_mapping_range(kfence_pool, kfence_pool + KFENCE_POOL_SIZE, PAGE_SIZE, NULL);
kfence_pool + KFENCE_POOL_SIZE,
PAGE_SIZE);
memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE); memblock_clear_nomap(kfence_pool, KFENCE_POOL_SIZE);
#endif #endif
......
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