All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weiwei Li <liweiwei@iscas.ac.cn>
To: Mayuresh Chitale <mchitale@ventanamicro.com>,
	qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: alistair.francis@wdc.com
Subject: Re: [RFC PATCH v2 2/4] target/riscv: smstateen check for h/senvcfg
Date: Wed, 23 Mar 2022 20:51:55 +0800	[thread overview]
Message-ID: <472dfd4e-099f-97e0-ba16-561df8ddeef1@iscas.ac.cn> (raw)
In-Reply-To: <20220323111309.9109-3-mchitale@ventanamicro.com>


在 2022/3/23 下午7:13, Mayuresh Chitale 写道:
> Accesses to henvcfg, henvcfgh and senvcfg are allowed
> only if corresponding bit in mstateen0/hstateen0 is
> enabled. Otherwise an illegal instruction trap is
> generated.
>
> Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
> ---
>   target/riscv/csr.c | 82 ++++++++++++++++++++++++++++++++++++++++++----
>   1 file changed, 76 insertions(+), 6 deletions(-)
>
> diff --git a/target/riscv/csr.c b/target/riscv/csr.c
> index 215c8ecef1..2388f0226f 100644
> --- a/target/riscv/csr.c
> +++ b/target/riscv/csr.c
> @@ -39,6 +39,35 @@ void riscv_set_csr_ops(int csrno, riscv_csr_operations *ops)
>   }
>   
>   /* Predicates */
> +static RISCVException smstateen_acc_ok(CPURISCVState *env, int mode, int bit)
> +{
> +    CPUState *cs = env_cpu(env);
> +    RISCVCPU *cpu = RISCV_CPU(cs);
> +    bool virt = riscv_cpu_virt_enabled(env);
> +
> +    if (!cpu->cfg.ext_smstateen) {
> +        return RISCV_EXCP_NONE;
> +    }
> +
> +    if (!(env->mstateen[0] & 1UL << bit)) {
> +        return RISCV_EXCP_ILLEGAL_INST;
> +    }

I think here should be " & (1UL << bit) " . The same for following 
similar cases.

Regards,

Weiwei Li



  reply	other threads:[~2022-03-23 12:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 11:13 [RFC PATCH v2 0/4] RISC-V Smstateen support Mayuresh Chitale
2022-03-23 11:13 ` [RFC PATCH v2 1/4] target/riscv: Add smstateen support Mayuresh Chitale
2022-03-23 13:01   ` Weiwei Li
2022-03-24  8:46     ` Mayuresh Chitale
2022-03-24  8:46       ` Mayuresh Chitale
2022-03-23 11:13 ` [RFC PATCH v2 2/4] target/riscv: smstateen check for h/senvcfg Mayuresh Chitale
2022-03-23 12:51   ` Weiwei Li [this message]
2022-03-24  8:26     ` Mayuresh Chitale
2022-03-24  8:26       ` Mayuresh Chitale
2022-03-23 11:13 ` [RFC PATCH v2 3/4] target/riscv: smstateen check for fcsr Mayuresh Chitale
2022-03-23 11:13 ` [RFC PATCH v2 4/4] target/riscv: smstateen check for AIA/IMSIC Mayuresh Chitale
2022-03-23 13:13   ` Weiwei Li
2022-03-24  8:28     ` Mayuresh Chitale
2022-03-24  8:28       ` 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=472dfd4e-099f-97e0-ba16-561df8ddeef1@iscas.ac.cn \
    --to=liweiwei@iscas.ac.cn \
    --cc=alistair.francis@wdc.com \
    --cc=mchitale@ventanamicro.com \
    --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.