All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: "Björn Töpel" <bjorn@kernel.org>,
	"Alexandre Ghiti" <alexghiti@rivosinc.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH RFC] target: riscv: Fix satp mode initialization based on profile
Date: Tue, 20 May 2025 12:53:48 +0200	[thread overview]
Message-ID: <51356014-b645-4e86-b338-0d097bf80260@redhat.com> (raw)
In-Reply-To: <87y0usiz22.fsf@all.your.base.are.belong.to.us>

On 5/19/25 14:07, Björn Töpel wrote:
> When realizing the cpus, the first cpu calls riscv_cpu_add_profiles()
> all profiles are disabled, whereas for the other cpu calls to
> riscv_cpu_add_profiles() have some profiles enabled. Having some
> profiles enabled, will issue a call to cpu_set_profile() that will
> enforce the satp code that Alex removes in this patch.
Ah so the problem is that *parent* profiles are not enabled until
riscv_cpu_add_profiles().

With my patches to introduce RISCVCPUDef, it's a pretty easy fix:

diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index 629ac37501e..04b929af41c 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -1083,6 +1083,19 @@ static bool riscv_cpu_is_dynamic(Object *cpu_obj)
      return object_dynamic_cast(cpu_obj, TYPE_RISCV_DYNAMIC_CPU) != NULL;
  }
  
+static void riscv_cpu_enable_profile(RISCVCPU *cpu,
+                                     RISCVCPUProfile *profile)
+{
+    profile->enabled = true;
+
+    if (profile->u_parent) {
+        riscv_cpu_enable_profile(cpu, profile->u_parent);
+    }
+    if (profile->s_parent) {
+        riscv_cpu_enable_profile(cpu, profile->s_parent);
+    }
+}
+
  static void riscv_cpu_init(Object *obj)
  {
      RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(obj);
@@ -1121,7 +1134,7 @@ static void riscv_cpu_init(Object *obj)
      cpu->cfg.max_satp_mode = -1;
  
      if (mcc->def->profile) {
-        mcc->def->profile->enabled = true;
+        riscv_cpu_enable_profile(cpu, mcc->def->profile);
      }
  
      env->misa_ext_mask = env->misa_ext = mcc->def->misa_ext;

Since they're all reviewed and Alistair has flushed his queue, I'll
send them in my next pull request.

On top of them, probably profiles should also be converted to use
RISCVCPUCfg and riscv_cpu_enable_profile() can then enable all the
flags with riscv_cpu_cfg_merge().

In general a lot (if not all) of the profile code should be moved out
of tcg-cpu.c and into riscv_cpu_class_base_init().  I didn't do that
because I didn't want to balloon an already-large series, but it's a
pretty obvious extension of the RISCVCPUDef concept to include all
profile features.

Paolo



  parent reply	other threads:[~2025-05-20 10:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-16 12:23 [PATCH RFC] target: riscv: Fix satp mode initialization based on profile Alexandre Ghiti
2025-05-19 12:07 ` Björn Töpel
2025-05-19 13:29   ` Daniel Henrique Barboza
2025-05-20 10:53   ` Paolo Bonzini [this message]
2025-05-20 11:33     ` Daniel Henrique Barboza
2025-05-20 14:40       ` Paolo Bonzini
2025-05-19 12:48 ` Daniel Henrique Barboza
2025-05-19 16:35   ` Andrew Jones
2025-05-19 17:15     ` Daniel Henrique Barboza
2025-05-20  7:50       ` Andrew Jones
2025-05-20 10:50         ` Daniel Henrique Barboza
2025-05-20 11:05           ` Andrew Jones

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=51356014-b645-4e86-b338-0d097bf80260@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alexghiti@rivosinc.com \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=bjorn@kernel.org \
    --cc=dbarboza@ventanamicro.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.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.