* [PATCH] target/i386: cmpxchg should not touch accumulator
@ 2021-07-31 19:06 yqwfh
2021-08-02 18:46 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: yqwfh @ 2021-07-31 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: yqwfh, Daniele Ahmed
Signed-off-by: Daniele Ahmed <ahmeddan@amazon.com>
---
target/i386/tcg/translate.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index aacb605..41386dd 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -5366,7 +5366,6 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
gen_lea_modrm(env, s, modrm);
tcg_gen_atomic_cmpxchg_tl(oldv, s->A0, cmpv, newv,
s->mem_index, ot | MO_LE);
- gen_op_mov_reg_v(s, ot, R_EAX, oldv);
} else {
if (mod == 3) {
rm = (modrm & 7) | REX_B(s);
@@ -5381,15 +5380,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
/* store value = (old == cmp ? new : old); */
tcg_gen_movcond_tl(TCG_COND_EQ, newv, oldv, cmpv, newv, oldv);
if (mod == 3) {
- gen_op_mov_reg_v(s, ot, R_EAX, oldv);
gen_op_mov_reg_v(s, ot, rm, newv);
- } else {
- /* Perform an unconditional store cycle like physical cpu;
- must be before changing accumulator to ensure
- idempotency if the store faults and the instruction
- is restarted */
- gen_op_st_v(s, ot, newv, s->A0);
- gen_op_mov_reg_v(s, ot, R_EAX, oldv);
}
}
tcg_gen_mov_tl(cpu_cc_src, oldv);
--
2.26.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] target/i386: cmpxchg should not touch accumulator
2021-07-31 19:06 [PATCH] target/i386: cmpxchg should not touch accumulator yqwfh
@ 2021-08-02 18:46 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2021-08-02 18:46 UTC (permalink / raw)
To: yqwfh, qemu-devel; +Cc: Daniele Ahmed
On 7/31/21 9:06 AM, yqwfh wrote:
> Signed-off-by: Daniele Ahmed <ahmeddan@amazon.com>
> ---
> target/i386/tcg/translate.c | 9 ---------
> 1 file changed, 9 deletions(-)
>
> diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
> index aacb605..41386dd 100644
> --- a/target/i386/tcg/translate.c
> +++ b/target/i386/tcg/translate.c
> @@ -5366,7 +5366,6 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
> gen_lea_modrm(env, s, modrm);
> tcg_gen_atomic_cmpxchg_tl(oldv, s->A0, cmpv, newv,
> s->mem_index, ot | MO_LE);
> - gen_op_mov_reg_v(s, ot, R_EAX, oldv);
> } else {
> if (mod == 3) {
> rm = (modrm & 7) | REX_B(s);
> @@ -5381,15 +5380,7 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
> /* store value = (old == cmp ? new : old); */
> tcg_gen_movcond_tl(TCG_COND_EQ, newv, oldv, cmpv, newv, oldv);
> if (mod == 3) {
> - gen_op_mov_reg_v(s, ot, R_EAX, oldv);
> gen_op_mov_reg_v(s, ot, rm, newv);
> - } else {
> - /* Perform an unconditional store cycle like physical cpu;
> - must be before changing accumulator to ensure
> - idempotency if the store faults and the instruction
> - is restarted */
> - gen_op_st_v(s, ot, newv, s->A0);
> - gen_op_mov_reg_v(s, ot, R_EAX, oldv);
> }
Obviously incorrect. You can't *not* store to EAX. You must conditionally store to EAX.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-02 18:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31 19:06 [PATCH] target/i386: cmpxchg should not touch accumulator yqwfh
2021-08-02 18:46 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).