From: Alistair Francis <alistair23@gmail.com>
To: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
alistair.francis@wdc.com, bmeng@tinylab.org,
liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com,
palmer@rivosinc.com, philmd@linaro.org, ajones@ventanamicro.com
Subject: Re: [PATCH v3 02/19] target/riscv: move riscv_cpu_realize_tcg() to TCG::cpu_realizefn()
Date: Mon, 25 Sep 2023 20:33:07 +1000 [thread overview]
Message-ID: <CAKmqyKMMJ5ByW1JPJ==f=sj56zZY+GXX2gj+xXyS3A2xH+GUmA@mail.gmail.com> (raw)
In-Reply-To: <68e7c41d-07b9-e265-6d3c-5f7b644ed0ca@ventanamicro.com>
On Mon, Sep 25, 2023 at 7:17 PM Daniel Henrique Barboza
<dbarboza@ventanamicro.com> wrote:
>
>
>
> On 9/22/23 02:29, Alistair Francis wrote:
> > On Wed, Sep 20, 2023 at 9:24 PM Daniel Henrique Barboza
> > <dbarboza@ventanamicro.com> wrote:
> >>
> >> riscv_cpu_realize_tcg() was added to allow TCG cpus to have a different
> >> realize() path during the common riscv_cpu_realize(), making it a good
> >> choice to start moving TCG exclusive code to tcg-cpu.c.
> >>
> >> Rename it to tcg_cpu_realizefn() and assign it as a implementation of
> >> accel::cpu_realizefn(). tcg_cpu_realizefn() will then be called during
> >> riscv_cpu_realize() via cpu_exec_realizefn(). We'll use a similar
> >> approach with KVM in the near future.
> >>
> >> riscv_cpu_validate_set_extensions() is too big and with too many
> >> dependencies to be moved in this same patch. We'll do that next.
> >>
> >> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
> >> Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
> >> Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
> >> ---
> >> target/riscv/cpu.c | 128 -----------------------------------
> >> target/riscv/tcg/tcg-cpu.c | 133 +++++++++++++++++++++++++++++++++++++
> >> 2 files changed, 133 insertions(+), 128 deletions(-)
> >>
> >> diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
> >> index e72c49c881..030629294f 100644
> >> --- a/target/riscv/cpu.c
> >> +++ b/target/riscv/cpu.c
> >> @@ -23,9 +23,7 @@
> >> #include "qemu/log.h"
> >> #include "cpu.h"
> >> #include "cpu_vendorid.h"
> >> -#include "pmu.h"
> >> #include "internals.h"
> >> -#include "time_helper.h"
> >> #include "exec/exec-all.h"
> >> #include "qapi/error.h"
> >> #include "qapi/visitor.h"
> >> @@ -1064,29 +1062,6 @@ static void riscv_cpu_validate_v(CPURISCVState *env, RISCVCPUConfig *cfg,
> >> }
> >> }
> >>
> >> -static void riscv_cpu_validate_priv_spec(RISCVCPU *cpu, Error **errp)
> >> -{
> >> - CPURISCVState *env = &cpu->env;
> >> - int priv_version = -1;
> >> -
> >> - if (cpu->cfg.priv_spec) {
> >> - if (!g_strcmp0(cpu->cfg.priv_spec, "v1.12.0")) {
> >> - priv_version = PRIV_VERSION_1_12_0;
> >> - } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.11.0")) {
> >> - priv_version = PRIV_VERSION_1_11_0;
> >> - } else if (!g_strcmp0(cpu->cfg.priv_spec, "v1.10.0")) {
> >> - priv_version = PRIV_VERSION_1_10_0;
> >> - } else {
> >> - error_setg(errp,
> >> - "Unsupported privilege spec version '%s'",
> >> - cpu->cfg.priv_spec);
> >> - return;
> >> - }
> >> -
> >> - env->priv_ver = priv_version;
> >> - }
> >> -}
> >> -
> >> static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu)
> >> {
> >> CPURISCVState *env = &cpu->env;
> >> @@ -1111,33 +1086,6 @@ static void riscv_cpu_disable_priv_spec_isa_exts(RISCVCPU *cpu)
> >> }
> >> }
> >>
> >> -static void riscv_cpu_validate_misa_mxl(RISCVCPU *cpu, Error **errp)
> >> -{
> >> - RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cpu);
> >> - CPUClass *cc = CPU_CLASS(mcc);
> >> - CPURISCVState *env = &cpu->env;
> >> -
> >> - /* Validate that MISA_MXL is set properly. */
> >> - switch (env->misa_mxl_max) {
> >> -#ifdef TARGET_RISCV64
> >> - case MXL_RV64:
> >> - case MXL_RV128:
> >> - cc->gdb_core_xml_file = "riscv-64bit-cpu.xml";
> >> - break;
> >> -#endif
> >> - case MXL_RV32:
> >> - cc->gdb_core_xml_file = "riscv-32bit-cpu.xml";
> >> - break;
> >> - 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;
> >> - }
> >> -}
> >> -
> >> /*
> >> * Check consistency between chosen extensions while setting
> >> * cpu->cfg accordingly.
> >> @@ -1511,74 +1459,6 @@ static void riscv_cpu_finalize_features(RISCVCPU *cpu, Error **errp)
> >> #endif
> >> }
> >>
> >> -static void riscv_cpu_validate_misa_priv(CPURISCVState *env, Error **errp)
> >> -{
> >> - if (riscv_has_ext(env, RVH) && env->priv_ver < PRIV_VERSION_1_12_0) {
> >> - error_setg(errp, "H extension requires priv spec 1.12.0");
> >> - return;
> >> - }
> >> -}
> >> -
> >> -static void riscv_cpu_realize_tcg(DeviceState *dev, Error **errp)
> >> -{
> >> - RISCVCPU *cpu = RISCV_CPU(dev);
> >> - CPURISCVState *env = &cpu->env;
> >> - Error *local_err = NULL;
> >> -
> >> - if (object_dynamic_cast(OBJECT(dev), TYPE_RISCV_CPU_HOST)) {
> >> - error_setg(errp, "'host' CPU is not compatible with TCG acceleration");
> >> - return;
> >> - }
> >> -
> >> - riscv_cpu_validate_misa_mxl(cpu, &local_err);
> >> - if (local_err != NULL) {
> >> - error_propagate(errp, local_err);
> >> - return;
> >> - }
> >> -
> >> - riscv_cpu_validate_priv_spec(cpu, &local_err);
> >> - if (local_err != NULL) {
> >> - error_propagate(errp, local_err);
> >> - return;
> >> - }
> >> -
> >> - riscv_cpu_validate_misa_priv(env, &local_err);
> >> - if (local_err != NULL) {
> >> - error_propagate(errp, local_err);
> >> - return;
> >> - }
> >> -
> >> - if (cpu->cfg.epmp && !cpu->cfg.pmp) {
> >> - /*
> >> - * Enhanced PMP should only be available
> >> - * on harts with PMP support
> >> - */
> >> - error_setg(errp, "Invalid configuration: EPMP requires PMP support");
> >> - return;
> >> - }
> >> -
> >> - riscv_cpu_validate_set_extensions(cpu, &local_err);
> >> - if (local_err != NULL) {
> >> - error_propagate(errp, local_err);
> >> - return;
> >> - }
> >> -
> >> -#ifndef CONFIG_USER_ONLY
> >> - CPU(dev)->tcg_cflags |= CF_PCREL;
> >> -
> >> - if (cpu->cfg.ext_sstc) {
> >> - riscv_timer_init(cpu);
> >> - }
> >> -
> >> - if (cpu->cfg.pmu_num) {
> >> - if (!riscv_pmu_init(cpu, cpu->cfg.pmu_num) && cpu->cfg.ext_sscofpmf) {
> >> - cpu->pmu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
> >> - riscv_pmu_timer_cb, cpu);
> >> - }
> >> - }
> >> -#endif
> >> -}
> >> -
> >> static void riscv_cpu_realize(DeviceState *dev, Error **errp)
> >> {
> >> CPUState *cs = CPU(dev);
> >> @@ -1597,14 +1477,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
> >> return;
> >> }
> >>
> >> - if (tcg_enabled()) {
> >> - riscv_cpu_realize_tcg(dev, &local_err);
> >> - if (local_err != NULL) {
> >> - error_propagate(errp, local_err);
> >> - return;
> >> - }
> >> - }
> >> -
> >> riscv_cpu_finalize_features(cpu, &local_err);
> >> if (local_err != NULL) {
> >> error_propagate(errp, local_err);
> >> diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
> >> index 0326cead0d..f47dc2064f 100644
> >> --- a/target/riscv/tcg/tcg-cpu.c
> >> +++ b/target/riscv/tcg/tcg-cpu.c
> >> @@ -18,10 +18,142 @@
> >> */
> >
> > I do think we should keep the Copyright statements from cpu.c in this
> > new file as you are now copying across the majority of code from there
>
> I don't mind keeping the copyright statements from cpu.c here. Feel free to change it
> in tree (or let me know if you want me to re-send).
Whoops. I missed this comment. Do you mind sending a v4 then I will apply that
Alistair
next prev parent reply other threads:[~2023-09-25 10:33 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-20 11:20 [PATCH v3 00/19] riscv: split TCG/KVM accelerators from cpu.c Daniel Henrique Barboza
2023-09-20 11:20 ` [PATCH v3 01/19] target/riscv: introduce TCG AccelCPUClass Daniel Henrique Barboza
2023-09-22 5:24 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 02/19] target/riscv: move riscv_cpu_realize_tcg() to TCG::cpu_realizefn() Daniel Henrique Barboza
2023-09-22 5:29 ` Alistair Francis
2023-09-25 9:17 ` Daniel Henrique Barboza
2023-09-25 10:33 ` Alistair Francis [this message]
2023-09-20 11:20 ` [PATCH v3 03/19] target/riscv: move riscv_cpu_validate_set_extensions() to tcg-cpu.c Daniel Henrique Barboza
2023-09-22 5:32 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 04/19] target/riscv: move riscv_tcg_ops " Daniel Henrique Barboza
2023-09-22 5:34 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 05/19] target/riscv/cpu.c: add .instance_post_init() Daniel Henrique Barboza
2023-09-22 5:51 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 06/19] target/riscv: move 'host' CPU declaration to kvm.c Daniel Henrique Barboza
2023-09-22 5:53 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 07/19] target/riscv/cpu.c: mark extensions arrays as 'const' Daniel Henrique Barboza
2023-09-22 5:54 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 08/19] target/riscv: move riscv_cpu_add_kvm_properties() to kvm.c Daniel Henrique Barboza
2023-09-22 5:55 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 09/19] target/riscv: make riscv_add_satp_mode_properties() public Daniel Henrique Barboza
2023-09-22 6:03 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 10/19] target/riscv: remove kvm-stub.c Daniel Henrique Barboza
2023-09-22 6:06 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 11/19] target/riscv: introduce KVM AccelCPUClass Daniel Henrique Barboza
2023-09-22 6:08 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 12/19] target/riscv: move KVM only files to kvm subdir Daniel Henrique Barboza
2023-09-25 1:26 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 13/19] target/riscv/kvm: do not use riscv_cpu_add_misa_properties() Daniel Henrique Barboza
2023-09-25 1:32 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 14/19] target/riscv/cpu.c: export set_misa() Daniel Henrique Barboza
2023-09-25 1:36 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 15/19] target/riscv/tcg: introduce tcg_cpu_instance_init() Daniel Henrique Barboza
2023-09-25 1:56 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 16/19] target/riscv/cpu.c: make misa_ext_cfgs[] 'const' Daniel Henrique Barboza
2023-09-25 1:37 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 17/19] target/riscv/tcg: move riscv_cpu_add_misa_properties() to tcg-cpu.c Daniel Henrique Barboza
2023-09-25 1:57 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 18/19] target/riscv/cpu.c: export isa_edata_arr[] Daniel Henrique Barboza
2023-09-25 2:00 ` Alistair Francis
2023-09-20 11:20 ` [PATCH v3 19/19] target/riscv/cpu: move priv spec functions to tcg-cpu.c Daniel Henrique Barboza
2023-09-22 10:55 ` Philippe Mathieu-Daudé
2023-09-25 2:00 ` Alistair Francis
2023-09-25 3:30 ` [PATCH v3 00/19] riscv: split TCG/KVM accelerators from cpu.c Alistair Francis
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='CAKmqyKMMJ5ByW1JPJ==f=sj56zZY+GXX2gj+xXyS3A2xH+GUmA@mail.gmail.com' \
--to=alistair23@gmail.com \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=bmeng@tinylab.org \
--cc=dbarboza@ventanamicro.com \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@rivosinc.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).