All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: liweiwei <liweiwei@iscas.ac.cn>, qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com,
	bmeng@tinylab.org, zhiwei_liu@linux.alibaba.com,
	palmer@rivosinc.com
Subject: Re: [PATCH for-8.1 v2 16/26] target/riscv/cpu.c: split RVG code from validate_set_extensions()
Date: Wed, 15 Mar 2023 10:50:57 -0300	[thread overview]
Message-ID: <2a13891e-9b5e-fc3c-308c-7d5b6eb0cfa0@ventanamicro.com> (raw)
In-Reply-To: <dbb76e1d-112f-1de0-211d-8d0762757ac3@iscas.ac.cn>



On 3/15/23 01:43, liweiwei wrote:
> 
> On 2023/3/15 00:49, Daniel Henrique Barboza wrote:
>> We can set all RVG related extensions during realize time, before
>> validate_set_extensions() itself. It will also avoid re-enabling
>> RVG via write_misa() when the CSR start to using the same validation
>> code realize() does.
>>
>> Note that we're setting both cfg->ext_N and env->misa_ext bits, instead
>> of just setting cfg->ext_N. The intention here is to start syncing all
>> misa_ext operations with its cpu->cfg flags, in preparation to allow for
>> the validate function to operate using a misa_ext. This doesn't make any
>> difference for the current code state, but will be a requirement for
>> write_misa() later on.
>>
>> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
>> ---
>>   target/riscv/cpu.c | 55 +++++++++++++++++++++++++++++++++-------------
>>   1 file changed, 40 insertions(+), 15 deletions(-)
>>
>> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
>> index 48ad7372b9..133807e39f 100644
>> --- a/target/riscv/cpu.c
>> +++ b/target/riscv/cpu.c
>> @@ -281,6 +281,42 @@ static uint32_t riscv_get_misa_ext_with_cpucfg(RISCVCPUConfig *cfg)
>>       return ext;
>>   }
>> +static void riscv_set_G_virt_ext(RISCVCPU *cpu)
>> +{
>> +    CPURISCVState *env = &cpu->env;
>> +    RISCVCPUConfig *cfg = &cpu->cfg;
>> +
>> +    if (!(cfg->ext_i && cfg->ext_m && cfg->ext_a &&
>> +          cfg->ext_f && cfg->ext_d &&
>> +          cfg->ext_icsr && cfg->ext_ifencei)) {
>> +
>> +        warn_report("Setting G will also set IMAFD_Zicsr_Zifencei");
>> +        cfg->ext_i = true;
>> +        env->misa_ext |= RVI;
>> +
>> +        cfg->ext_m = true;
>> +        env->misa_ext |= RVM;
>> +
>> +        cfg->ext_a = true;
>> +        env->misa_ext |= RVA;
>> +
>> +        cfg->ext_f = true;
>> +        env->misa_ext |= RVF;
>> +
>> +        cfg->ext_d = true;
>> +        env->misa_ext |= RVD;
>> +
>> +        cfg->ext_icsr = true;
>> +        cfg->ext_ifencei = true;
>> +
>> +        /*
>> +         * Update misa_ext_mask since this is called
>> +         * only during riscv_cpu_realize().
>> +         */
>> +        env->misa_ext_mask = env->misa_ext;
>> +    }
> 
> Another two question:
> 
> - whether we should set 'G' when all these extensions are supported?

As far as I can tell, no. RVG is being treated as a shortcut to enabled this set of
extensions, but it doesn't mean that if the user happens to chose them manually we
should enable RVG.

> 
> - whether 'G'should be disabled if some of the extensions are disabled by write_misa?

Good point. Yes, we would need to disable RVG if RVG is enabled in the hart but
then another letter extension to the group (I,M,A F or D) is disabled. Which is
something that isn't being handled now.

A simple solution is, in patch 15,  forbid IMAFD to be disabled if RVG is already
set.

In fact, this kind of logic is something that we would need to do for the future
profile extension, so in a way RVG is being handled almost like a profile now.


Thanks,


Daniel




> 
> Regards,
> 
> Weiwei Li
> 
>> +}
>> +
>>   static void riscv_set_cpucfg_with_misa(RISCVCPUConfig *cfg,
>>                                          uint32_t misa_ext)
>>   {
>> @@ -1036,21 +1072,6 @@ static void riscv_cpu_validate_set_extensions(RISCVCPU *cpu, Error **errp)
>>           return;
>>       }
>> -    /* Do some ISA extension error checking */
>> -    if (cpu->cfg.ext_g && !(cpu->cfg.ext_i && cpu->cfg.ext_m &&
>> -                            cpu->cfg.ext_a && cpu->cfg.ext_f &&
>> -                            cpu->cfg.ext_d &&
>> -                            cpu->cfg.ext_icsr && cpu->cfg.ext_ifencei)) {
>> -        warn_report("Setting G will also set IMAFD_Zicsr_Zifencei");
>> -        cpu->cfg.ext_i = true;
>> -        cpu->cfg.ext_m = true;
>> -        cpu->cfg.ext_a = true;
>> -        cpu->cfg.ext_f = true;
>> -        cpu->cfg.ext_d = true;
>> -        cpu->cfg.ext_icsr = true;
>> -        cpu->cfg.ext_ifencei = true;
>> -    }
>> -
>>       if (cpu->cfg.ext_i && cpu->cfg.ext_e) {
>>           error_setg(errp,
>>                      "I and E extensions are incompatible");
>> @@ -1313,6 +1334,10 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
>>           return;
>>       }
>> +    if (cpu->cfg.ext_g) {
>> +        riscv_set_G_virt_ext(cpu);
>> +    }
>> +
>>       riscv_cpu_validate_set_extensions(cpu, &local_err);
>>       if (local_err != NULL) {
>>           error_propagate(errp, local_err);
> 


  reply	other threads:[~2023-03-15 13:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 16:49 [PATCH for-8.1 v2 00/26] target/riscv: rework CPU extensions validation Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 01/26] target/riscv/cpu.c: add riscv_cpu_validate_v() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 02/26] target/riscv/cpu.c: remove set_vext_version() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 03/26] target/riscv/cpu.c: remove set_priv_version() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 04/26] target/riscv: add PRIV_VERSION_LATEST Daniel Henrique Barboza
