From: Frank Chang <frank.chang@sifive.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: "open list:RISC-V" <qemu-riscv@nongnu.org>,
Bin Meng <bin.meng@windriver.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Vincent Chen <vincent.chen@sifive.com>,
Alistair Francis <alistair.francis@wdc.com>,
Palmer Dabbelt <palmer@dabbelt.com>
Subject: Re: [PATCH RESEND v2] target/riscv: Set mstatus_hs.[SD|FS] bits if Clean and V=1 in mark_fs_dirty()
Date: Sun, 19 Sep 2021 10:54:10 +0800 [thread overview]
Message-ID: <CAE_xrPh+CzNK-nnsO6NSk+FKowXW2Tbva9abhpgAD13xfPak4A@mail.gmail.com> (raw)
In-Reply-To: <93e9a615-94fb-3958-9560-111910668768@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 3193 bytes --]
On Sun, Sep 19, 2021 at 2:46 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> On 9/17/21 2:31 AM, frank.chang@sifive.com wrote:
> > From: Frank Chang <frank.chang@sifive.com>
> >
> > When V=1, both vsstauts.FS and HS-level sstatus.FS are in effect.
> > Modifying the floating-point state when V=1 causes both fields to
> > be set to 3 (Dirty).
> >
> > However, it's possible that HS-level sstatus.FS is Clean and VS-level
> > vsstatus.FS is Dirty at the time mark_fs_dirty() is called when V=1.
> > We can't early return for this case because we still need to set
> > sstatus.FS to Dirty according to spec.
> >
> > Signed-off-by: Frank Chang <frank.chang@sifive.com>
> > Reviewed-by: Vincent Chen <vincent.chen@sifive.com>
> > Tested-by: Vincent Chen <vincent.chen@sifive.com>
> > ---
> > target/riscv/cpu.h | 4 ++++
> > target/riscv/translate.c | 24 +++++++++++++++---------
> > 2 files changed, 19 insertions(+), 9 deletions(-)
>
>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> > static void mark_fs_dirty(DisasContext *ctx)
> > {
> > TCGv tmp;
> > - target_ulong sd;
> > + target_ulong sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD;
> > +
> > + if (ctx->virt_enabled && ctx->mstatus_hs_fs != MSTATUS_FS) {
> > + /* Remember the stage change for the rest of the TB. */
> > + ctx->mstatus_hs_fs = MSTATUS_FS;
> > +
> > + tmp = tcg_temp_new();
> > + tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState,
> mstatus_hs));
> > + tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd);
> > + tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState,
> mstatus_hs));
> > + tcg_temp_free(tmp);
> > + }
> >
> > if (ctx->mstatus_fs == MSTATUS_FS) {
> > return;
> > }
> > +
> > /* Remember the state change for the rest of the TB. */
> > ctx->mstatus_fs = MSTATUS_FS;
> >
> > tmp = tcg_temp_new();
> > - sd = is_32bit(ctx) ? MSTATUS32_SD : MSTATUS64_SD;
> > -
> > tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
> > tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd);
> > tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState, mstatus));
> > -
> > - if (ctx->virt_enabled) {
> > - tcg_gen_ld_tl(tmp, cpu_env, offsetof(CPURISCVState,
> mstatus_hs));
> > - tcg_gen_ori_tl(tmp, tmp, MSTATUS_FS | sd);
> > - tcg_gen_st_tl(tmp, cpu_env, offsetof(CPURISCVState,
> mstatus_hs));
> > - }
> > tcg_temp_free(tmp);
>
> While it works, it would be nicer to keep these two cases as similar as
> possible.
>
>
Hi, Richard, thanks for the review.
Do you mean it's better to change to code sequence to something like:
static void mark_fs_dirty(DisasContext *ctx)
{
.....
if (ctx->virt_enabled && ctx->mstatus_hs_fs != MSTATUS_FS) {
/* Remember the stage change for the rest of the TB. */
ctx->mstatus_hs_fs = MSTATUS_FS;
.....
}
if (ctx->mstatus_fs != MSTATUS_FS) {
/* Remember the state change for the rest of the TB. */
ctx->mstatus_fs = MSTATUS_FS;
.....
}
}
If so, I can update and send out the v3 patch.
Regards,
Frank Chang
>
> r~
>
[-- Attachment #2: Type: text/html, Size: 5010 bytes --]
next prev parent reply other threads:[~2021-09-19 2:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-17 9:31 [PATCH RESEND v2] target/riscv: Set mstatus_hs.[SD|FS] bits if Clean and V=1 in mark_fs_dirty() frank.chang
2021-09-18 18:46 ` Richard Henderson
2021-09-19 2:54 ` Frank Chang [this message]
2021-09-19 16:32 ` 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=CAE_xrPh+CzNK-nnsO6NSk+FKowXW2Tbva9abhpgAD13xfPak4A@mail.gmail.com \
--to=frank.chang@sifive.com \
--cc=alistair.francis@wdc.com \
--cc=bin.meng@windriver.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=vincent.chen@sifive.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).