All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anton Johansson via qemu development <qemu-devel@nongnu.org>
To: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Cc: luoyonggang@gmail.com, qemu-devel@nongnu.org,
	qemu-riscv@nongnu.org,  daniel.barboza@oss.qualcomm.com,
	philmd@oss.qualcomm.com, palmer@dabbelt.com,
	 alistair.francis@wdc.com
Subject: Re: [PATCH 07/18] target/riscv: Runtime register MAX and BARE CPUs
Date: Fri, 2 Oct 2026 17:42:34 +0200	[thread overview]
Message-ID: <ar_AzEWpF9XDGNdg@hive.localdomain> (raw)
In-Reply-To: <f8f27bc3-83ce-4ccf-ae38-a43188b2ebc5@oss.qualcomm.com>

On 02/10/26, Pierrick Bouvier wrote:
> On 10/1/2026 9:28 AM, Yonggang Luo wrote:
> > On Thu, Oct 1, 2026 at 11:55 PM Anton Johansson via qemu development
> > <qemu-devel@nongnu.org> wrote:
> >>
> >> Moves initialization of satp and mxl fields to a class initialization
> >> function that checks target_riscv64().
> >>
> >> Note: I'm aware the current iteration of this patch is rather hacky, I
> >> don't like the introduction of runtime_misa_mxl_max, but I'm keeping
> >> this in to get the series out there and collect feedback.
> >>
> >> Signed-off-by: Anton Johansson <anjo@rev.ng>
> >> ---
> >>  target/riscv/cpu.h |  1 +
> >>  target/riscv/cpu.c | 90 +++++++++++++++++++++++++++++++++++-------------------
> >>  2 files changed, 59 insertions(+), 32 deletions(-)
> >>
> > 
> > This patch is how I handle these, just for reference, not a review.
> 
> Yonggang approach looks cleaner, I would favor this one.

I'm personally not a huge fan, it still feels rather hacky. Why add a
completely new RISCVCPUDef::target_init just to make sure fields are
initialized before riscv_cpu_validate_misa_mxl()? Wouldn't moving the
check to a later point, maybe .instance_init, be better? Then for
riscv_cpu_init() we get

  riscv_cpu_validate_misa_mxl(mcc);
  env->misa_mxl = mcc->def->misa_mxl_max;

misa_mxl_max would be verified only during instance rather than
class initialization, which seems like a decent tradeoff for a simpler
solution.

-- 
Anton Johansson
rev.ng Labs Srl.


WARNING: multiple messages have this Message-ID (diff)
From: Anton Johansson via <qemu-riscv@nongnu.org>
To: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Cc: luoyonggang@gmail.com, qemu-devel@nongnu.org,
	qemu-riscv@nongnu.org,  daniel.barboza@oss.qualcomm.com,
	philmd@oss.qualcomm.com, palmer@dabbelt.com,
	 alistair.francis@wdc.com
Subject: Re: [PATCH 07/18] target/riscv: Runtime register MAX and BARE CPUs
Date: Fri, 2 Oct 2026 17:42:34 +0200	[thread overview]
Message-ID: <ar_AzEWpF9XDGNdg@hive.localdomain> (raw)
In-Reply-To: <f8f27bc3-83ce-4ccf-ae38-a43188b2ebc5@oss.qualcomm.com>

On 02/10/26, Pierrick Bouvier wrote:
> On 10/1/2026 9:28 AM, Yonggang Luo wrote:
> > On Thu, Oct 1, 2026 at 11:55 PM Anton Johansson via qemu development
> > <qemu-devel@nongnu.org> wrote:
> >>
> >> Moves initialization of satp and mxl fields to a class initialization
> >> function that checks target_riscv64().
> >>
> >> Note: I'm aware the current iteration of this patch is rather hacky, I
> >> don't like the introduction of runtime_misa_mxl_max, but I'm keeping
> >> this in to get the series out there and collect feedback.
> >>
> >> Signed-off-by: Anton Johansson <anjo@rev.ng>
> >> ---
> >>  target/riscv/cpu.h |  1 +
> >>  target/riscv/cpu.c | 90 +++++++++++++++++++++++++++++++++++-------------------
> >>  2 files changed, 59 insertions(+), 32 deletions(-)
> >>
> > 
> > This patch is how I handle these, just for reference, not a review.
> 
> Yonggang approach looks cleaner, I would favor this one.

