target-arm: Handle 'smc' as an undefined instruction
PATCH 1/1 target-arm: Handle 'smc' as an undefined instruction
Handle smc as an undefined instruction instead of having it wrongly interpreted as some other one.
--- target-arm/translate.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
target-arm/translate.c +6 -1
@@ -6346,7 +6346,12 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)dead_tmp (tmp2);store_reg (s, rd, tmp);break ; -case 7 :/* bkpt */ +case 7 : +/* SMC? */ +if ((insn &0xfffffff0 ) ==0xe1600070 ) { + goto illegal_op; + } +/* bkpt */ gen_set_condexec (s);gen_set_pc_im (s->pc -4 );gen_exception (EXCP_BKPT );
Signature · 1 line
1.7.1
target-arm/translate.c static void disas_arm_insn(CPUState * env, DisasContext *s) · line 6354
Quoted 6 lines · Adam Lackorzynski
target-arm/translate.c +6
-0+case 7 : +/* SMC? */ +if ((insn &0xfffffff0 ) ==0xe1600070 ) { + goto illegal_op; + } +/* bkpt */
This doesn't look right to me. SMC in the ARM encoding is a standard conditionalised instruction, so you shouldn't be mandating that the cond field is 0xe.
I think the correct way to distinguish BKPT from SMC is to look at bits [22..21] of the instruction: 01 for BKPT, 11 for SMC and other combinations are UNDEFINED. This is in 'op1' at this point in the code...
-- Peter Maydell
Quoted 11 lines · Peter Maydell
Review
Quoted 6 lines · Adam Lackorzynski
(quoted diff) +6
-0+ case 7: + /* SMC? */ + if ((insn & 0xfffffff0) == 0xe1600070) { + goto illegal_op; + } + /* bkpt */This doesn't look right to me. SMC in the ARM encoding is a standard conditionalised instruction, so you shouldn't be mandating that the cond field is
0xe.
True.
Quoted 4 lines
I think the correct way to distinguish BKPT from SMC is to look at bits [22..21] of the instruction: 01 for BKPT, 11 for SMC and other combinations are UNDEFINED. This is in 'op1' at this point in the code...
target-arm: Handle 'smc' as an undefined instruction
Refine check on bkpt so that smc is handled as an undefined instruction.
--- target-arm/translate.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
target-arm/translate.c +5 -1
@@ -6346,7 +6346,11 @@ static void disas_arm_insn(CPUState * env, DisasContext *s)dead_tmp (tmp2);store_reg (s, rd, tmp);break ; -case 7 :/* bkpt */ +case 7 : +if (op1 !=1 ) { + goto illegal_op; + } +/* bkpt */ gen_set_condexec (s);gen_set_pc_im (s->pc -4 );gen_exception (EXCP_BKPT );
Signature · 8 lines
1.7.1 Thanks, Adam -- Adam [email protected] Lackorzynski http://os.inf.tu-dresden.de/~adam/