From nobody Mon Feb 2 07:30:41 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1769752950; cv=none; d=zohomail.com; s=zohoarc; b=OKPRHdAYTKS6BZgfBqvPFEINJnKVtaLtMHvrbUULT6QnlG7/hxekiFGntUZmKewMg9bYOIVO8QkS4/H94DZXHyIh3s9/N+o8CC3u8VYpTdqUemEnrANFsrI7nKW+bVyKcJ+cg9n4G3p8ll0A2QXfncnvYPKP6IVbj1/yq0Vqr1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769752950; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WBoXQfTlU7JT+rS+l/wPvoxh673wbQqHj0ja46BFnJs=; b=dSM3if4su7JQg48S+s815FUiyP3mgSCQWRE2ZrGdCFzBfZMEiDy2XfOjUf1SCFUjhq4c1UVyao/i1fEkXl7JTyVWSRr1EjoaJCqhzpi+CPYdtWNP1540An0VdVxVB5HoAIy+R3vyVQHJB0122Fi7GKAgcufHUuDwQpKYELu5efE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769752950131156.58575394941215; Thu, 29 Jan 2026 22:02:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlhZD-0004Mc-4Z; Fri, 30 Jan 2026 01:01:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlhZ7-0004Kr-JO for qemu-devel@nongnu.org; Fri, 30 Jan 2026 01:01:09 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vlhZ5-0000ls-Es for qemu-devel@nongnu.org; Fri, 30 Jan 2026 01:01:09 -0500 Received: by mail-pf1-x444.google.com with SMTP id d2e1a72fcca58-81ed3e6b8e3so909757b3a.2 for ; Thu, 29 Jan 2026 22:01:06 -0800 (PST) Received: from ZEVORN-PC.bbrouter ([183.195.20.181]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a88b3f6d77sm66274585ad.2.2026.01.29.22.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jan 2026 22:01:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769752866; x=1770357666; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WBoXQfTlU7JT+rS+l/wPvoxh673wbQqHj0ja46BFnJs=; b=gN7oCX322oBAJcTyLrOFzZD+PKNqidz6rFxoaqmcgfRTVh1AlI3IVfmF0xYTk4EWFU GSQKhoS2hU3gEF0pTbYsJONpgllvyNQ9m6k9HYSHW6XwMIiWh3I5E+tonIm89oVwz7vq apfQeHyBakoUm3PRLZtUKMtigrzZMJhmqK4mmhuD/0GG51LwZMelSPrmwCn4Vfl+Ma47 ZMerRz4NplDbqDYqOw3n7exmLKjdLzOCiw0t1A/XxGbiYgSoqLH76iuQJ1h69Vh8xiZD PVGeUFwzzmWeNxZRKb+eU2dMPoA/dTJuN+RahccnD+Q7GvDcjHGSdCkvW2lfqHqhKJ/q QEWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769752866; x=1770357666; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=WBoXQfTlU7JT+rS+l/wPvoxh673wbQqHj0ja46BFnJs=; b=sPo61aQcuPl66Z2loVoVk2DgqqtwuMSQhGd1ba/ArlPogS9XqC02EPwOUvzKR1xR5A EQxA6l3I4FxfZZbSa6vQmIyK6eE2Yh+wYgvQF835a6q0UPkp9zl5CewoMn8XbFRliyDB UvkWtdxEnIU60JEwMYq/U6Lb6yROxiHi75iZDkHqNg63Vb0UCt1oImuz/mvWdTPz6nnU M9BPVmrpuN7P1yHfzdxFqNk62meAwYRRBGq+Btld5hG6AzlRvDplsNoNO8xEt9RhJYik Xxzjz3xrH4N43d+8rpg+M+MqAWy9hzz3Za0mp+q/tKQkMpLSLzER4wANX4DlrSx0J9D0 k8/w== X-Gm-Message-State: AOJu0YwvO4oOTKppj9e1TaCp0vrc1yQmHWbKZLDxYrqBRybrQcIG+CzB wHaqfhibQcMd9RbtNSO3T5S7ipP16XCavqieZcC4CXEpiWeCathk0NxzajeG3/EG+AyFEg== X-Gm-Gg: AZuq6aJUQUCfUP6l+Y2Ga4IIHuPl7WMT0vx4ve1Km+59P99K0bYzAZWiZ6sCuCbRIjn iF8vEmcWDiLRSwpGwTzFvEIAbGKFESYDuQKSbRL8lkgrLfRxjOoQ/XdMhAEkIhFbF3NltPNPUng MrAmEZtv636GEnuosEBetpJkLaPcgPAVFgVvxjRYPq9FdAtRkNU9EXQy8ToowegJKs+5GA4GQUI GGUKYRqU7FLyVWr7cAYfZ+C6ZzF2bja2JXMeVMi91b1l5n+RXtOsGU3Gd9mAGqDer+J7pjAQ59X TwfUjlU9/r58bUkYzOiJFB98nM44pz4YKpjYcE6llX+Kj+OYfonx5i1/feT40J0NsD6r5eW5MZo ekBLHmDhZDb5MBuzksP1UD8j0Zw1FNsi/avQJMzhmLV5o5OSsHo4nRSJIpda/S+WF/j9nvMduil mXpUvf7+Vnuh9/E9im1V+lhtXjfSme6BGOIvC5lePWKkbsPTU9+igsVt2tkvE= X-Received: by 2002:a05:6300:404c:b0:38d:e87c:48c2 with SMTP id adf61e73a8af0-392e015baabmr1489347637.58.1769752865619; Thu, 29 Jan 2026 22:01:05 -0800 (PST) From: Chao Liu To: Alistair Francis , Daniel Henrique Barboza , Palmer Dabbelt , Weiwei Li , Liu Zhiwei Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org, hust-os-kernel-patches@googlegroups.com, wangjingwei@iscas.ac.cn, devel@lists.libvirt.org, Daniel Henrique Barboza Subject: [RFC PATCH v4 1/7] target/riscv: deprecate 'debug' CPU property Date: Fri, 30 Jan 2026 14:00:00 +0800 Message-ID: <30b51bbe85516664482caec9748baef92c99b4b6.1769751489.git.chao.liu.zevorn@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::444; envelope-from=chao.liu.zevorn@gmail.com; helo=mail-pf1-x444.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1769752951432158500 Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza Starting on commit f31ba686a9 ("target/riscv/cpu.c: add 'sdtrig' in riscv,isa') the 'debug' flag has been used as an alias for 'sdtrig'. We're going to add more debug trigger extensions, e.g. 'sdext' [1]. And all of a sudden the existence of this flag is now weird. Do we keep it as a 'sdtrig' only or do we add 'sdext'? The solution proposed here is to deprecate it. The flag was introduced a long time ago as a way to encapsulate support for all debug related CSRs. Today we have specific debug trigger extensions and there's no more use for a generic 'debug' flag. Users should be encouraged to enable/disable extensions directly instead of using "made-up" flags that exists only in a QEMU context. The following changes are made: - 'ext_sdtrig' flag was added in cpu->cfg. 'debug' flag was removed from cpu->cfg; - All occurrences of cpu->cfg.debug were replaced to 'ext_sdtrig'; - Two explicit getters and setters for the 'debug' property were added. The property will simply get/set ext_sdtrig; - vmstate_debug was renamed to vmstate_sdtrig. We're aware that this will impact migration between QEMU 10.2 to newer versions, but we're still in a point where the migration break cost isn't big enough to justify adding migration compatibility scaffolding. Finally, deprecated.rst was updated to deprecate 'debug' and encourage users to use 'ext_sdtrig' instead. [1] https://lore.kernel.org/qemu-devel/cover.1768622881.git.chao.liu.zevorn= @gmail.com/ Signed-off-by: Daniel Henrique Barboza --- docs/about/deprecated.rst | 7 +++++ target/riscv/cpu.c | 51 ++++++++++++++++++++++++++++--- target/riscv/cpu_cfg_fields.h.inc | 2 +- target/riscv/csr.c | 2 +- target/riscv/machine.c | 24 +++++++-------- target/riscv/tcg/tcg-cpu.c | 2 +- 6 files changed, 69 insertions(+), 19 deletions(-) diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst index 7abb3dab59..44a6e53044 100644 --- a/docs/about/deprecated.rst +++ b/docs/about/deprecated.rst @@ -507,6 +507,13 @@ It was implemented as a no-op instruction in TCG up to= QEMU 9.0, but only with ``-cpu max`` (which does not guarantee migration compatibility across versions). =20 +``debug=3Dtrue|false`` on RISC-V CPUs (since 11.0) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This option, since QEMU 10.1, has been a simple alias to the ``sdtrig`` +extension. Users are advised to enable/disable ``sdtrig`` directly instead +of using ``debug``. + Backwards compatibility ----------------------- =20 diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 01cb62bde4..9fa4e09f17 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -210,7 +210,7 @@ const RISCVIsaExtData isa_edata_arr[] =3D { ISA_EXT_DATA_ENTRY(zvkt, PRIV_VERSION_1_12_0, ext_zvkt), ISA_EXT_DATA_ENTRY(zhinx, PRIV_VERSION_1_12_0, ext_zhinx), ISA_EXT_DATA_ENTRY(zhinxmin, PRIV_VERSION_1_12_0, ext_zhinxmin), - ISA_EXT_DATA_ENTRY(sdtrig, PRIV_VERSION_1_12_0, debug), + ISA_EXT_DATA_ENTRY(sdtrig, PRIV_VERSION_1_12_0, ext_sdtrig), ISA_EXT_DATA_ENTRY(shcounterenw, PRIV_VERSION_1_12_0, has_priv_1_12), ISA_EXT_DATA_ENTRY(sha, PRIV_VERSION_1_12_0, ext_sha), ISA_EXT_DATA_ENTRY(shgatpa, PRIV_VERSION_1_12_0, has_priv_1_12), @@ -782,7 +782,7 @@ static void riscv_cpu_reset_hold(Object *obj, ResetType= type) env->vill =3D true; =20 #ifndef CONFIG_USER_ONLY - if (cpu->cfg.debug) { + if (cpu->cfg.ext_sdtrig) { riscv_trigger_reset_hold(env); } =20 @@ -945,7 +945,7 @@ static void riscv_cpu_realize(DeviceState *dev, Error *= *errp) riscv_cpu_register_gdb_regs_for_features(cs); =20 #ifndef CONFIG_USER_ONLY - if (cpu->cfg.debug) { + if (cpu->cfg.ext_sdtrig) { riscv_trigger_realize(&cpu->env); } #endif @@ -1124,6 +1124,14 @@ static void riscv_cpu_init(Object *obj) cpu->env.vext_ver =3D VEXT_VERSION_1_00_0; cpu->cfg.max_satp_mode =3D -1; =20 + /* + * 'debug' started being deprecated in 11.0, been just a proxy + * to set ext_sdtrig ever since. It has been enabled by default + * for a long time though, so we're stuck with setting set 'strig' + * by default too. At least for now ... + */ + cpu->cfg.ext_sdtrig =3D true; + if (mcc->def->profile) { mcc->def->profile->enabled =3D true; } @@ -1238,6 +1246,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = =3D { MULTI_EXT_CFG_BOOL("smcdeleg", ext_smcdeleg, false), MULTI_EXT_CFG_BOOL("sscsrind", ext_sscsrind, false), MULTI_EXT_CFG_BOOL("ssccfg", ext_ssccfg, false), + MULTI_EXT_CFG_BOOL("sdtrig", ext_sdtrig, true), MULTI_EXT_CFG_BOOL("smctr", ext_smctr, false), MULTI_EXT_CFG_BOOL("ssctr", ext_ssctr, false), MULTI_EXT_CFG_BOOL("zifencei", ext_zifencei, true), @@ -2649,8 +2658,42 @@ RISCVCPUImpliedExtsRule *riscv_multi_ext_implied_rul= es[] =3D { NULL }; =20 +/* + * DEPRECATED_11.0: just a proxy for ext_sdtrig. + */ +static void prop_debug_get(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + bool value =3D RISCV_CPU(obj)->cfg.ext_sdtrig; + + visit_type_bool(v, name, &value, errp); +} + +/* + * DEPRECATED_11.0: just a proxy for ext_sdtrig. + */ +static void prop_debug_set(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + RISCVCPU *cpu =3D RISCV_CPU(obj); + bool value; + + visit_type_bool(v, name, &value, errp); + cpu->cfg.ext_sdtrig =3D value; +} + +/* + * DEPRECATED_11.0: just a proxy for ext_sdtrig. + */ +static const PropertyInfo prop_debug =3D { + .type =3D "bool", + .description =3D "DEPRECATED: use 'sdtrig' instead.", + .get =3D prop_debug_get, + .set =3D prop_debug_set, +}; + static const Property riscv_cpu_properties[] =3D { - DEFINE_PROP_BOOL("debug", RISCVCPU, cfg.debug, true), + {.name =3D "debug", .info =3D &prop_debug}, =20 {.name =3D "pmu-mask", .info =3D &prop_pmu_mask}, {.name =3D "pmu-num", .info =3D &prop_pmu_num}, /* Deprecated */ diff --git a/target/riscv/cpu_cfg_fields.h.inc b/target/riscv/cpu_cfg_field= s.h.inc index 3696f02ee0..1e9162281f 100644 --- a/target/riscv/cpu_cfg_fields.h.inc +++ b/target/riscv/cpu_cfg_fields.h.inc @@ -46,6 +46,7 @@ BOOL_FIELD(ext_zilsd) BOOL_FIELD(ext_zimop) BOOL_FIELD(ext_zcmop) BOOL_FIELD(ext_ztso) +BOOL_FIELD(ext_sdtrig) BOOL_FIELD(ext_smstateen) BOOL_FIELD(ext_sstc) BOOL_FIELD(ext_smcdeleg) @@ -157,7 +158,6 @@ BOOL_FIELD(ext_xmipslsp) =20 BOOL_FIELD(mmu) BOOL_FIELD(pmp) -BOOL_FIELD(debug) BOOL_FIELD(misa_w) =20 BOOL_FIELD(short_isa_string) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 05c7ec8352..870fad87ac 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -777,7 +777,7 @@ static RISCVException have_mseccfg(CPURISCVState *env, = int csrno) =20 static RISCVException debug(CPURISCVState *env, int csrno) { - if (riscv_cpu_cfg(env)->debug) { + if (riscv_cpu_cfg(env)->ext_sdtrig) { return RISCV_EXCP_NONE; } =20 diff --git a/target/riscv/machine.c b/target/riscv/machine.c index 09c032a879..62c51c8033 100644 --- a/target/riscv/machine.c +++ b/target/riscv/machine.c @@ -218,14 +218,14 @@ static const VMStateDescription vmstate_kvmtimer =3D { }; #endif =20 -static bool debug_needed(void *opaque) +static bool sdtrig_needed(void *opaque) { RISCVCPU *cpu =3D opaque; =20 - return cpu->cfg.debug; + return cpu->cfg.ext_sdtrig; } =20 -static int debug_post_load(void *opaque, int version_id) +static int sdtrig_post_load(void *opaque, int version_id) { RISCVCPU *cpu =3D opaque; CPURISCVState *env =3D &cpu->env; @@ -237,12 +237,12 @@ static int debug_post_load(void *opaque, int version_= id) return 0; } =20 -static const VMStateDescription vmstate_debug =3D { - .name =3D "cpu/debug", - .version_id =3D 2, - .minimum_version_id =3D 2, - .needed =3D debug_needed, - .post_load =3D debug_post_load, +static const VMStateDescription vmstate_sdtrig =3D { + .name =3D "cpu/sdtrig", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D sdtrig_needed, + .post_load =3D sdtrig_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINTTL(env.trigger_cur, RISCVCPU), VMSTATE_UINTTL_ARRAY(env.tdata1, RISCVCPU, RV_MAX_TRIGGERS), @@ -425,8 +425,8 @@ static const VMStateDescription vmstate_sstc =3D { =20 const VMStateDescription vmstate_riscv_cpu =3D { .name =3D "cpu", - .version_id =3D 11, - .minimum_version_id =3D 11, + .version_id =3D 12, + .minimum_version_id =3D 12, .post_load =3D riscv_cpu_post_load, .fields =3D (const VMStateField[]) { VMSTATE_UINTTL_ARRAY(env.gpr, RISCVCPU, 32), @@ -492,13 +492,13 @@ const VMStateDescription vmstate_riscv_cpu =3D { &vmstate_kvmtimer, #endif &vmstate_envcfg, - &vmstate_debug, &vmstate_smstateen, &vmstate_jvt, &vmstate_elp, &vmstate_ssp, &vmstate_ctr, &vmstate_sstc, + &vmstate_sdtrig, NULL } }; diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 378b298886..d9fbb5bf58 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -180,7 +180,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *c= s) ? EXT_STATUS_DIRTY : EXT_STATUS_DISABLED; } =20 - if (cpu->cfg.debug && !icount_enabled()) { + if (cpu->cfg.ext_sdtrig && !icount_enabled()) { flags =3D FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enab= led); } #endif --=20 2.52.0