I'm personally not a huge fan, it still feels rather hacky. Why add a
completely new RISCVCPUDef::target_init just to make sure fields are
initialized before riscv_cpu_validate_misa_mxl()? Wouldn't moving the
check to a later point, maybe .instance_init, be better? Then for
riscv_cpu_init() we get

  riscv_cpu_validate_misa_mxl(mcc);
  env->misa_mxl = mcc->def->misa_mxl_max;

misa_mxl_max would be verified only during instance rather than
class initialization, which seems like a decent tradeoff for a simpler
solution.

-- 
Anton Johansson
rev.ng Labs Srl.


  reply	other threads:[~2026-10-02 15:37 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 15:59 [PATCH 00/18] single-binary: target/riscv, compile subset of compilation units once Anton Johansson via qemu development
2026-10-01 15:59 ` Anton Johansson via
2026-10-01 15:59 ` [PATCH 01/18] target/riscv: Make internals.h target agnostic Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 21:25   ` Pierrick Bouvier
2026-10-01 21:33     ` Pierrick Bouvier
2026-10-06 23:14     ` Anton Johansson via qemu development
2026-10-06 23:14       ` Anton Johansson via
2026-10-07  0:26       ` Pierrick Bouvier
2026-10-02  5:56   ` Philippe Mathieu-Daudé
2026-10-02  6:06   ` Yonggang Luo
2026-10-01 15:59 ` [PATCH 02/18] target/riscv: meson, add user and common system source sets Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 21:26   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 03/18] target/riscv: Move pmu CSR read to csr.h Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 21:26   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 04/18] target/riscv: Make debug.c target agnostic Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 21:32   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 05/18] target/riscv: Widen CSR ops to 64-bit and compile once for system-mode Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:04   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 06/18] target/riscv: Runtime CPU registration Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:10   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 07/18] target/riscv: Runtime register MAX and BARE CPUs Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 16:28   ` Yonggang Luo
2026-10-01 22:19     ` Pierrick Bouvier
2026-10-02 15:42       ` Anton Johansson via qemu development [this message]
2026-10-02 15:42         ` Anton Johansson via
2026-10-02 15:46         ` Yonggang Luo
2026-10-02 15:49         ` Yonggang Luo
2026-10-02 18:07         ` Yonggang Luo
2026-10-06 23:15           ` Anton Johansson via qemu development
2026-10-06 23:15             ` Anton Johansson via
2026-10-07  7:25             ` Yonggang Luo
2026-10-01 15:59 ` [PATCH 08/18] target/riscv: cpu.c unconditionally check larger MXL Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:14   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 09/18] target/riscv: Stub KVM functions for machines.c/cpu.c Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:11   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 10/18] target/riscv: Compile cpu.c once for system-mode Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:11   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 11/18] target/riscv: Compile cpu_helper.c " Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:11   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 12/18] target/riscv: Compile tcg-cpu.c " Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:12   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 13/18] target/riscv: Compile riscv-qmp-cmds.c once Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:12   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 14/18] target/riscv: Compile pmp.c once Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:12   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 15/18] target/riscv: Compile arch_dump.c once Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:12   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 16/18] target/riscv: Compile machine.c once Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:13   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 17/18] target/riscv: Compile time_helper.c once Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:13   ` Pierrick Bouvier
2026-10-01 15:59 ` [PATCH 18/18] target/riscv: Compile monitor.c once Anton Johansson via qemu development
2026-10-01 15:59   ` Anton Johansson via
2026-10-01 22:14   ` Pierrick Bouvier
2026-10-02  6:07   ` Philippe Mathieu-Daudé
2026-10-01 22:03 ` [PATCH 00/18] single-binary: target/riscv, compile subset of compilation units once Pierrick Bouvier

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=ar_AzEWpF9XDGNdg@hive.localdomain \
    --to=qemu-devel@nongnu.org \
    --cc=alistair.francis@wdc.com \
    --cc=anjo@rev.ng \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=luoyonggang@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=philmd@oss.qualcomm.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-riscv@nongnu.org \
    /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.