From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Qi Hu <huqi@loongson.cn>, Jinyang Shen <shenjinyang@loongson.cn>,
Xuehai Chen <chenxuehai@loongson.cn>
Subject: [PULL 1/5] target/i386: Fix calculation of LOCK NEG eflags
Date: Wed, 2 Nov 2022 12:41:21 +0100 [thread overview]
Message-ID: <20221102114125.58902-2-pbonzini@redhat.com> (raw)
In-Reply-To: <20221102114125.58902-1-pbonzini@redhat.com>
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
next prev parent reply other threads:[~2022-11-02 11:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-02 11:41 [PULL 0/5] Misc patches for QEMU 7.2 soft freeze Paolo Bonzini
2022-11-02 11:41 ` Paolo Bonzini [this message]
2022-11-02 11:41 ` [PULL 2/5] os-posix: asynchronous teardown for shutdown on Linux Paolo Bonzini
2022-11-02 11:41 ` [PULL 3/5] target/i386: Set maximum APIC ID to KVM prior to vCPU creation Paolo Bonzini
2022-11-02 11:41 ` [PULL 4/5] util/log: Close per-thread log file on thread termination Paolo Bonzini
2022-11-02 11:41 ` [PULL 5/5] target/i386: Fix test for paging enabled Paolo Bonzini
2022-11-02 12:13 ` [PULL 0/5] Misc patches for QEMU 7.2 soft freeze Bin Meng
2022-11-02 13:04 ` Paolo Bonzini
2022-11-03 21:27 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221102114125.58902-2-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=chenxuehai@loongson.cn \
--cc=huqi@loongson.cn \
--cc=qemu-devel@nongnu.org \
--cc=shenjinyang@loongson.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.