target/i386: Generate #UD when applying LOCK to a register
PATCH 1/1 target/i386: Generate #UD when applying LOCK to a register
This covers inc, dec, and the bit test instructions.
I believe we've finally covered all of the cases for which we have an atomic path that would use the cpu_A0 temp, which is only initialized for address sources.
--- target/i386/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
target/i386/translate.c +11 -0
@@ -1398,6 +1398,11 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d)static void gen_inc (DisasContext *s1,TCGMemOp ot,int d,int c) {if (s1->prefix &PREFIX_LOCK ) { +if (d !=OR_TMP0 ) { +/* Lock prefix when destination is not memory. */ +gen_illegal_opcode (s1); +return ; + }tcg_gen_movi_tl (s1->T0, c >0 ?1 :-1 );tcg_gen_atomic_add_fetch_tl (s1->T0, s1->A0, s1->T0, s1->mem_index, ot |MO_LE );
@@ -6764,6 +6769,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); }/* load shift */
@@ -6803,6 +6811,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); } bt_op:
Signature · 1 line
2.17.2
Cc'ing Alberto
Quoted 6 lines · Richard Henderson
This covers inc, dec, and the bit test instructions.
I believe we've finally covered all of the cases for which we have an atomic path that would use the
cpu_A0temp, which is only initialized for address sources.
Quoted 43 lines
Signed-off-by Richard Henderson <[email protected]>--- target/i386/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+)target/i386/translate.c +11
-0@@ -1398,6 +1398,11 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d)static void gen_inc (DisasContext *s1,TCGMemOp ot,int d,int c) {if (s1->prefix &PREFIX_LOCK ) { +if (d !=OR_TMP0 ) { +/* Lock prefix when destination is not memory. */ +gen_illegal_opcode (s1); +return ; + }tcg_gen_movi_tl (s1->T0, c >0 ?1 :-1 );tcg_gen_atomic_add_fetch_tl (s1->T0, s1->A0, s1->T0, s1->mem_index, ot |MO_LE );@@ -6764,6 +6769,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); }/* load shift */ @@ -6803,6 +6811,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); } bt_op:
Ping.
Quoted 49 lines · Richard Henderson
This covers inc, dec, and the bit test instructions.
I believe we've finally covered all of the cases for which we have an atomic path that would use the
cpu_A0temp, which is only initialized for address sources.Signed-off-by Richard Henderson <[email protected]>--- target/i386/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+)target/i386/translate.c +11
-0@@ -1398,6 +1398,11 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d)static void gen_inc (DisasContext *s1,TCGMemOp ot,int d,int c) {if (s1->prefix &PREFIX_LOCK ) { +if (d !=OR_TMP0 ) { +/* Lock prefix when destination is not memory. */ +gen_illegal_opcode (s1); +return ; + }tcg_gen_movi_tl (s1->T0, c >0 ?1 :-1 );tcg_gen_atomic_add_fetch_tl (s1->T0, s1->A0, s1->T0, s1->mem_index, ot |MO_LE );@@ -6764,6 +6769,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); }/* load shift */ @@ -6803,6 +6811,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); } bt_op:
Philippe Mathieu-Daudé
Reviewed-byQuoted 10 lines · Richard Henderson
Ping.
Quoted 7 lines · Richard Henderson
This covers inc, dec, and the bit test instructions.
I believe we've finally covered all of the cases for which we have an atomic path that would use the
cpu_A0temp, which is only initialized for address sources.
Quoted 1 line
Quoted 1 line
Signed-off-by Richard Henderson <[email protected]>
Quoted 43 lines
Quoted 41 lines
--- target/i386/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+)target/i386/translate.c +11
-0@@ -1398,6 +1398,11 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d)static void gen_inc (DisasContext *s1,TCGMemOp ot,int d,int c) {if (s1->prefix &PREFIX_LOCK ) { +if (d !=OR_TMP0 ) { +/* Lock prefix when destination is not memory. */ +gen_illegal_opcode (s1); +return ; + }tcg_gen_movi_tl (s1->T0, c >0 ?1 :-1 );tcg_gen_atomic_add_fetch_tl (s1->T0, s1->A0, s1->T0, s1->mem_index, ot |MO_LE );@@ -6764,6 +6769,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); }/* load shift */ @@ -6803,6 +6811,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); } bt_op:
Paolo Bonzini
AppliedQuoted 40 lines · Richard Henderson
This covers inc, dec, and the bit test instructions.
I believe we've finally covered all of the cases for which we have an atomic path that would use the
cpu_A0temp, which is only initialized for address sources.Signed-off-by Richard Henderson <[email protected]>--- target/i386/translate.c | 11 +++++++++++ 1 file changed, 11 insertions(+)target/i386/translate.c +8
-0@@ -1398,6 +1398,11 @@ static void gen_op(DisasContext *s1, int op, TCGMemOp ot, int d)static void gen_inc (DisasContext *s1,TCGMemOp ot,int d,int c) {if (s1->prefix &PREFIX_LOCK ) { +if (d !=OR_TMP0 ) { +/* Lock prefix when destination is not memory. */ +gen_illegal_opcode (s1); +return ; + }tcg_gen_movi_tl (s1->T0, c >0 ?1 :-1 );tcg_gen_atomic_add_fetch_tl (s1->T0, s1->A0, s1->T0, s1->mem_index, ot |MO_LE );@@ -6764,6 +6769,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); }/* load shift */
target/i386/translate.c static target_ulong disas_insn(DisasContext *s, CPUState *cpu) · line 6819
Quoted 9 lines
target/i386/translate.c +3
-0@@ -6803,6 +6811,9 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)gen_op_ld_v (s, ot, s->T0, s->A0); } }else { +if (s->prefix &PREFIX_LOCK ) { + goto illegal_op; + }gen_op_mov_v_reg (s, ot, s->T0, rm); } bt_op:
Queued, thanks.
Paolo