Skip to content

Commit

Permalink
#7 add revocation tree allocation fail exception code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingkai-Li committed Aug 16, 2023
1 parent 3bb7f78 commit 8a92cd1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion riscv/encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,7 @@
#define CAUSE_INSUFFICIENT_CAP_PERMS 0x1b
#define CAUSE_CAP_OUT_OF_BOUND 0x1c
#define CAUSE_ILLEGAL_OPERAND_VALUE 0x1d
// CAUSE_UNHANDLEABLE_EXCEPTION only used in pure capstone
#define CAUSE_INSUFFICIENT_SYSTEM_RESOURCES 0x1e
// #define CAUSE_UNHANDLEABLE_EXCEPTION 0x3f
/*end of capstone added exception code*/
#endif
Expand Down Expand Up @@ -4929,6 +4929,8 @@ DECLARE_CAUSE("unexpected capability type", CAUSE_UNEXPECTED_CAP_TYPE)
DECLARE_CAUSE("insufficient capability permissions", CAUSE_INSUFFICIENT_CAP_PERMS)
DECLARE_CAUSE("capability out of bound", CAUSE_CAP_OUT_OF_BOUND)
DECLARE_CAUSE("illegal operand value", CAUSE_ILLEGAL_OPERAND_VALUE)
DECLARE_CAUSE("insufficient system resources", CAUSE_INSUFFICIENT_SYSTEM_RESOURCES)

// DECLARE_CAUSE("unhandleable exception", CAUSE_UNHANDLEABLE_EXCEPTION)
/*end of capstone added exceptions*/
#endif
3 changes: 2 additions & 1 deletion riscv/insns/cs_mrev.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ if (IS_CAP(insn_rd)) UPDATE_RC_DOWN(READ_CAP_NODE(insn_rd));
WRITE_CAP_DUMB(insn_rd, READ_CAP(insn_rs1));
/*update rs1 capability node_id*/
rev_node_id_t mrev_node_id = ALLOCATE_NODE(READ_CAP_NODE(insn_rs1));
assert(mrev_node_id != REV_NODE_ID_INVALID); // crush if no node available
if (mrev_node_id == REV_NODE_ID_INVALID)
throw trap_capstone_insufficient_system_resources(insn.bits());
READ_CAP(insn_rs1).node_id = mrev_node_id;
/*update rd capability type*/
if (NOT_ZERO_REG(insn_rd)) {
Expand Down
3 changes: 2 additions & 1 deletion riscv/insns/cs_split.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ if (insn_rs1 != insn_rd) {
// allocate new node
if (NOT_ZERO_REG(insn_rd)) {
rev_node_id_t split_node_id = SPLIT_RT(READ_CAP_NODE(insn_rs1));
assert(split_node_id != REV_NODE_ID_INVALID); // crush if no more node
if (split_node_id == REV_NODE_ID_INVALID)
throw trap_capstone_insufficient_system_resources(insn.bits());
READ_CAP(insn_rd).node_id = split_node_id;
READ_CAP(insn_rd).base = tmp_val;
READ_CAP(insn_rd).cursor = tmp_val;
Expand Down
1 change: 1 addition & 0 deletions riscv/trap.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,5 +139,6 @@ DECLARE_CAPSTONE_TRAP(CAUSE_UNEXPECTED_CAP_TYPE, capstone_unexpected_cap_type)
DECLARE_CAPSTONE_TRAP(CAUSE_INSUFFICIENT_CAP_PERMS, capstone_insufficient_cap_perms)
DECLARE_CAPSTONE_TRAP(CAUSE_CAP_OUT_OF_BOUND, capstone_cap_out_of_bound)
DECLARE_CAPSTONE_TRAP(CAUSE_ILLEGAL_OPERAND_VALUE, capstone_illegal_operand_value)
DECLARE_CAPSTONE_TRAP(CAUSE_INSUFFICIENT_SYSTEM_RESOURCES, capstone_insufficient_system_resources)
/*end of transcapstone exceptions*/
#endif

0 comments on commit 8a92cd1

Please sign in to comment.