From: Simon Scherer <scherer.simon89@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, richard.henderson@linaro.org,
Simon Scherer <scherer.simon89@gmail.com>
Subject: [PATCH 2/2] target/i386: Update FPU tag word for FXCH
Date: Wed, 2 Sep 2026 14:04:19 +0200 [thread overview]
Message-ID: <20260902120419.212855-3-scherer.simon89@gmail.com> (raw)
In-Reply-To: <20260902120419.212855-1-scherer.simon89@gmail.com>
FXCH ST(i) exchanges the contents of ST(0) and ST(i). Both registers
receive a new value, so both should end up marked valid in the FPU tag
word, regardless of what they were tagged before the swap.
helper_fxchg_ST0_STN() swaps the two values but never touches either
register's tag. So if either register happened to be tagged empty
beforehand, it is still wrongly tagged empty afterwards.
Mark both ST0 and ST(st_index) valid after the swap.
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4400
Signed-off-by: Simon Scherer <scherer.simon89@gmail.com>
---
target/i386/tcg/fpu_helper.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/target/i386/tcg/fpu_helper.c b/target/i386/tcg/fpu_helper.c
index 6ccc3c3b4e..9df9f2f375 100644
--- a/target/i386/tcg/fpu_helper.c
+++ b/target/i386/tcg/fpu_helper.c
@@ -520,6 +520,8 @@ void helper_fxchg_ST0_STN(CPUX86State *env, int st_index)
tmp = ST(st_index);
ST(st_index) = ST0;
ST0 = tmp;
+ env->fptags[env->fpstt] = 0;
+ env->fptags[(env->fpstt + st_index) & 7] = 0;
}
/* FPU operations */
--
2.53.0
prev parent reply other threads:[~2026-09-02 12:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 12:04 [PATCH 0/2] target/i386: Fix FPU tag word for FSTP/FXCH Simon Scherer
2026-09-02 12:04 ` [PATCH 1/2] target/i386: Update FPU tag word for FSTP Simon Scherer
2026-09-02 12:04 ` Simon Scherer [this message]
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=20260902120419.212855-3-scherer.simon89@gmail.com \
--to=scherer.simon89@gmail.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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.