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>,
"Fabiano Rosas" <farosas@suse.de>,
"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>,
qemu-riscv@nongnu.org
Subject: Re: [PATCH v4 3/5] target/riscv: Move misa_mxl_max to class
Date: Wed, 18 Oct 2023 21:23:00 +0900 [thread overview]
Message-ID: <06d5e859-02db-4f4b-a31c-e9fb986e97dd@daynix.com> (raw)
In-Reply-To: <cc32b55b-adc9-440d-814e-5a124a9ec8af@linux.alibaba.com>
On 2023/10/18 15:50, LIU Zhiwei wrote:
>
> On 2023/10/18 2:53, Akihiko Odaki wrote:
>> misa_mxl_max is common for all instances of a RISC-V CPU class so they
>> are better put into class.
>>
>> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
>> ---
>> target/riscv/cpu-qom.h | 1 +
>> target/riscv/cpu.h | 3 +-
>> hw/riscv/boot.c | 2 +-
>> target/riscv/cpu.c | 118 +++++++++++++++++++------------------
>> target/riscv/gdbstub.c | 12 ++--
>> target/riscv/kvm/kvm-cpu.c | 10 ++--
>> target/riscv/machine.c | 7 +--
>> target/riscv/tcg/tcg-cpu.c | 12 ++--
>> target/riscv/translate.c | 3 +-
>> 9 files changed, 88 insertions(+), 80 deletions(-)
>>
>> diff --git a/target/riscv/cpu-qom.h b/target/riscv/cpu-qom.h
>> index f3fbe37a2c..33b6d52c90 100644
>> --- a/target/riscv/cpu-qom.h
>> +++ b/target/riscv/cpu-qom.h
>> @@ -68,5 +68,6 @@ struct RISCVCPUClass {
>> /*< public >*/
>> DeviceRealize parent_realize;
>> ResettablePhases parent_phases;
>> + uint32_t misa_mxl_max; /* max mxl for this cpu */
>> };
>> #endif /* RISCV_CPU_QOM_H */
>> diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
>> index f8ffa5ee38..ef10efd1e7 100644
>> --- a/target/riscv/cpu.h
>> +++ b/target/riscv/cpu.h
>> @@ -159,7 +159,6 @@ struct CPUArchState {
>> /* RISCVMXL, but uint32_t for vmstate migration */
>> uint32_t misa_mxl; /* current mxl */
>> - uint32_t misa_mxl_max; /* max mxl for this cpu */
>> uint32_t misa_ext; /* current extensions */
>> uint32_t misa_ext_mask; /* max ext for this cpu */
>> uint32_t xl; /* current xlen */
>> @@ -711,7 +710,7 @@ enum riscv_pmu_event_idx {
>> /* used by tcg/tcg-cpu.c*/
>> void isa_ext_update_enabled(RISCVCPU *cpu, uint32_t ext_offset, bool
>> en);
>> bool isa_ext_is_enabled(RISCVCPU *cpu, uint32_t ext_offset);
>> -void riscv_cpu_set_misa(CPURISCVState *env, RISCVMXL mxl, uint32_t ext);
>> +void riscv_cpu_set_misa_ext(CPURISCVState *env, uint32_t ext);
>> typedef struct RISCVCPUMultiExtConfig {
>> const char *name;
>> diff --git a/hw/riscv/boot.c b/hw/riscv/boot.c
>> index 52bf8e67de..b7cf08f479 100644
>> --- a/hw/riscv/boot.c
>> +++ b/hw/riscv/boot.c
>> @@ -36,7 +36,7 @@
>> bool riscv_is_32bit(RISCVHartArrayState *harts)
>> {
>> - return harts->harts[0].env.misa_mxl_max == MXL_RV32;
>> + return RISCV_CPU_GET_CLASS(&harts->harts[0])->misa_mxl_max ==
>> MXL_RV32;
>
> Hi Akihiko,
>
> Can we use the cached CPUClass in CPUState? Like
>
> (RISCVCPUClass *)((CPUState *)(&harts->harts[0])->cc)
If just casting, you can do:
(RISCVCPUClass *)((Object *)&harts->harts[0])->class
But it removes type safety checks RISCV_CPU_GET_CLASS() provides. This
is not a hot path so it's better to keep the checks.
next prev parent reply other threads:[~2023-10-18 12:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 18:53 [PATCH v4 0/5] gdbstub and TCG plugin improvements Akihiko Odaki
2023-10-17 18:53 ` [PATCH v4 1/5] gdbstub: Check if gdb_regs is NULL Akihiko Odaki
2023-10-17 18:53 ` [PATCH v4 2/5] target/riscv: Remove misa_mxl validation Akihiko Odaki
2023-10-18 5:54 ` LIU Zhiwei
2023-10-18 12:51 ` Daniel Henrique Barboza
2023-10-17 18:53 ` [PATCH v4 3/5] target/riscv: Move misa_mxl_max to class Akihiko Odaki
2023-10-18 6:50 ` LIU Zhiwei
2023-10-18 12:23 ` Akihiko Odaki [this message]
2023-10-18 13:01 ` Daniel Henrique Barboza
2023-10-18 13:31 ` Akihiko Odaki
2023-10-18 14:23 ` Daniel Henrique Barboza
2023-10-19 10:17 ` Akihiko Odaki
2023-10-17 18:53 ` [PATCH v4 4/5] target/riscv: Validate misa_mxl_max only once Akihiko Odaki
2023-10-17 18:54 ` [PATCH v4 5/5] 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=06d5e859-02db-4f4b-a31c-e9fb986e97dd@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=farosas@suse.de \
--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=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).