riscv: Move kernel mapping outside of linear mapping
[linux-2.6-microblaze.git] / arch / riscv / kernel / head.S
index 11e2a4f..6cb05f2 100644 (file)
@@ -35,12 +35,17 @@ ENTRY(_start)
        .word 0
 #endif
        .balign 8
+#ifdef CONFIG_RISCV_M_MODE
+       /* Image load offset (0MB) from start of RAM for M-mode */
+       .dword 0
+#else
 #if __riscv_xlen == 64
        /* Image load offset(2MB) from start of RAM */
        .dword 0x200000
 #else
        /* Image load offset(4MB) from start of RAM */
        .dword 0x400000
+#endif
 #endif
        /* Effective size of kernel image */
        .dword _end - _start
@@ -64,7 +69,8 @@ pe_head_start:
 #ifdef CONFIG_MMU
 relocate:
        /* Relocate return address */
-       li a1, PAGE_OFFSET
+       la a1, kernel_virt_addr
+       REG_L a1, 0(a1)
        la a2, _start
        sub a1, a1, a2
        add ra, ra, a1
@@ -177,7 +183,6 @@ setup_trap_vector:
 
 END(_start)
 
-       __INIT
 ENTRY(_start_kernel)
        /* Mask all interrupts */
        csrw CSR_IE, zero
@@ -256,7 +261,11 @@ clear_bss_done:
 
        /* Initialize page tables and relocate to virtual addresses */
        la sp, init_thread_union + THREAD_SIZE
+#ifdef CONFIG_BUILTIN_DTB
+       la a0, __dtb_start
+#else
        mv a0, s1
+#endif /* CONFIG_BUILTIN_DTB */
        call setup_vm
 #ifdef CONFIG_MMU
        la a0, early_pg_dir