All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: Ben Dooks <ben.dooks@codethink.co.uk>,
	Weiwei Li <liweiwei@iscas.ac.cn>,
	qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: alistair.francis@wdc.com
Subject: Re: [PATCH v6 3/5] target/riscv: smstateen check for fcsr
Date: Fri, 29 Jul 2022 17:59:16 +0530	[thread overview]
Message-ID: <ea27c17be274bc650c458769ec41259acbccb8aa.camel@ventanamicro.com> (raw)
In-Reply-To: <a0267001-a369-cfab-40ac-05037649166c@codethink.co.uk>

On Thu, 2022-07-28 at 09:09 +0100, Ben Dooks wrote:
> On 28/07/2022 07:15, Mayuresh Chitale wrote:
> > On Mon, 2022-07-25 at 15:23 +0800, Weiwei Li wrote:
> > > 在 2022/7/24 下午11:49, Mayuresh Chitale 写道:
> > > > On Fri, 2022-07-22 at 09:42 +0800, Weiwei Li wrote:
> > > > > 在 2022/7/21 下午11:31, Mayuresh Chitale 写道:
> > > > > > If smstateen is implemented and sstateen0.fcsr is clear
> > > > > > then
> > > > > > the
> > > > > > floating point operations must return illegal instruction
> > > > > > exception.
> > > > > > 
> > > > > > Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> > > > > > ---
> > > > > >    target/riscv/csr.c                        | 23
> > > > > > ++++++++++++++
> > > > > >    target/riscv/insn_trans/trans_rvf.c.inc   | 38
> > > > > > +++++++++++++++++++++--
> > > > > >    target/riscv/insn_trans/trans_rvzfh.c.inc |  4 +++
> > > > > >    3 files changed, 63 insertions(+), 2 deletions(-)
> > > > > > 
> > > > > > diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> > > > > > index ab06b117f9..a597b6cbc7 100644
> > > > > > --- a/target/riscv/csr.c
> > > > > > +++ b/target/riscv/csr.c
> > > > > > @@ -96,6 +96,10 @@ static RISCVException fs(CPURISCVState
> > > > > > *env,
> > > > > > int
> > > > > > csrno)
> > > > > >            !RISCV_CPU(env_cpu(env))->cfg.ext_zfinx) {
> > > > > >            return RISCV_EXCP_ILLEGAL_INST;
> > > > > >        }
> > > > > > +
> > > > > > +    if (!env->debugger && !riscv_cpu_fp_enabled(env)) {
> > > > > > +        return smstateen_acc_ok(env, 0, SMSTATEEN0_FCSR);
> > > > > > +    }
> > > > > >    #endif
> > > > > >        return RISCV_EXCP_NONE;
> > > > > >    }
> > > > > > @@ -1876,6 +1880,9 @@ static RISCVException
> > > > > > write_mstateen0(CPURISCVState *env, int csrno,
> > > > > >                                          target_ulong
> > > > > > new_val)
> > > > > >    {
> > > > > >        uint64_t wr_mask = SMSTATEEN_STATEN |
> > > > > > SMSTATEEN0_HSENVCFG;
> > > > > > +    if (!riscv_has_ext(env, RVF)) {
> > > > > > +        wr_mask |= SMSTATEEN0_FCSR;
> > > > > > +    }
> > > > > >    
> > > > > >        return write_mstateen(env, csrno, wr_mask, new_val);
> > > > > >    }
> > > > > > @@ -1924,6 +1931,10 @@ static RISCVException
> > > > > > write_mstateen0h(CPURISCVState *env, int csrno,
> > > > > >    {
> > > > > >        uint64_t wr_mask = SMSTATEEN_STATEN |
> > > > > > SMSTATEEN0_HSENVCFG;
> > > > > >    
> > > > > > +    if (!riscv_has_ext(env, RVF)) {
> > > > > > +        wr_mask |= SMSTATEEN0_FCSR;
> > > > > > +    }
> > > > > > +
> > > > > >        return write_mstateenh(env, csrno, wr_mask,
> > > > > > new_val);
> > > > > >    }
> > > > > >    
> > > > > > @@ -1973,6 +1984,10 @@ static RISCVException
> > > > > > write_hstateen0(CPURISCVState *env, int csrno,
> > > > > >    {
> > > > > >        uint64_t wr_mask = SMSTATEEN_STATEN |
> > > > > > SMSTATEEN0_HSENVCFG;
> > > > > >    
> > > > > > +    if (!riscv_has_ext(env, RVF)) {
> > > > > > +        wr_mask |= SMSTATEEN0_FCSR;
> > > > > > +    }
> > > > > > +
> > > > > >        return write_hstateen(env, csrno, wr_mask, new_val);
> > > > > >    }
> > > > > >    
> > > > > > @@ -2024,6 +2039,10 @@ static RISCVException
> > > > > > write_hstateen0h(CPURISCVState *env, int csrno,
> > > > > >    {
> > > > > >        uint64_t wr_mask = SMSTATEEN_STATEN |
> > > > > > SMSTATEEN0_HSENVCFG;
> > > > > >    
> > > > > > +    if (!riscv_has_ext(env, RVF)) {
> > > > > > +        wr_mask |= SMSTATEEN0_FCSR;
> > > > > > +    }
> > > > > > +
> > > > > >        return write_hstateenh(env, csrno, wr_mask,
> > > > > > new_val);
> > > > > >    }
> > > > > >    
> > > > > > @@ -2083,6 +2102,10 @@ static RISCVException
> > > > > > write_sstateen0(CPURISCVState *env, int csrno,
> > > > > >    {
> > > > > >        uint64_t wr_mask = SMSTATEEN_STATEN |
> > > > > > SMSTATEEN0_HSENVCFG;
> > > > > >    
> > > > > > +    if (!riscv_has_ext(env, RVF)) {
> > > > > > +        wr_mask |= SMSTATEEN0_FCSR;
> > > > > > +    }
> > > > > > +
> > > > > >        return write_sstateen(env, csrno, wr_mask, new_val);
> > > > > >    }
> > > > > >    
> > > > > > diff --git a/target/riscv/insn_trans/trans_rvf.c.inc
> > > > > > b/target/riscv/insn_trans/trans_rvf.c.inc
> > > > > > index a1d3eb52ad..c43c48336b 100644
> > > > > > --- a/target/riscv/insn_trans/trans_rvf.c.inc
> > > > > > +++ b/target/riscv/insn_trans/trans_rvf.c.inc
> > > > > > @@ -24,9 +24,43 @@
> > > > > >                return false; \
> > > > > >    } while (0)
> > > > > >    
> > > > > > +#ifndef CONFIG_USER_ONLY
> > > > > > +#define SMSTATEEN_CHECK(ctx) do {\
> > > > > > +    CPUState *cpu = ctx->cs; \
> > > > > > +    CPURISCVState *env = cpu->env_ptr; \
> > > > > > +    if (ctx->cfg_ptr->ext_smstateen && \
> > > > > > +        (env->priv < PRV_M)) { \
> > > > > > +        uint64_t stateen = env->mstateen[0]; \
> > > > > > +        uint64_t hstateen = env->hstateen[0]; \
> > > > > > +        uint64_t sstateen = env->sstateen[0]; \
> > > > > > +        if (!(stateen & SMSTATEEN_STATEN)) {\
> > > > > > +            hstateen = 0; \
> > > > > > +            sstateen = 0; \
> > > > > > +        } \
> > > > > > +        if (ctx->virt_enabled) { \
> > > > > > +            stateen &= hstateen; \
> > > > > > +            if (!(hstateen & SMSTATEEN_STATEN)) {\
> > > > > > +                sstateen = 0; \
> > > > > > +            } \
> > > > > > +        } \
> > > > > > +        if (env->priv == PRV_U && has_ext(ctx, RVS))
> > > > > > {\eventually
> > > > > > meaning
> > > > > > +            stateen &= sstateen; \
> > > > > > +        } \
> > > > > > +        if (!(stateen & SMSTATEEN0_FCSR)) { \
> > > > > > +            return false; \
> > > > > > +        } \
> > > > > > +    } \
> 
> given the size of that I would have thought an "static inline"
> function would be easier to write and maintain for SMSTATEEN_CHECK
Ok. I will update in the next version.
> 
> 



  reply	other threads:[~2022-07-29 12:29 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21 15:31 [PATCH v6 0/5] RISC-V Smstateen support Mayuresh Chitale
2022-07-21 15:31 ` [PATCH v6 1/5] target/riscv: Add smstateen support Mayuresh Chitale
2022-07-22  0:31   ` Weiwei Li
2022-07-24 15:39     ` Mayuresh Chitale
2022-07-25  7:11       ` Weiwei Li
2022-07-28  5:39         ` Mayuresh Chitale
2022-07-21 15:31 ` [PATCH v6 2/5] target/riscv: smstateen check for h/senvcfg Mayuresh Chitale
2022-07-22  0:45   ` Weiwei Li
2022-07-28  6:41     ` Mayuresh Chitale
2022-07-28  7:59       ` Weiwei Li
2022-07-21 15:31 ` [PATCH v6 3/5] target/riscv: smstateen check for fcsr Mayuresh Chitale
2022-07-22  1:42   ` Weiwei Li
2022-07-24 15:49     ` Mayuresh Chitale
2022-07-25  7:23       ` Weiwei Li
2022-07-28  6:15         ` Mayuresh Chitale
2022-07-28  7:38           ` Weiwei Li
2022-07-28  8:09           ` Ben Dooks
2022-07-29 12:29             ` Mayuresh Chitale [this message]
2022-07-21 15:31 ` [PATCH v6 4/5] target/riscv: smstateen check for AIA/IMSIC Mayuresh Chitale
2022-07-22  1:45   ` Weiwei Li
2022-07-21 15:31 ` [PATCH v6 5/5] target/riscv: smstateen knobs Mayuresh Chitale
2022-07-22  1:47   ` Weiwei Li

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=ea27c17be274bc650c458769ec41259acbccb8aa.camel@ventanamicro.com \
    --to=mchitale@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=ben.dooks@codethink.co.uk \
    --cc=liweiwei@iscas.ac.cn \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.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.