Skip to content

Commit

Permalink
fix(rvc): NEMU should also properly handle illegal instruction cases …
Browse files Browse the repository at this point in the history
…in non-dynamic library mode
  • Loading branch information
my-mayfly committed Feb 15, 2025
1 parent 9d06edd commit a1098aa
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/isa/riscv64/instr/rvc/decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ static inline def_DHelper(CI_simm) {

static inline def_DHelper(CI_simm_lui) {
decode_CI_simm(s, width);
#ifdef CONFIG_SHARE

// C.LUI is only valid when rd != {x0, x2}, and when the immediate is not
// equal to zero. The code points with nzimm=0 are reserved; the remaining
// code points with rd=x0 are HINTs; and the remaining code points with rd=x2
// correspond to the C.ADDI16SP instruction.
if (unlikely(id_src2->imm == 0)) {
longjmp_exception(EX_II);
}
#endif // CONFIG_SHARE

// the immediate of LUI is placed at id_src1->imm
id_src1->imm = id_src2->imm << 12;
}
Expand Down Expand Up @@ -322,14 +322,12 @@ def_THelper(c_addi_dispatch) {
}

def_THelper(c_addiw_dispatch) {
#ifdef CONFIG_SHARE
// C.ADDIW is only valid when rd != x0; the code points with rd=x0 are reserved.
uint32_t instr = s->isa.instr.val;
uint32_t rd = BITS(instr, 11, 7);
if (unlikely(rd == 0)) {
return EXEC_ID_inv;
}
#endif // CONFIG_SHARE
return table_c_addiw(s);
}

Expand Down

0 comments on commit a1098aa

Please sign in to comment.