Skip to content

Commit

Permalink
ELP is violated if lpad not fetched when expected
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Nov 28, 2023
1 parent ac7e90a commit 2bece04
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions model/riscv_step.sail
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,20 @@ function step(step_no : int) -> bool = {
then {
print_instr("[" ^ string_of_int(step_no) ^ "] [" ^ to_str(cur_privilege) ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(h) ^ ") " ^ to_str(ast));
};
/* check for RVC once here instead of every RVC execute clause. */
if haveRVC() then {
nextPC = PC + 2;
(execute(ast), true)
} else {
handle_illegal();
/* Zicfilp requires a landing pad (a base inst) if ELP is LP_EXPECTED */
if elp != ElpState_to_bits(LP_EXPECTED) then {
handle_sw_check_exception(LANDING_PAD_FAULT);
(RETIRE_FAIL, true)
}
} else {
/* check for RVC once here instead of every RVC execute clause. */
if haveRVC() then {
nextPC = PC + 2;
(execute(ast), true)
} else {
handle_illegal();
(RETIRE_FAIL, true)
}
}
},
F_Base(w) => {
instbits = zero_extend(w);
Expand All @@ -131,8 +137,14 @@ function step(step_no : int) -> bool = {
then {
print_instr("[" ^ string_of_int(step_no) ^ "] [" ^ to_str(cur_privilege) ^ "]: " ^ BitStr(PC) ^ " (" ^ BitStr(w) ^ ") " ^ to_str(ast));
};
nextPC = PC + 4;
(execute(ast), true)
/* Zicfilp requires a aligned lpad if elp is LP_EXPECTED */
if zicfilp_is_elp_violated() then {
handle_sw_check_exception(LANDING_PAD_FAULT);
(RETIRE_FAIL, true)
} else {
nextPC = PC + 4;
(execute(ast), true)
}
}
}
}
Expand Down

0 comments on commit 2bece04

Please sign in to comment.