From: Weiwei Li <liweiwei@iscas.ac.cn>
To: Mayuresh Chitale <mchitale@ventanamicro.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
alistair.francis@wdc.com
Cc: liweiwei@iscas.ac.cn, Alistair Francis <alistair23@gmail.com>,
Daniel Barboza <dbarboza@ventanamicro.com>,
Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH v3 2/4] target/riscv: Reuse tb->flags.FS
Date: Sat, 29 Apr 2023 09:17:32 +0800 [thread overview]
Message-ID: <2080f38b-59ad-cb5b-02ee-f78f12a75414@iscas.ac.cn> (raw)
In-Reply-To: <20230428165212.2800669-3-mchitale@ventanamicro.com>
On 2023/4/29 00:52, Mayuresh Chitale wrote:
> When misa.F is 0 tb->flags.FS field is unused and can be used to save
> the current state of smstateen0.FCSR check which is needed by the
> floating point translation routines.
>
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> ---
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Weiwei Li
> target/riscv/cpu_helper.c | 9 +++++++++
> target/riscv/translate.c | 12 +++++++++++-
> 2 files changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
> index b68dcfe7b6..126ac221a0 100644
> --- a/target/riscv/cpu_helper.c
> +++ b/target/riscv/cpu_helper.c
> @@ -119,6 +119,15 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
> vs = MIN(vs, get_field(env->mstatus_hs, MSTATUS_VS));
> }
>
> + /*
> + * If misa.F is 0 then the FS field of the tb->flags can be used to pass
> + * the current state of the smstateen.FCSR bit which must be checked for
> + * in the floating point translation routines.
> + */
> + if (!riscv_has_ext(env, RVF)) {
> + fs = (smstateen_acc_ok(env, 0, SMSTATEEN0_FCSR) == RISCV_EXCP_NONE);
> + }
> +
> if (cpu->cfg.debug && !icount_enabled()) {
> flags = FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enabled);
> }
> diff --git a/target/riscv/translate.c b/target/riscv/translate.c
> index 928da0d3f0..74f624aa62 100644
> --- a/target/riscv/translate.c
> +++ b/target/riscv/translate.c
> @@ -78,6 +78,7 @@ typedef struct DisasContext {
> int frm;
> RISCVMXL ol;
> bool virt_inst_excp;
> + bool smstateen_fcsr_ok;
> bool virt_enabled;
> const RISCVCPUConfig *cfg_ptr;
> /* vector extension */
> @@ -1155,7 +1156,11 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
> ctx->pc_succ_insn = ctx->base.pc_first;
> ctx->priv = FIELD_EX32(tb_flags, TB_FLAGS, PRIV);
> ctx->mem_idx = FIELD_EX32(tb_flags, TB_FLAGS, MEM_IDX);
> - ctx->mstatus_fs = FIELD_EX32(tb_flags, TB_FLAGS, FS);
> + if (has_ext(ctx, RVF)) {
> + ctx->mstatus_fs = FIELD_EX32(tb_flags, TB_FLAGS, FS);
> + } else {
> + ctx->mstatus_fs = 0;
> + }
> ctx->mstatus_vs = FIELD_EX32(tb_flags, TB_FLAGS, VS);
> ctx->priv_ver = env->priv_ver;
> ctx->virt_enabled = FIELD_EX32(tb_flags, TB_FLAGS, VIRT_ENABLED);
> @@ -1178,6 +1183,11 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
> ctx->itrigger = FIELD_EX32(tb_flags, TB_FLAGS, ITRIGGER);
> ctx->zero = tcg_constant_tl(0);
> ctx->virt_inst_excp = false;
> + if (has_ext(ctx, RVF) || !cpu->cfg.ext_smstateen) {
> + ctx->smstateen_fcsr_ok = 1;
> + } else {
> + ctx->smstateen_fcsr_ok = FIELD_EX32(tb_flags, TB_FLAGS, FS);
> + }
> }
>
> static void riscv_tr_tb_start(DisasContextBase *db, CPUState *cpu)
next prev parent reply other threads:[~2023-04-29 1:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-28 16:52 [PATCH v3 0/4] Smstateen FCSR Mayuresh Chitale
2023-04-28 16:52 ` [PATCH v3 1/4] target/riscv: smstateen check for fcsr Mayuresh Chitale
2023-04-28 16:52 ` [PATCH v3 2/4] target/riscv: Reuse tb->flags.FS Mayuresh Chitale
2023-04-29 1:17 ` Weiwei Li [this message]
2023-04-29 8:54 ` Richard Henderson
2023-04-29 9:20 ` Weiwei Li
2023-04-28 16:52 ` [PATCH v3 3/4] target/riscv: check smstateen fcsr flag Mayuresh Chitale
2023-04-29 1:20 ` Weiwei Li
2023-04-28 16:52 ` [PATCH v3 4/4] target/riscv: smstateen knobs Mayuresh Chitale
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=2080f38b-59ad-cb5b-02ee-f78f12a75414@iscas.ac.cn \
--to=liweiwei@iscas.ac.cn \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=dbarboza@ventanamicro.com \
--cc=mchitale@ventanamicro.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@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 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).