Page MenuHomeFreeBSD

RISC-V: fix global pointer assignment at boot
ClosedPublic

Authored by mhorne on Jan 11 2020, 11:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 30 2024, 1:55 PM
Unknown Object (File)
Dec 23 2023, 3:36 AM
Unknown Object (File)
Nov 11 2023, 6:36 AM
Unknown Object (File)
Nov 8 2023, 4:18 AM
Unknown Object (File)
Oct 30 2023, 12:13 PM
Unknown Object (File)
Oct 26 2023, 2:34 PM
Unknown Object (File)
Jul 1 2023, 9:03 PM
Unknown Object (File)
Jul 1 2023, 7:46 AM
Subscribers

Details

Summary

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

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 28613
Build 26647: arc lint + arc unit

Event Timeline

Yep, this is what I was thinking of (with the lla fixed). Thanks!

sys/riscv/riscv/locore.S
59

This needs to be an lla.

sys/riscv/riscv/locore.S
330

Maybe add the again, this time with the virtual address. comment to match the BSP case (and to make it clear that mpentry itself is inheriting the physical gp from _start)?

Use lla, not la. Use longer comment for mpva as well.

Ping. Are you happy with this?

This revision is now accepted and ready to land.Jan 16 2020, 8:34 PM
This revision was automatically updated to reflect the committed changes.