qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Cc: "Alex Bennée" <alex.bennee@linaro.org>,
	"Mikhail Tyutin" <m.tyutin@yadro.com>,
	"Aleksandr Anenkov" <a.anenkov@yadro.com>,
	qemu-devel@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Weiwei Li" <liweiwei@iscas.ac.cn>,
	"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
	"open list:RISC-V TCG CPUs" <qemu-riscv@nongnu.org>,
	"Richard Henderson" <richard.henderson@linaro.org>
Subject: Re: [PATCH 1/4] target/riscv: Remove misa_mxl validation
Date: Wed, 18 Oct 2023 21:19:13 +0900	[thread overview]
Message-ID: <fe9d34fc-8dbb-4c90-a6b4-1539c3b86c0f@daynix.com> (raw)
In-Reply-To: <a3fd0789-c09b-4a34-b3d3-d36ac5201750@linux.alibaba.com>

On 2023/10/18 14:53, LIU Zhiwei wrote:
> +CC Richard
> 
> On 2023/10/17 11:37, Akihiko Odaki wrote:
>> On 2023/10/17 11:29, LIU Zhiwei wrote:
>>>
>>> On 2023/10/12 13:42, Akihiko Odaki wrote:
>>>> It is initialized with a simple assignment and there is little room for
>>>> error. In fact, the validation is even more complex.
>>>>
>>>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>>>> ---
>>>>   target/riscv/cpu.c | 13 ++-----------
>>>>   1 file changed, 2 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
>>>> index f5572704de..550b357fb7 100644
>>>> --- a/target/riscv/cpu.c
>>>> +++ b/target/riscv/cpu.c
>>>> @@ -1042,7 +1042,7 @@ static void 
>>>> riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu)
>>>>       }
>>>>   }
>>>> -static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu, Error **errp)
>>>> +static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu)
>>>>   {
>>>>       RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
>>>>       CPUClass *cc = CPU_CLASS(mcc);
>>>> @@ -1062,11 +1062,6 @@ static void 
>>>> riscv_cpu_validate_misa_mxl(RISCVCPU *cpu, Error **errp)
>>>>       default:
>>>>           g_assert_not_reached();
>>>>       }
>>>> -
>>>> -    if (env->misa_mxl_max != env->misa_mxl) {
>>>> -        error_setg(errp, "misa_mxl_max must be equal to misa_mxl");
>>>> -        return;
>>>> -    }
>>>>   }
>>>>   /*
>>>> @@ -1447,11 +1442,7 @@ static void riscv_cpu_realize_tcg(DeviceState 
>>>> *dev, Error **errp)
>>>>           return;
>>>>       }
>>>> -    riscv_cpu_validate_misa_mxl(cpu, &local_err);
>>>> -    if (local_err != NULL) {
>>>> -        error_propagate(errp, local_err);
>>>> -        return;
>>>> -    }
>>>> +    riscv_cpu_validate_misa_mxl(cpu);
>>>
>>> This it not right.  As we are still working on the supporting for 
>>> MXL32 or SXL32, this validation is needed.
>>
>> It's not preventing supporting MXL32 or SXL32. It's removing 
>> env->misa_mxl_max != env->misa_mxl just because it's initialized with 
>> a simple statement:
>> env->misa_mxl_max = env->misa_mxl = mxl;
>>
>> It makes little sense to have a validation code that is more complex 
>> than the validated code.
>>
>>>
>>> And we can't ensure the all RISC-V cpus have the same misa_mxl_max or 
>>> misa_mxl,   it is not right to move it to class.
>>> For example, in the future, riscv64-softmmu can run 32-bit cpu and 
>>> 64-bit cpu. And maybe in heterogeneous SOC,
>>> we have 32-bit cpu and 64-bit cpu together.
>>
>> This patch series does not touch misa_mxl. We don't need to ensure 
>> that all CPUs have the same misa_mxl_max, but we just need to ensure 
>> that CPUs in the same class do. Creating a heterogeneous SoC is still 
>> possible by combining e.g. TYPE_RISCV_CPU_SIFIVE_E31 and 
>> TYPE_RISCV_CPU_SIFIVE_E51, for example.
> 
> I see what you mean. It makes sense  to move the misa_mxl_max field from 
> env to the class struct. The misa_mxl_max  is always be set by  cpu init 
> or the migration.
> 
> The former  is OK. I don't know whether QEMU supports migration from 
> 32-bit CPU to 64-bit CPU. Otherwise,
> 
> Acked-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>

It doesn't. docs/devel/migration.rst states:
 > For this to work, QEMU has to be launched with the same arguments the
 > two times.  I.e. it can only restore the state in one guest that has
 > the same devices that the one it was saved (this last requirement can
 > be relaxed a bit, but for now we can consider that configuration has
 > to be exactly the same).

The corresponding CPUs in two QEMU instances launched with the same 
arguments will have the same misa_mxl_max values.


  reply	other threads:[~2023-10-18 12:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-12  5:42 [PATCH 0/4] gdbstub and TCG plugin improvements Akihiko Odaki
2023-10-12  5:42 ` [PATCH 1/4] target/riscv: Remove misa_mxl validation Akihiko Odaki
2023-10-13 17:12   ` Daniel Henrique Barboza
2023-10-17  2:29   ` LIU Zhiwei
2023-10-17  3:37     ` Akihiko Odaki
2023-10-18  5:53       ` LIU Zhiwei
2023-10-18 12:19         ` Akihiko Odaki [this message]
2023-10-12  5:42 ` [PATCH 2/4] target/riscv: Move misa_mxl_max to class Akihiko Odaki
2023-10-13 17:47   ` Daniel Henrique Barboza
2023-10-12  5:42 ` [PATCH 3/4] target/riscv: Validate misa_mxl_max only once Akihiko Odaki
2023-10-12  5:42 ` [PATCH 4/4] plugins: Remove an extra parameter Akihiko Odaki

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=fe9d34fc-8dbb-4c90-a6b4-1539c3b86c0f@daynix.com \
    --to=akihiko.odaki@daynix.com \
    --cc=a.anenkov@yadro.com \
    --cc=alex.bennee@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=liweiwei@iscas.ac.cn \
    --cc=m.tyutin@yadro.com \
    --cc=palmer@dabbelt.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.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).