Closed ImanHosseini closed 2 years ago
pk
was compiled using the C extension, but you are running Spike without the C extension.
Thanks! I see... so that address is unaligned because compressed instructions can be aligned at 2-byte boundaries instead of 4 right? (so the jump target is a C- instruction) So I now tried this (added f too because it was using C.fswsp):
spike --isa=rv32imfc -d pk t2
Now it traps a few instructions later at:
core 0: 0x8000029c (0x2e60306f) j pc + 0x32e6
:
core 0: 0x80003582 (0x00007179) c.addi16sp sp, -48
:
core 0: 0x80003584 (0x0000f406) c.fswsp ft1, 40(sp)
core 0: exception trap_illegal_instruction, epc 0x80003584
core 0: tval 0x0000f406
Which is odd, C.FSWSP should be covered with *fc ?
so that address is unaligned because compressed instructions can be aligned at 2-byte boundaries instead of 4 right?
Yeah, that's right.
C.FSWSP should be covered with *fc ?
Yeah, but it's possible the FPU hasn't been enabled yet (by setting mstatus.FS). Unfortunately, I can't help dig into debugging that.
Thanks! I will try to take it from here :) Just 1 question: all of this is not the code in my program right? Based on the addresses, these are all the 'pk' startup code (my code has no C- instructions at all), so is this a bug on pk side?
Right, the addresses being >= 0x80000000 suggest to me it's part of pk
.
It was fixed by:
spike --isa=rv32imafc -d /opt/riscv/riscv32-unknown-elf/bin/pk t2
I did expect, that given the '--isa=rv32' flag it would (magically) pull the correct pk but it was using the 64bit one. The other 'pk' file is a 64bit ELF, shouldn't it just throw error trying to load an ELF64 with isa=rv32? Now google would lead future ppl having the same issue to this thread now: try using the full path to pk ppl!.
Oh, nice!
Unlike cases of unsupported extension: where the error message specifically tells you what went wrong, cases of RV32/RV64 incompatibilities like this lead to unhelpful errors and you shouldn't have loaded an incompatible code in the first place - & if you have, it means you are not aware that you are doing it, like here - I think it would be nice if spike didn't load incompatible code and just told you that you are making that mistake. PR: https://github.com/riscv-software-src/riscv-isa-sim/pull/1085
I have a simple program compiled with:
and I try to run it with spike as:
And it crashes with "trap_instruction_address_misaligned", here's a trace: