From: Richard Henderson <richard.henderson@linaro.org>
To: Ziqiao Kong <ziqiaokong@gmail.com>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, ehabkost@redhat.com
Subject: Re: [PATCH v7 2/2] target/i386: Correct implementation for FCS, FIP, FDS and FDP
Date: Wed, 7 Jul 2021 14:08:26 -0700 [thread overview]
Message-ID: <56f215ae-8535-90ee-44f7-a30e712e0318@linaro.org> (raw)
In-Reply-To: <20210530150112.74411-2-ziqiaokong@gmail.com>
On 5/30/21 8:01 AM, Ziqiao Kong wrote:
> /* fninit */
> - env->fpus = 0;
> - env->fpstt = 0;
> - cpu_set_fpuc(env, 0x37f);
> - env->fptags[0] = 1;
> - env->fptags[1] = 1;
> - env->fptags[2] = 1;
> - env->fptags[3] = 1;
> - env->fptags[4] = 1;
> - env->fptags[5] = 1;
> - env->fptags[6] = 1;
> - env->fptags[7] = 1;
> + helper_fninit(env);
Directly calling a function named "helper" is bad practice. Those should only be called
from TCG generated code. In this case it happens to be ok, since helper_fninit does not
use GETPC(), but really we should break out a "do_fninit" function to share.
> case 0xd8 ... 0xdf:
> {
> + TCGv last_addr = tcg_temp_new();
> + int last_seg;
> + bool update_fdp = false;
These belong...
> @@ -5942,7 +5947,14 @@ static target_ulong disas_insn(DisasContext *s, CPUState *cpu)
> op = ((b & 7) << 3) | ((modrm >> 3) & 7);
> if (mod != 3) {
> /* memory op */
> - gen_lea_modrm(env, s, modrm);
> + AddressParts a = gen_lea_modrm_0(env, s, modrm);
... here, within the section that deals with memory operands.
> + if (update_fip) {
> + tcg_gen_ld32u_tl(s->T0, cpu_env,
> + offsetof(CPUX86State, segs[R_CS].selector));
> + tcg_gen_st16_tl(s->T0, cpu_env, offsetof(CPUX86State, fpcs));
> +
> + tcg_gen_movi_tl(s->T0, pc_start - s->cs_base);
> + tcg_gen_st_tl(s->T0, cpu_env, offsetof(CPUX86State, fpip));
> + }
> +
> + if (update_fdp) {
> + if (s->override >= 0) {
> + last_seg = s->override;
> + }
> + tcg_gen_ld32u_tl(s->T0, cpu_env,
> + offsetof(CPUX86State,
> + segs[last_seg].selector));
> + tcg_gen_st16_tl(s->T0, cpu_env, offsetof(CPUX86State, fpds));
> +
> + tcg_gen_st_tl(last_addr, cpu_env, offsetof(CPUX86State, fpdp));
> + }
Similarly the update_fdp test belongs at the end of the memory op block.
r~
next prev parent reply other threads:[~2021-07-07 21:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-30 15:01 [PATCH v7 1/2] target/i386: Trivial code motion and code style fix Ziqiao Kong
2021-05-30 15:01 ` [PATCH v7 2/2] target/i386: Correct implementation for FCS, FIP, FDS and FDP Ziqiao Kong
2021-06-04 15:04 ` Ziqiao Kong
2021-06-11 14:32 ` Ziqiao Kong
2021-06-24 17:06 ` Ziqiao Kong
2021-07-01 13:58 ` Ziqiao Kong
2021-07-06 14:20 ` Ziqiao Kong
2021-07-06 22:20 ` Eduardo Habkost
2021-07-07 21:08 ` Richard Henderson [this message]
2021-06-04 15:04 ` [PATCH v7 1/2] target/i386: Trivial code motion and code style fix Ziqiao Kong
2021-06-11 14:32 ` Ziqiao Kong
2021-06-24 17:06 ` Ziqiao Kong
2021-07-01 13:58 ` Ziqiao Kong
2021-07-06 14:20 ` Ziqiao Kong
2021-07-07 21:01 ` Richard Henderson
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=56f215ae-8535-90ee-44f7-a30e712e0318@linaro.org \
--to=richard.henderson@linaro.org \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=ziqiaokong@gmail.com \
/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 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).