From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: frank.chang@sifive.com, qemu-devel@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
"open list:RISC-V TCG CPUs" <qemu-riscv@nongnu.org>,
Max Chou <max.chou@sifive.com>
Subject: Re: [PATCH 2/2] target/riscv: Update MISA.X for non-standard extensions
Date: Mon, 17 Nov 2025 10:53:30 -0300 [thread overview]
Message-ID: <f7da44c5-e9dc-45db-9ccc-02d662ab9ad4@ventanamicro.com> (raw)
In-Reply-To: <20251114090134.1125646-3-frank.chang@sifive.com>
On 11/14/25 6:01 AM, frank.chang@sifive.com wrote:
> From: Frank Chang <frank.chang@sifive.com>
>
> MISA.X is set if there are any non-standard extensions.
> We should set MISA.X when any of the vendor extensions is enabled.
>
> Signed-off-by: Frank Chang <frank.chang@sifive.com>
> Reviewed-by: Max Chou <max.chou@sifive.com>
> ---
Reviewed-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> target/riscv/cpu.h | 1 +
> target/riscv/tcg/tcg-cpu.c | 15 +++++++++++++++
> 2 files changed, 16 insertions(+)
>
> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
> index 8899bf7667a..2e0c92fe593 100644
> --- a/target/riscv/cpu.h
> +++ b/target/riscv/cpu.h
> @@ -69,6 +69,7 @@ typedef struct CPUArchState CPURISCVState;
> #define RVH RV('H')
> #define RVG RV('G')
> #define RVB RV('B')
> +#define RVX RV('X')
>
> extern const uint32_t misa_bits[];
> const char *riscv_get_misa_ext_name(uint32_t bit);
> diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
> index da09a2417cc..0d730f4d774 100644
> --- a/target/riscv/tcg/tcg-cpu.c
> +++ b/target/riscv/tcg/tcg-cpu.c
> @@ -1180,6 +1180,20 @@ static void riscv_cpu_update_misa_c(RISCVCPU *cpu)
> }
> }
>
> +/* MISA.X is set when any of the non-standard extensions is enabled. */
> +static void riscv_cpu_update_misa_x(RISCVCPU *cpu)
> +{
> + CPURISCVState *env = &cpu->env;
> + const RISCVCPUMultiExtConfig *arr = riscv_cpu_vendor_exts;
> +
> + for (int i = 0; arr[i].name != NULL; i++) {
> + if (isa_ext_is_enabled(cpu, arr[i].offset)) {
> + riscv_cpu_set_misa_ext(env, env->misa_ext | RVX);
> + break;
> + }
> + }
> +}
> +
> void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)
> {
> CPURISCVState *env = &cpu->env;
> @@ -1188,6 +1202,7 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)
> riscv_cpu_init_implied_exts_rules();
> riscv_cpu_enable_implied_rules(cpu);
> riscv_cpu_update_misa_c(cpu);
> + riscv_cpu_update_misa_x(cpu);
>
> riscv_cpu_validate_misa_priv(env, &local_err);
> if (local_err != NULL) {
prev parent reply other threads:[~2025-11-17 13:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 9:01 [PATCH 0/2] Set MISA.[C|X] based on the selected extensions frank.chang
2025-11-14 9:01 ` [PATCH 1/2] target/riscv: Update MISA.C for Zc* extensions frank.chang
2025-11-17 13:53 ` Daniel Henrique Barboza
2025-11-14 9:01 ` [PATCH 2/2] target/riscv: Update MISA.X for non-standard extensions frank.chang
2025-11-17 13:53 ` Daniel Henrique Barboza [this message]
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=f7da44c5-e9dc-45db-9ccc-02d662ab9ad4@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=frank.chang@sifive.com \
--cc=liwei1518@gmail.com \
--cc=max.chou@sifive.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.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).