riscv: Move setup_bootmem into paging_init
[linux-2.6-microblaze.git] / arch / riscv / mm / init.c
index dfb5e4f..dab3171 100644 (file)
@@ -67,11 +67,6 @@ static void __init zone_sizes_init(void)
        free_area_init(max_zone_pfns);
 }
 
-static void __init setup_zero_page(void)
-{
-       memset((void *)empty_zero_page, 0, PAGE_SIZE);
-}
-
 #if defined(CONFIG_MMU) && defined(CONFIG_DEBUG_VM)
 static inline void print_mlk(char *name, unsigned long b, unsigned long t)
 {
@@ -119,7 +114,7 @@ void __init mem_init(void)
        print_vm_layout();
 }
 
-void __init setup_bootmem(void)
+static void __init setup_bootmem(void)
 {
        phys_addr_t vmlinux_end = __pa_symbol(&_end);
        phys_addr_t vmlinux_start = __pa_symbol(&_start);
@@ -135,11 +130,16 @@ void __init setup_bootmem(void)
 
        /*
         * Reserve from the start of the kernel to the end of the kernel
-        * and make sure we align the reservation on PMD_SIZE since we will
+        */
+#if defined(CONFIG_64BIT) && defined(CONFIG_STRICT_KERNEL_RWX)
+       /*
+        * Make sure we align the reservation on PMD_SIZE since we will
         * map the kernel in the linear mapping as read-only: we do not want
         * any allocation to happen between _end and the next pmd aligned page.
         */
-       memblock_reserve(vmlinux_start, (vmlinux_end - vmlinux_start + PMD_SIZE - 1) & PMD_MASK);
+       vmlinux_end = (vmlinux_end + PMD_SIZE - 1) & PMD_MASK;
+#endif
+       memblock_reserve(vmlinux_start, vmlinux_end - vmlinux_start);
 
        /*
         * memblock allocator is not aware of the fact that last 4K bytes of
@@ -640,7 +640,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa)
 #endif
 }
 
-#if defined(CONFIG_64BIT) && !defined(CONFIG_XIP_KERNEL)
+#if defined(CONFIG_64BIT) && defined(CONFIG_STRICT_KERNEL_RWX)
 void protect_kernel_linear_mapping_text_rodata(void)
 {
        unsigned long text_start = (unsigned long)lm_alias(_start);
@@ -861,8 +861,8 @@ RESERVEDMEM_OF_DECLARE(elfcorehdr, "linux,elfcorehdr", elfcore_hdr_setup);
 
 void __init paging_init(void)
 {
+       setup_bootmem();
        setup_vm_final();
-       setup_zero_page();
 }
 
 void __init misc_mem_init(void)