Page MenuHomeFreeBSD

RISC-V privilege architecture update v1.10
ClosedPublic

Authored by br on Jul 31 2017, 8:03 PM.
Tags
None
Referenced Files
F103030570: D11800.id31819.diff
Wed, Nov 20, 1:09 AM
F103000848: D11800.id31873.diff
Tue, Nov 19, 4:33 PM
F103000845: D11800.id31870.diff
Tue, Nov 19, 4:33 PM
F103000838: D11800.id31819.diff
Tue, Nov 19, 4:33 PM
F103000830: D11800.id31808.diff
Tue, Nov 19, 4:33 PM
F103000822: D11800.id31758.diff
Tue, Nov 19, 4:33 PM
F103000813: D11800.id31672.diff
Tue, Nov 19, 4:33 PM
F103000809: D11800.id31653.diff
Tue, Nov 19, 4:33 PM

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Replacing all instances of __riscv__ with __riscv seems like a slightly unwelcome inconsistency with other architectures. Is there a reason why this change needs to be made?

andrew added inline comments.
sys/riscv/riscv/machdep.c
855 ↗(On Diff #31396)

Why not make this a compile time check?

In D11800#244666, @ngie wrote:

Replacing all instances of __riscv__ with __riscv seems like a slightly unwelcome inconsistency with other architectures. Is there a reason why this change needs to be made?

So RISC-V is extensible ISA and the idea is to have built-in define per each extension, so together with __riscv we now have some subset of these as well (depends on -march string passed to compiler)

__riscv_compressed
__riscv_atomic
__riscv_mul
__riscv_div
__riscv_muldiv
__riscv_fdiv
__riscv_fsqrt
__riscv_float_abi_soft
__riscv_float_abi_single
__riscv_float_abi_double
__riscv_cmodel_medlow
__riscv_cmodel_medany
__riscv_cmodel_pic
__riscv_xlen == 64
sys/riscv/riscv/machdep.c
855 ↗(On Diff #31396)

Good idea, added CTASSERT(FDT)
thanks!

If current compilers accept both __riscv__ and __riscv could we first commit that as an independent change?

built-in defines change moved to separate review https://reviews.freebsd.org/D11901

lib/csu/riscv/crti.S
49–50 ↗(On Diff #31673)

Why does it need the nop?

sys/conf/ldscript.riscv
9 ↗(On Diff #31673)

Why is the + 0x200000 needed?

  • remove nop in crti.S
  • remove align 2 (set to 0) in crti.S

this helps to build correct code

lib/csu/riscv/crti.S
49–50 ↗(On Diff #31673)

The compiler was inserting empty space of 2 bytes (0x0000) which is invalid instruction. Using nop we filling that space with real instruction.
But I just updated compiler and things getting worse: nop does not help anymore. It looks like R_RISCV_ALIGN relocation uses 3 bytes and things get unaligned. I removed .align 2 and it now works fine

sys/conf/ldscript.riscv
9 ↗(On Diff #31673)

because BBL puts kernel to offset 0x200000 of physical memory.
Using same offset in VA space helps us to setup initial mapping and jump to VA space in locore.S.
So we have translations like 0xffffffc000200000 -> 0x80200000

remove changes added by accident

o Detect physical memory address kernel loaded to
o Remove offset to kernbase in RISC-V linker script

sort riscv boot params struct

This revision was automatically updated to reflect the committed changes.