[PATCH] RISC-V: Initialize the jvt CSR

Hau Hsu hau.hsu@sifive.com
Wed Sep 27 01:17:53 GMT 2023


We found a potential ISA conflict when compiling the crt0.S with zcd extension.
We already have a new patch under testing.
I'll send it after it is verified.

Best,

Hau Hsu
Software Engineer
hau.hsu@sifive.com




> Kito Cheng <kito.cheng@gmail.com> 於 2023年9月25日 下午2:17 寫道:
> 
> LGTM 
> 
> Hau Hsu via Newlib <newlib@sourceware.org <mailto:newlib@sourceware.org>> 於 2023年9月25日 週一 06:37 寫道:
>> We set symbol '__jvt_base$' as weak. So if the symbol is not set in the
>> linker script, the address would be 0. We initialize jvt CSR only if
>> the address is not 0.
>> 
>> psabi reference:
>> https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2d770815dc9a8b11e61ea1abd487cb25ee56ad5e/riscv-elf.adoc#table-jump-relaxation
>> ---
>>  libgloss/riscv/crt0.S | 10 ++++++++++
>>  1 file changed, 10 insertions(+)
>> 
>> diff --git a/libgloss/riscv/crt0.S b/libgloss/riscv/crt0.S
>> index 7a4e4e32c..4744ba039 100644
>> --- a/libgloss/riscv/crt0.S
>> +++ b/libgloss/riscv/crt0.S
>> @@ -26,6 +26,16 @@ _start:
>>    addi  gp, gp, %pcrel_lo(1b)
>>  .option pop
>> 
>> +  /* Initialize jvt CSR */
>> +  .weak __jvt_base$
>> +.option push
>> +.option arch, +zcmt, +zicsr
>> +  lla a0, __jvt_base$
>> +  beqz a0, .Ljvt_init_end
>> +  csrw jvt, a0
>> +.Ljvt_init_end:
>> +.option pop
>> +
>>    # Clear the bss segment
>>    la      a0, __bss_start
>>    la      a2, _end
>> -- 
>> 2.42.0
>> 



More information about the Newlib mailing list