Page MenuHomeFreeBSD

RISC-V privilege architecture update v1.10
ClosedPublic

Authored by br on Jul 31 2017, 8:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 9:32 AM
Unknown Object (File)
Wed, Nov 20, 9:31 AM
Unknown Object (File)
Wed, Nov 20, 9:28 AM
Unknown Object (File)
Wed, Nov 20, 9:25 AM
Unknown Object (File)
Wed, Nov 20, 9:24 AM
Unknown Object (File)
Wed, Nov 20, 9:11 AM
Unknown Object (File)
Wed, Nov 20, 7:25 AM
Unknown Object (File)
Wed, Nov 20, 1:09 AM

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

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
858

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
858

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
50–51

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
50–51

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.