[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 1/5] target/i386: Fix calculation of LOCK NEG eflags
From: |
Paolo Bonzini |
Subject: |
[PULL 1/5] target/i386: Fix calculation of LOCK NEG eflags |
Date: |
Wed, 2 Nov 2022 12:41:21 +0100 |
From: Qi Hu <huqi@loongson.cn>
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>
---
target/i386/tcg/translate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 546c427c232f..c477a10f410c 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);
--
2.38.1
- [PULL 0/5] Misc patches for QEMU 7.2 soft freeze, Paolo Bonzini, 2022/11/02
- [PULL 1/5] target/i386: Fix calculation of LOCK NEG eflags,
Paolo Bonzini <=
- [PULL 3/5] target/i386: Set maximum APIC ID to KVM prior to vCPU creation, Paolo Bonzini, 2022/11/02
- [PULL 2/5] os-posix: asynchronous teardown for shutdown on Linux, Paolo Bonzini, 2022/11/02
- [PULL 5/5] target/i386: Fix test for paging enabled, Paolo Bonzini, 2022/11/02
- [PULL 4/5] util/log: Close per-thread log file on thread termination, Paolo Bonzini, 2022/11/02
- Re: [PULL 0/5] Misc patches for QEMU 7.2 soft freeze, Bin Meng, 2022/11/02
- Re: [PULL 0/5] Misc patches for QEMU 7.2 soft freeze, Stefan Hajnoczi, 2022/11/03