Index: sys/riscv/riscv/locore.S =================================================================== --- sys/riscv/riscv/locore.S +++ sys/riscv/riscv/locore.S @@ -53,6 +53,12 @@ .text .globl _start _start: + /* Set the global pointer */ +.option push +.option norelax + la gp, __global_pointer$ +.option pop + /* Get the physical address kernel loaded to */ lla t0, virt_map ld t1, 0(t0) @@ -168,6 +174,11 @@ .align 2 va: + /* Set the global pointer again, this time with the virtual address. */ +.option push +.option norelax + la gp, __global_pointer$ +.option pop /* Setup supervisor trap vector */ la t0, cpu_exception_handler @@ -177,12 +188,6 @@ li t0, 0 csrw sscratch, t0 - /* Set the global pointer */ -.option push -.option norelax - la gp, __global_pointer$ -.option pop - /* Initialize stack pointer */ la s3, initstack_end mv sp, s3 @@ -322,6 +327,12 @@ .align 2 mpva: + /* Set the global pointer */ +.option push +.option norelax + la gp, __global_pointer$ +.option pop + /* Setup supervisor trap vector */ la t0, cpu_exception_handler csrw stvec, t0 @@ -330,12 +341,6 @@ li t0, 0 csrw sscratch, t0 - /* Set the global pointer */ -.option push -.option norelax - la gp, __global_pointer$ -.option pop - call init_secondary END(mpentry) #endif