2023-03-14 17:36   ` Richard Henderson
2023-03-14 16:49 ` [PATCH for-8.1 v2 05/26] target/riscv/cpu.c: add priv_spec validate/disable_exts helpers Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 06/26] target/riscv/cpu.c: add riscv_cpu_validate_misa_mxl() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 07/26] target/riscv: move pmp and epmp validations to validate_set_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 08/26] target/riscv/cpu.c: validate extensions before riscv_timer_init() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 09/26] target/riscv/cpu.c: remove cfg setup from riscv_cpu_init() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 10/26] target/riscv/cpu.c: avoid set_misa() in validate_set_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 11/26] target/riscv/cpu.c: set cpu config in set_misa() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 12/26] target/riscv/cpu.c: redesign register_cpu_props() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 13/26] target/riscv: put env->misa_ext <-> cpu->cfg code into helpers Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 14/26] target/riscv: add RVG Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 15/26] target/riscv: do not allow RVG in write_misa() Daniel Henrique Barboza
2023-03-15  3:52   ` liweiwei
2023-03-14 16:49 ` [PATCH for-8.1 v2 16/26] target/riscv/cpu.c: split RVG code from validate_set_extensions() Daniel Henrique Barboza
2023-03-15  4:43   ` liweiwei
2023-03-15 13:50     ` Daniel Henrique Barboza [this message]
2023-03-14 16:49 ` [PATCH for-8.1 v2 17/26] target/riscv: write env->misa_ext* in register_generic_cpu_props() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 18/26] target/risc/cpu.c: add riscv_cpu_validate_misa_ext() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 19/26] target/riscv/cpu:c add misa_ext V-> D & F dependency Daniel Henrique Barboza
2023-03-15  4:51   ` liweiwei
2023-03-14 16:49 ` [PATCH for-8.1 v2 20/26] target/riscv: move riscv_cpu_validate_v() to validate_misa_ext() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 21/26] target/riscv: validate_misa_ext() now validates a misa_ext val Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 22/26] target/riscv: error out on priv failure for RVH Daniel Henrique Barboza
2023-03-15  5:07   ` liweiwei
2023-03-14 16:49 ` [PATCH for-8.1 v2 23/26] target/riscv: split riscv_cpu_validate_set_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 24/26] target/riscv: use misa_ext val in riscv_cpu_validate_extensions() Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 25/26] target/riscv: rework write_misa() Daniel Henrique Barboza
2023-03-15  5:25   ` liweiwei
2023-03-15 20:37     ` Daniel Henrique Barboza
2023-03-17  3:04       ` liweiwei
2023-03-17 11:54         ` Daniel Henrique Barboza
2023-03-14 16:49 ` [PATCH for-8.1 v2 26/26] target/riscv: update cpu->cfg misa bits in commit_cpu_cfg() Daniel Henrique Barboza

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=2a13891e-9b5e-fc3c-308c-7d5b6eb0cfa0@ventanamicro.com \
    --to=dbarboza@ventanamicro.com \
    --cc=alistair.francis@wdc.com \
    --cc=bmeng@tinylab.org \
    --cc=liweiwei@iscas.ac.cn \
    --cc=palmer@rivosinc.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 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.