Skip to content

Commit

Permalink
#1 add temporary varible for cap-man-insn
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingkai-Li committed Aug 19, 2023
1 parent 8a92cd1 commit 02f3de2
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
8 changes: 5 additions & 3 deletions riscv/insns/cs_cincoffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ cap_type_t tmp_type = READ_CAP(insn_rs1).type;
if (tmp_type == CAP_TYPE_UNINITIALIZED || tmp_type == CAP_TYPE_SEALED)
throw trap_capstone_unexpected_cap_type(insn.bits());
/*increment cursor*/
if (NOT_ZERO_REG(insn_rs1)) {
READ_CAP(insn_rs1).cursor += RS2;
}
uint64_t val = RS2;
MOVC(insn_rd, insn_rs1);
if (NOT_ZERO_REG(insn_rd)) {
READ_CAP(insn_rd).cursor += val;
}

6 changes: 3 additions & 3 deletions riscv/insns/cs_cincoffsetimm.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cap_type_t tmp_type = READ_CAP(insn_rs1).type;
if (tmp_type == CAP_TYPE_UNINITIALIZED || tmp_type == CAP_TYPE_SEALED)
throw trap_capstone_unexpected_cap_type(insn.bits());
/*increment cursor*/
if (NOT_ZERO_REG(insn_rs1)) {
READ_CAP(insn_rs1).cursor += insn_i_imm;
}
MOVC(insn_rd, insn_rs1);
if (NOT_ZERO_REG(insn_rd)) {
READ_CAP(insn_rd).cursor += insn_i_imm;
}
5 changes: 3 additions & 2 deletions riscv/insns/cs_init.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ if (READ_CAP(insn_rs1).type != CAP_TYPE_UNINITIALIZED)
if (READ_CAP(insn_rs1).cursor != READ_CAP(insn_rs1).end)
throw trap_capstone_illegal_operand_value(insn.bits());
/*init an uninitialized capability*/
READ_CAP(insn_rs1).type = CAP_TYPE_LINEAR;
READ_CAP(insn_rs1).cursor = READ_CAP(insn_rs1).base + RS2;
uint64_t val = RS2;
MOVC(insn_rd, insn_rs1);
READ_CAP(insn_rd).type = CAP_TYPE_LINEAR;
READ_CAP(insn_rd).cursor = READ_CAP(insn_rs1).base + val;
7 changes: 4 additions & 3 deletions riscv/insns/cs_scc.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ if (!IS_CAP(insn_rs1) || !IS_DATA(insn_rs2))
if (READ_CAP(insn_rs1).type == CAP_TYPE_UNINITIALIZED || READ_CAP(insn_rs1).type == CAP_TYPE_SEALED)
throw trap_capstone_unexpected_cap_type(insn.bits());
/*set current cursor*/
if (NOT_ZERO_REG(insn_rs1)) {
READ_CAP(insn_rs1).cursor = RS2;
}
uint64_t val = RS2;
MOVC(insn_rd, insn_rs1);
if (NOT_ZERO_REG(insn_rd)) {
READ_CAP(insn_rd).cursor = val;
}
4 changes: 2 additions & 2 deletions riscv/insns/cs_seal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ if (READ_CAP(insn_rs1).end - READ_CAP(insn_rs1).base < CLENBYTES * 33)
if (READ_CAP(insn_rs1).base % CLENBYTES != 0)
throw trap_capstone_illegal_operand_value(insn.bits());
/*seal a linear capability*/
READ_CAP(insn_rs1).type = CAP_TYPE_SEALED;
READ_CAP(insn_rs1).async = CAP_ASYNC_SYNC;
MOVC(insn_rd, insn_rs1);
READ_CAP(insn_rd).type = CAP_TYPE_SEALED;
READ_CAP(insn_rd).async = CAP_ASYNC_SYNC;
8 changes: 4 additions & 4 deletions riscv/insns/cs_tighten.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ if (tmp_type != CAP_TYPE_LINEAR && tmp_type != CAP_TYPE_NONLINEAR && tmp_type !=
if (insn_ri_imm < 7 && !CAP_PERM_GTE(insn_rs1, static_cast<cap_perm_t>(insn_ri_imm)))
throw trap_capstone_illegal_operand_value(insn.bits());
/*tighten the permission*/
if (NOT_ZERO_REG(insn_rs1)) {
MOVC(insn_rd, insn_rs1);
if (NOT_ZERO_REG(insn_rd)) {
if (insn_ri_imm > 7) {
READ_CAP(insn_rs1).perm = CAP_PERM_NA;
READ_CAP(insn_rd).perm = CAP_PERM_NA;
}
else {
READ_CAP(insn_rs1).perm = static_cast<cap_perm_t>(insn_ri_imm);
READ_CAP(insn_rd).perm = static_cast<cap_perm_t>(insn_ri_imm);
}
}
MOVC(insn_rd, insn_rs1);

0 comments on commit 02f3de2

Please sign in to comment.