summaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorQi Hu2022-10-24 10:41:55 +0200
committerPaolo Bonzini2022-10-31 09:46:34 +0100
commit121531751087ad3f8d87ad17068835bbcd14fb02 (patch)
tree6e68c6f3e37f7d642645b284d9df227ed05697d3 /target
parentMerge tag 'block-pull-request' of https://gitlab.com/stefanha/qemu into staging (diff)
downloadqemu-121531751087ad3f8d87ad17068835bbcd14fb02.tar.gz
qemu-121531751087ad3f8d87ad17068835bbcd14fb02.tar.xz
qemu-121531751087ad3f8d87ad17068835bbcd14fb02.zip
target/i386: Fix calculation of LOCK NEG eflags
After: lock negl -0x14(%rbp) pushf pop %rax %rax will contain the wrong value because the "lock neg" calculates the wrong eflags. Simple test: #include <assert.h> int main() { __volatile__ unsigned test = 0x2363a; __volatile__ char cond = 0; asm( "lock negl %0 \n\t" "sets %1" : "=m"(test), "=r"(cond)); assert(cond & 1); return 0; } Reported-by: Jinyang Shen <shenjinyang@loongson.cn> Co-Developed-by: Xuehai Chen <chenxuehai@loongson.cn> Signed-off-by: Xuehai Chen <chenxuehai@loongson.cn> Signed-off-by: Qi Hu <huqi@loongson.cn> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target')
-rw-r--r--target/i386/tcg/translate.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 546c427c23..c477a10f41 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -3300,7 +3300,7 @@ static bool disas_insn(DisasContext *s, CPUState *cpu)
tcg_temp_free(t2);
tcg_temp_free(a0);
- tcg_gen_mov_tl(s->T0, t0);
+ tcg_gen_neg_tl(s->T0, t0);
tcg_temp_free(t0);
} else {
tcg_gen_neg_tl(s->T0, s->T0);