HomeFreeBSD

RISC-V: fix global pointer assignment at boot

Description

RISC-V: fix global pointer assignment at boot

As part of the RISC-V ABI, the gp register is expected to initialized
with the address of __global_pointer$ as early as possible. This allows
loads and stores from .sdata to be relaxed based on the value of gp. In
locore.S we do this initialization twice, once each for va and mpva.
However, in both cases the initialization is preceded by an la
instruction, which in theory could be relaxed by the linker.

Move the initialization of gp to be slightly earlier (before la
cpu_exception_handler), and add an additional gp initialization at the
very beginning of _start, before virtual memory is set up.

Reported by: jrtc27
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D23139

Details

Committed
mhorneJan 17 2020, 5:03 PM
Reviewer
jrtc27
Differential Revision
D23139: RISC-V: fix global pointer assignment at boot
Parents
rS356834: Use unsigned loads in fubyte, fuword16, generic_bs_r_1, generic_bs_r_2
Branches
Unknown
Tags
Unknown