Skip to content

Commit

Permalink
target-arm: Check undefined opcodes for SWP in A32 decoder
Browse files Browse the repository at this point in the history
Make sure we are not treating architecturally Undefined instructions
as a SWP, by verifying the opcodes as per section A8.8.229 of ARMv7-A
specification. Bits [21:20] must be zero for this to be a SWP or SWPB.
We also choose to UNDEF for the architecturally UNPREDICTABLE case of
bits [11:8] not being zero.

Signed-off-by: Onur Sahin <onursahin08@gmail.com>
[PMM: tweaked commit message]
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
sahinonur authored and pm215 committed Apr 10, 2018
1 parent 8720daa commit c4869ca
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions target/arm/translate.c
Original file line number Diff line number Diff line change
Expand Up @@ -9237,11 +9237,14 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
}
}
tcg_temp_free_i32(addr);
} else {
} else if ((insn & 0x00300f00) == 0) {
/* 0bcccc_0001_0x00_xxxx_xxxx_0000_1001_xxxx
* - SWP, SWPB
*/

TCGv taddr;
TCGMemOp opc = s->be_data;

/* SWP instruction */
rm = (insn) & 0xf;

if (insn & (1 << 22)) {
Expand All @@ -9259,6 +9262,8 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
get_mem_index(s), opc);
tcg_temp_free(taddr);
store_reg(s, rd, tmp);
} else {
goto illegal_op;
}
}
} else {
Expand Down

0 comments on commit c4869ca

Please sign in to comment.