target/riscv: deprecate 'debug' CPU property
PATCH 1/1 target/riscv: deprecate 'debug' CPU property
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/[email protected]/
--- 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(-)
docs/about/deprecated.rst +7 -0
@@ -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). +``debug=true|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 -----------------------
target/riscv/cpu.c +47 -4
88 lines not on this page · raw message
target/riscv/cpu_cfg_fields.h.inc +1 -1
@@ -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)
@@ -156,7 +157,6 @@ BOOL_FIELD(ext_xmipslsp) BOOL_FIELD(mmu) BOOL_FIELD(pmp) -BOOL_FIELD(debug) BOOL_FIELD(misa_w) BOOL_FIELD(short_isa_string)
target/riscv/csr.c +1 -1
@@ -777,7 +777,7 @@ static RISCVException have_mseccfg(CPURISCVState *env, int csrno)static RISCVException debug (CPURISCVState *env,int csrno) { -if (riscv_cpu_cfg (env)->debug) { +if (riscv_cpu_cfg (env)->ext_sdtrig) {return RISCV_EXCP_NONE ; }
target/riscv/machine.c +12 -12
@@ -218,14 +218,14 @@ static const VMStateDescription vmstate_kvmtimer = { };#endif -static bool debug_needed (void *opaque) +static bool sdtrig_needed (void *opaque) {RISCVCPU *cpu = opaque; -return cpu->cfg.debug; +return cpu->cfg.ext_sdtrig; } -static int debug_post_load (void *opaque,int version_id) +static int sdtrig_post_load (void *opaque,int version_id) {RISCVCPU *cpu = opaque;CPURISCVState *env = &cpu->env;
@@ -237,12 +237,12 @@ static int debug_post_load(void *opaque, int version_id)return 0 ; } -static const VMStateDescription vmstate_debug = { - .name ="cpu/debug" , - .version_id =2 , - .minimum_version_id =2 , - .needed = debug_needed, - .post_load = debug_post_load, +static const VMStateDescription vmstate_sdtrig = { + .name ="cpu/sdtrig" , + .version_id =1 , + .minimum_version_id =1 , + .needed = sdtrig_needed, + .post_load = sdtrig_post_load, .fields = (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 = {const VMStateDescription vmstate_riscv_cpu = { .name ="cpu" , - .version_id =11 , - .minimum_version_id =11 , + .version_id =12 , + .minimum_version_id =12 , .post_load = riscv_cpu_post_load, .fields = (const VMStateField []) {VMSTATE_UINTTL_ARRAY (env.gpr,RISCVCPU ,32 ),
@@ -492,13 +492,13 @@ const VMStateDescription vmstate_riscv_cpu = { &vmstate_kvmtimer, #endif &vmstate_envcfg, - &vmstate_debug, &vmstate_smstateen, &vmstate_jvt, &vmstate_elp, &vmstate_ssp, &vmstate_ctr, &vmstate_sstc, + &vmstate_sdtrig,NULL } };
target/riscv/tcg/tcg-cpu.c +1 -1
@@ -177,7 +177,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs) ? EXT_STATUS_DIRTY : EXT_STATUS_DISABLED; } -if (cpu->cfg.debug && !icount_enabled ()) { +if (cpu->cfg.ext_sdtrig && !icount_enabled ()) { flags =FIELD_DP32 (flags,TB_FLAGS ,ITRIGGER , env->itrigger_enabled); }#endif
Signature · 1 line
2.43.0