Export debug triggers as an extension
cover Export debug triggers as an extension
All the CPUs may or may not implement the debug trigger (sdtrig) extension. The presence of it should be dynamically detectable. This patch exports the debug triggers as an extension which can be turned on or off by sdtrig=<true/false> option. It is turned on by default.
"sdtrig" is concatenated to ISA string when it is enabled. Like so:
rv64imafdch_zicbom_*_sdtrig_*_sstc_svadu
Himanshu Chauhan (2):
target/riscv: Export sdtrig as an extension and ISA string target/riscv: Raise an exception when sdtrig is turned off
target/riscv/cpu.c | 2 ++ target/riscv/cpu_cfg.h | 1 + target/riscv/csr.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+)
Signature · 1 line
2.34.1
PATCH 1/2 target/riscv: Export sdtrig as an extension and ISA string
This patch makes the debug trigger (sdtrig) capability as an extension and exports it as an ISA string. The sdtrig extension may or may not be implemented in a system. The
-cpu rv64,sdtrig=<true/false>
option can be used to dynamicaly turn sdtrig extension on or off.
--- target/riscv/cpu.c | 2 ++ target/riscv/cpu_cfg.h | 1 + 2 files changed, 3 insertions(+)
target/riscv/cpu.c +2 -0
@@ -143,6 +143,7 @@ const RISCVIsaExtData isa_edata_arr[] = {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 , ext_sdtrig),ISA_EXT_DATA_ENTRY (smaia,PRIV_VERSION_1_12_0 , ext_smaia),ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , ext_smepmp), ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen),
@@ -1306,6 +1307,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zve64d" , ext_zve64d, false),MULTI_EXT_CFG_BOOL ("sstc" , ext_sstc, true), +MULTI_EXT_CFG_BOOL ("sdtrig" , ext_sdtrig, true),MULTI_EXT_CFG_BOOL ("smepmp" , ext_smepmp, false),MULTI_EXT_CFG_BOOL ("smstateen" , ext_smstateen, false), MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true),
target/riscv/cpu_cfg.h +1 -0
@@ -113,6 +113,7 @@ struct RISCVCPUConfig {bool ext_ssaia;bool ext_sscofpmf;bool ext_smepmp; +bool ext_sdtrig;bool rvv_ta_all_1s;bool rvv_ma_all_1s;
Signature · 1 line
2.34.1
Re: [PATCH 1/2] target/riscv: Export sdtrig as an extension and ISA string
Quoted 27 lines · Himanshu Chauhan
This patch makes the debug trigger (sdtrig) capability as an extension and exports it as an ISA string. The sdtrig extension may or may not be implemented in a system. The
-cpu rv64,sdtrig=<true/false>option can be used to dynamicaly turn sdtrig extension on or off.
Signed-off-by Himanshu Chauhan <[email protected]>--- target/riscv/cpu.c | 2 ++ target/riscv/cpu_cfg.h | 1 + 2 files changed, 3 insertions(+)target/riscv/cpu.c +1
-0@@ -143,6 +143,7 @@ const RISCVIsaExtData isa_edata_arr[] = {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 , ext_sdtrig),ISA_EXT_DATA_ENTRY (smaia,PRIV_VERSION_1_12_0 , ext_smaia),ISA_EXT_DATA_ENTRY (smepmp,PRIV_VERSION_1_12_0 , ext_smepmp), ISA_EXT_DATA_ENTRY(smstateen, PRIV_VERSION_1_12_0, ext_smstateen),
target/riscv/cpu.c const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = { · line 1310
Quoted 4 lines
target/riscv/cpu.c +1
-0@@ -1306,6 +1307,7 @@ const RISCVCPUMultiExtConfig riscv_cpu_extensions[] = {MULTI_EXT_CFG_BOOL ("zve64d" , ext_zve64d, false),MULTI_EXT_CFG_BOOL ("sstc" , ext_sstc, true), + MULTI_EXT_CFG_BOOL("sdtrig", ext_sdtrig, true),
This exposes the property, but doesn't wire it up. Can you swap the order of these patches?
target/riscv/cpu_cfg.h struct RISCVCPUConfig { · line 116
Quoted 12 lines
target/riscv/cpu.c +0
-0MULTI_EXT_CFG_BOOL ("smepmp" , ext_smepmp, false),MULTI_EXT_CFG_BOOL ("smstateen" , ext_smstateen, false), MULTI_EXT_CFG_BOOL("svadu", ext_svadu, true),target/riscv/cpu_cfg.h +1
-0@@ -113,6 +113,7 @@ struct RISCVCPUConfig {bool ext_ssaia;bool ext_sscofpmf;bool ext_smepmp; +bool ext_sdtrig;
and include this change in the other patch
Alistair
Quoted 7 lines
target/riscv/cpu_cfg.h +0
-1bool rvv_ta_all_1s;bool rvv_ma_all_1s; --2.34.1
PATCH 2/2 target/riscv: Raise an exception when sdtrig is turned off
In reply to Himanshu ChauhanWhen sdtrig is turned off by "sdtrig=false" option, raise and illegal instruction exception on any read/write to sdtrig CSRs.
--- target/riscv/csr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
target/riscv/csr.c +20 -0
@@ -3854,6 +3854,10 @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno,static RISCVException read_tselect (CPURISCVState *env,int csrno,target_ulong *val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } + *val =tselect_csr_read (env);return RISCV_EXCP_NONE ; }
@@ -3861,6 +3865,10 @@ static RISCVException read_tselect(CPURISCVState *env, int csrno,static RISCVException write_tselect (CPURISCVState *env,int csrno,target_ulong val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } +tselect_csr_write (env, val);return RISCV_EXCP_NONE ; }
@@ -3868,6 +3876,10 @@ static RISCVException write_tselect(CPURISCVState *env, int csrno,static RISCVException read_tdata (CPURISCVState *env,int csrno,target_ulong *val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } +/* return 0 in tdata1 to end the trigger enumeration */ if (env->trigger_cur >=RV_MAX_TRIGGERS && csrno ==CSR_TDATA1 ) { *val =0 ;
@@ -3885,6 +3897,10 @@ static RISCVException read_tdata(CPURISCVState *env, int csrno,static RISCVException write_tdata (CPURISCVState *env,int csrno,target_ulong val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } +if (!tdata_available (env, csrno -CSR_TDATA1 )) {return RISCV_EXCP_ILLEGAL_INST ; }
@@ -3896,6 +3912,10 @@ static RISCVException write_tdata(CPURISCVState *env, int csrno,static RISCVException read_tinfo (CPURISCVState *env,int csrno,target_ulong *val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } + *val =tinfo_csr_read (env);return RISCV_EXCP_NONE ; }
Signature · 1 line
2.34.1
Re: [PATCH 2/2] target/riscv: Raise an exception when sdtrig is turned off
Quoted 15 lines · Himanshu Chauhan
When sdtrig is turned off by "sdtrig=false" option, raise and illegal instruction exception on any read/write to sdtrig CSRs.
Signed-off-by Himanshu Chauhan <[email protected]>--- target/riscv/csr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)target/riscv/csr.c +0
-0
target/riscv/csr.c static RISCVException write_pmpaddr(CPURISCVState *env, int csrno, · line 3859
Quoted 6 lines
target/riscv/csr.c +3
-0@@ -3854,6 +3854,10 @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno,static RISCVException read_tselect (CPURISCVState *env,int csrno,target_ulong *val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + }
Thanks for the patch!
You should be able to add this check to the
static RISCVException debug(CPURISCVState *env, int csrno)
function instead
Alistair
Quoted 52 lines
target/riscv/csr.c +17
-1+ *val =tselect_csr_read (env);return RISCV_EXCP_NONE ; }@@ -3861,6 +3865,10 @@ static RISCVException read_tselect(CPURISCVState *env, int csrno,static RISCVException write_tselect (CPURISCVState *env,int csrno,target_ulong val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } +tselect_csr_write (env, val);return RISCV_EXCP_NONE ; }@@ -3868,6 +3876,10 @@ static RISCVException write_tselect(CPURISCVState *env, int csrno,static RISCVException read_tdata (CPURISCVState *env,int csrno,target_ulong *val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } +/* return 0 in tdata1 to end the trigger enumeration */ if (env->trigger_cur >=RV_MAX_TRIGGERS && csrno ==CSR_TDATA1 ) { *val =0 ;@@ -3885,6 +3897,10 @@ static RISCVException read_tdata(CPURISCVState *env, int csrno,static RISCVException write_tdata (CPURISCVState *env,int csrno,target_ulong val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } +if (!tdata_available (env, csrno -CSR_TDATA1 )) {return RISCV_EXCP_ILLEGAL_INST ; }@@ -3896,6 +3912,10 @@ static RISCVException write_tdata(CPURISCVState *env, int csrno,static RISCVException read_tinfo (CPURISCVState *env,int csrno,target_ulong *val) { +if (!riscv_cpu_cfg (env)->ext_sdtrig) { +return RISCV_EXCP_ILLEGAL_INST ; + } + *val =tinfo_csr_read (env);return RISCV_EXCP_NONE ; } --2.34.1
Himanshu,
We spoke offline but let's make everyone aware:
- 'sdtrig' should be marked with 'x-' and be an experimental extension since the spec isn't yet frozen;
- Alvin sent a patch to the ML adding the 'mcontext' CSR for 'sdtrig' some time ago:
"[PATCH v2] target/riscv: Implement optional CSR mcontext of debug Sdtrig extension"
It would be good to put his patch on top of this series to ease the review for everyone. The changes done in patch 2 would also be applicable to the mcontext CSR;
- last but probably the most important: the existing 'debug' flag seems to be acting as the actual 'sdtrig' extension due to how the flag is gating trigger code, e.g.:
if (cpu->cfg.debug) {
riscv_trigger_realize(&cpu->env);
}and
if (cpu->cfg.debug) {
riscv_trigger_reset_hold(env);
}If that's really the case, all the checks with cpu->cfg.debug will need to also include cpu->cfg.ext_sdtrig (one or the other). And now we'll have to make an option: do we leave the debug triggers (i.e. the 'debug' flag) as always enabled?
If it's up to me I would make 'debug' as default 'false' and deprecate it. Users will need to enable the debug triggers via x-sdtrig=true from now on. This will break existing behavior, but the way it is now we're always enabling an extension (via the debug flag) that isn't even frozen, so we're already in the wrong.
Alistair, any thoughts?
Thanks,
Daniel
Quoted 20 lines · Himanshu Chauhan
All the CPUs may or may not implement the debug trigger (sdtrig) extension. The presence of it should be dynamically detectable. This patch exports the debug triggers as an extension which can be turned on or off by sdtrig=<true/false> option. It is turned on by default.
"sdtrig" is concatenated to ISA string when it is enabled. Like so:
rv64imafdch_zicbom_*_sdtrig_*_sstc_svaduHimanshu Chauhan (2):
target/riscv: Export sdtrig as an extension and ISA string target/riscv: Raise an exception when sdtrig is turned offtarget/riscv/cpu.c | 2 ++ target/riscv/cpu_cfg.h | 1 + target/riscv/csr.c | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+)
Quoted 26 lines · Daniel Henrique Barboza
Himanshu,
We spoke offline but let's make everyone aware:
- 'sdtrig' should be marked with 'x-' and be an experimental extension since the spec isn't yet frozen;
- Alvin sent a patch to the ML adding the 'mcontext' CSR for 'sdtrig' some time ago:
"[PATCH v2] target/riscv: Implement optional CSR mcontext of debug Sdtrig extension"
It would be good to put his patch on top of this series to ease the review for everyone. The changes done in patch 2 would also be applicable to the mcontext CSR;
- last but probably the most important: the existing 'debug' flag seems to be acting as the actual 'sdtrig' extension due to how the flag is gating trigger code, e.g.:
if (cpu->cfg.debug) { riscv_trigger_realize(&cpu->env); }and
Quoted 8 lines
if (cpu->cfg.debug) { riscv_trigger_reset_hold(env); }If that's really the case, all the checks with
cpu->cfg.debugwill need to also includecpu->cfg.ext_sdtrig(one or the other). And now we'll have to make an option: do we leave the debug triggers (i.e. the 'debug' flag) as always enabled?
From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_vote
That was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
Quoted 2 lines
If it's up to me I would make 'debug' as default 'false' and deprecate it. Users will need
I don't think that's the right approach. It's a ratified extension that we are supporting and is in hardware. I think we are stuck supporting it
Quoted 3 lines
to enable the debug triggers via x-sdtrig=true from now on. This will break existing behavior, but the way it is now we're always enabling an extension (via the debug flag) that isn't even frozen, so we're already in the wrong.
Maybe the debug group can chime in and say what they expect users to do? It seems like there are conflicting specs
Alistair
Quoted 61 lines · Alistair Francis
Quoted 38 lines · Daniel Henrique Barboza
Himanshu,
We spoke offline but let's make everyone aware:
- 'sdtrig' should be marked with 'x-' and be an experimental extension since
the spec isn't yet frozen;- Alvin sent a patch to the ML adding the 'mcontext' CSR for 'sdtrig' some time
ago:"[PATCH v2] target/riscv: Implement optional CSR mcontext of debug Sdtrig extension"
It would be good to put his patch on top of this series to ease the review for everyone.
The changes done in patch 2 would also be applicable to the mcontext CSR;- last but probably the most important: the existing 'debug' flag seems to be acting as
the actual 'sdtrig' extension due to how the flag is gating trigger code, e.g.:if (
cpu->cfg.debug) {
riscv_trigger_realize(&cpu->env);
}and
if (
cpu->cfg.debug) {
riscv_trigger_reset_hold(env);
}Quoted 5 lines
If that's really the case, all the checks with
cpu->cfg.debugwill need to also includecpu->cfg.ext_sdtrig(one or the other). And now we'll have to make an option: do we leave
the debug triggers (i.e. the 'debug' flag) as always enabled?From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
If it's up to me I would make 'debug' as default 'false' and deprecate it. Users will need
I don't think that's the right approach. It's a ratified extension that we are supporting and is in hardware. I think we are stuck supporting it
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778 target/riscv: cpu: Enable native debug feature 38b4e781a4 target/riscv: machine: Add debug state description b6092544fc target/riscv: csr: Hook debug CSR read/write 1acdb3b013 target/riscv: cpu: Add a config option for native debug 95799e36c1 target/riscv: Add initial support for the Sdtrig extension
In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default on
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen spec
There is potentially a chance that some use cases will be broken but I don't think triggers are being widely use - the SBI support only just got merged:
https://github.com/riscv-software-src/opensbi/commit/97f234f15c9657c6ec69fa6ed745be8107bf6ae2
Hope this is helpful,
Rob
Quoted 102 lines · Rob Bradford
Quoted 61 lines · Alistair Francis
Quoted 38 lines · Daniel Henrique Barboza
Himanshu,
We spoke offline but let's make everyone aware:
- 'sdtrig' should be marked with 'x-' and be an experimental extension since
the spec isn't yet frozen;- Alvin sent a patch to the ML adding the 'mcontext' CSR for 'sdtrig' some time
ago:"[PATCH v2] target/riscv: Implement optional CSR mcontext of debug Sdtrig extension"
It would be good to put his patch on top of this series to ease the review for everyone.
The changes done in patch 2 would also be applicable to the mcontext CSR;- last but probably the most important: the existing 'debug' flag seems to be acting as
the actual 'sdtrig' extension due to how the flag is gating trigger code, e.g.:if (
cpu->cfg.debug) {
riscv_trigger_realize(&cpu->env);
}and
if (
cpu->cfg.debug) {
riscv_trigger_reset_hold(env);
}Quoted 5 lines
If that's really the case, all the checks with
cpu->cfg.debugwill need to also includecpu->cfg.ext_sdtrig(one or the other). And now we'll have to make an option: do we leave
the debug triggers (i.e. the 'debug' flag) as always enabled?From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
If it's up to me I would make 'debug' as default 'false' and deprecate it. Users will need
I don't think that's the right approach. It's a ratified extension that we are supporting and is in hardware. I think we are stuck supporting it
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extensionIn March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
Quoted 6 lines
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default on
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen spec
If x-sdtrig is 'false' and 'debug' is on, and then we warn if debug=true and x-sdtrig is false, we'll warn every time using the defaults.
Given what you said here:
Quoted 5 lines
There is potentially a chance that some use cases will be broken but I don't think triggers are being widely use - the SBI support only just got merged:
https://github.com/riscv-software-src/opensbi/commit/97f234f15c9657c6ec69fa6ed745be8107bf6a>
I believe we can deprecate 'debug' and simply ignore its existence. Do everything else with x-sdtrig. So if an user sets any 'debug' value we'll:
- warn that the flag is deprecated
- set x-sdtrig to whatever value the user set to 'debug'
'debug' will become just an alternate way to set x-sdtrig. The logic should just check for x-sdtrig.
Thanks,
Daniel
Quoted 4 lines
Hope this is helpful,
Rob
Quoted 116 lines · Daniel Henrique Barboza
Quoted 90 lines · Rob Bradford
Quoted 61 lines · Alistair Francis
Quoted 38 lines · Daniel Henrique Barboza
Himanshu,
We spoke offline but let's make everyone aware:
- 'sdtrig' should be marked with 'x-' and be an experimental extension since
the spec isn't yet frozen;- Alvin sent a patch to the ML adding the 'mcontext' CSR for 'sdtrig' some time
ago:"[PATCH v2] target/riscv: Implement optional CSR mcontext of debug Sdtrig extension"
It would be good to put his patch on top of this series to ease the review for everyone.
The changes done in patch 2 would also be applicable to the mcontext CSR;- last but probably the most important: the existing 'debug' flag seems to be acting as
the actual 'sdtrig' extension due to how the flag is gating trigger code, e.g.:if (cpu->cfg.debug) { riscv_trigger_realize(&cpu->env); }and
if (cpu->cfg.debug) { riscv_trigger_reset_hold(env); }Quoted 5 lines
If that's really the case, all the checks with
cpu->cfg.debugwill need to also includecpu->cfg.ext_sdtrig(one or the other). And now we'll have to make an option: do we leave
the debug triggers (i.e. the 'debug' flag) as always enabled?From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
If it's up to me I would make 'debug' as default 'false' and deprecate it. Users will need
I don't think that's the right approach. It's a ratified extension that we are supporting and is in hardware. I think we are stuck supporting it
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extension In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support isQuoted 8 lines
available.
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default on
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen specIf x-sdtrig is 'false' and 'debug' is on, and then we warn if debug=true and x-sdtrig is false, we'll warn every time using the defaults.
Given what you said here:
Quoted 4 lines
There is potentially a chance that some use cases will be broken but I don't think triggers are being widely use - the SBI support only just got merged:
https://github.com/riscv-software-src/opensbi/commit/97f234f15c9657c6ec69fa6ed745be8107bf6a>
Quoted 8 lines
I believe we can deprecate 'debug' and simply ignore its existence. Do everything else with x-sdtrig. So if an user sets any 'debug' value we'll:
- warn that the flag is deprecated
- set x-sdtrig to whatever value the user set to 'debug''debug' will become just an alternate way to set x-sdtrig. The logic should just check for x-sdtrig.
My v2 patchset which I posted a few ours back, gets rid of ‘debug’. It is replaced with x-sdtrig. Keeping them both doesn’t make sense.
Here is v2:
https://mail.gnu.org/archive/html/qemu-riscv/2024-01/msg00570.html
Regards
Himanshu
Quoted 9 lines
Thanks,
Daniel
Quoted 2 lines
Hope this is helpful,
Rob
Quoted 83 lines · Rob Bradford
Quoted 61 lines · Alistair Francis
Quoted 38 lines · Daniel Henrique Barboza
Himanshu,
We spoke offline but let's make everyone aware:
- 'sdtrig' should be marked with 'x-' and be an experimental extension since
the spec isn't yet frozen;- Alvin sent a patch to the ML adding the 'mcontext' CSR for 'sdtrig' some time
ago:"[PATCH v2] target/riscv: Implement optional CSR mcontext of debug Sdtrig extension"
It would be good to put his patch on top of this series to ease the review for everyone.
The changes done in patch 2 would also be applicable to the mcontext CSR;- last but probably the most important: the existing 'debug' flag seems to be acting as
the actual 'sdtrig' extension due to how the flag is gating trigger code, e.g.:if (cpu->cfg.debug) { riscv_trigger_realize(&cpu->env); }and
if (cpu->cfg.debug) { riscv_trigger_reset_hold(env); }Quoted 5 lines
If that's really the case, all the checks with
cpu->cfg.debugwill need to also includecpu->cfg.ext_sdtrig(one or the other). And now we'll have to make an option: do we leave
the debug triggers (i.e. the 'debug' flag) as always enabled?From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
Quoted 1 line
Quoted 8 lines
Quoted 2 lines
If it's up to me I would make 'debug' as default 'false' and deprecate it. Users will need
I don't think that's the right approach. It's a ratified extension that we are supporting and is in hardware. I think we are stuck supporting it
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extension
Quoted 4 lines
In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
Yeah... We used the "stable" from master. That is our mistake there.
I'm pretty sure we targeted the 0.13. The "Sdtrig" was only added in the v4 as the changelog says: "mention Sdtrig extension in the commit"
Quoted 13 lines
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
Quoted 7 lines
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default on
We can't deprecate a ratified spec. The 0.13 just seems to call it "debug" so that's what we are stuck with
Quoted 2 lines
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen spec
We will need to support two versions, as there are two ratified specs.
Alistair
Quoted 10 lines
There is potentially a chance that some use cases will be broken but I don't think triggers are being widely use - the SBI support only just got merged:
https://github.com/riscv-software-src/opensbi/commit/97f234f15c9657c6ec69fa6ed745be8107bf6ae2Hope this is helpful,
Rob
Quoted 13 lines · Alistair Francis
Quoted 13 lines
Quoted 13 lines
From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
...
Quoted 43 lines
Quoted 12 lines
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extensionQuoted 4 lines
In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
Yeah... We used the "stable" from master. That is our mistake there.
I'm pretty sure we targeted the 0.13. The "Sdtrig" was only added in the v4 as the changelog says: "mention Sdtrig extension in the commit"
Quoted 13 lines
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
Quoted 7 lines
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default on
Quoted 8 lines
We can't deprecate a ratified spec. The 0.13 just seems to call it "debug" so that's what we are stuck with
Quoted 2 lines
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen specWe will need to support two versions, as there are two ratified specs.
We'll likely want to be allowed to deprecate ratified extensions as riscv evolves. Despite best intentions, extensions may be designed and ratified which ultimately fail to be of much utility, and new extensions will supersede old extensions. If QEMU keeps every extension it adds, then we'll slow progress on new extensions by maintaining old extension code. The old extensions will also bitrot or waste CI resources getting tested for no reason.
I don't know the history of 'debug' and 'sdtrig', other than what I've read above, but, to me, it looks like 'debug' might be one of the first extensions which should be deprecated. Assuming we have a long enough deprecation period, then I think it's always safe to attempt a deprecation. If somebody shouts, then it can always be taken back off the chopping block.
Thanks,
drew
Quoted 68 lines · Andrew Jones
Quoted 13 lines · Alistair Francis
Quoted 13 lines
Quoted 13 lines
From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
...
Quoted 43 lines
Quoted 12 lines
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extensionQuoted 4 lines
In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
Yeah... We used the "stable" from master. That is our mistake there.
I'm pretty sure we targeted the 0.13. The "Sdtrig" was only added in the v4 as the changelog says: "mention Sdtrig extension in the commit"
Quoted 13 lines
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
Quoted 7 lines
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default onQuoted 8 lines
We can't deprecate a ratified spec. The 0.13 just seems to call it "debug" so that's what we are stuck with
Quoted 2 lines
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen specWe will need to support two versions, as there are two ratified specs.
Quoted 7 lines
We'll likely want to be allowed to deprecate ratified extensions as riscv evolves. Despite best intentions, extensions may be designed and ratified which ultimately fail to be of much utility, and new extensions will supersede old extensions. If QEMU keeps every extension it adds, then we'll slow progress on new extensions by maintaining old extension code. The old extensions will also bitrot or waste CI resources getting tested for no reason.
I agree that we might need to deprecate extensions.
I'm not sure the debug extension is there though. The debug extension is used in current shipping hardware and has been ratified. The Sdtrig isn't even ratified yet
(https://lists.riscv.org/g/tech-announce/message/320)
Right now I feel that we should at least wait for hardware that supports Sdtrig to start to come out. Then we can look at deprecating debug. Deprecating it now seems a bit premature.
Alistair
Quoted 11 lines
I don't know the history of 'debug' and 'sdtrig', other than what I've read above, but, to me, it looks like 'debug' might be one of the first extensions which should be deprecated. Assuming we have a long enough deprecation period, then I think it's always safe to attempt a deprecation. If somebody shouts, then it can always be taken back off the chopping block.
Thanks,
drew
Quoted 78 lines · Alistair Francis
Quoted 68 lines · Andrew Jones
Quoted 13 lines · Alistair Francis
Quoted 13 lines
Quoted 13 lines
From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
...
Quoted 43 lines
Quoted 12 lines
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extensionQuoted 4 lines
In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
Yeah... We used the "stable" from master. That is our mistake there.
I'm pretty sure we targeted the 0.13. The "Sdtrig" was only added in the v4 as the changelog says: "mention Sdtrig extension in the commit"
Quoted 13 lines
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
Quoted 7 lines
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default onQuoted 8 lines
We can't deprecate a ratified spec. The 0.13 just seems to call it "debug" so that's what we are stuck with
Quoted 2 lines
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen specWe will need to support two versions, as there are two ratified specs.
Quoted 7 lines
We'll likely want to be allowed to deprecate ratified extensions as riscv evolves. Despite best intentions, extensions may be designed and ratified which ultimately fail to be of much utility, and new extensions will supersede old extensions. If QEMU keeps every extension it adds, then we'll slow progress on new extensions by maintaining old extension code. The old extensions will also bitrot or waste CI resources getting tested for no reason.
Quoted 6 lines
I agree that we might need to deprecate extensions.
I'm not sure the debug extension is there though. The debug extension is used in current shipping hardware and has been ratified. The Sdtrig isn't even ratified yet
(https://lists.riscv.org/g/tech-announce/message/320)
Is shipping real hardware OR ratification a requirement of QEMU patch acceptance ?
Regards,
Anup
Quoted 19 lines
Right now I feel that we should at least wait for hardware that supports Sdtrig to start to come out. Then we can look at deprecating debug. Deprecating it now seems a bit premature.
Alistair
Quoted 11 lines
I don't know the history of 'debug' and 'sdtrig', other than what I've read above, but, to me, it looks like 'debug' might be one of the first extensions which should be deprecated. Assuming we have a long enough deprecation period, then I think it's always safe to attempt a deprecation. If somebody shouts, then it can always be taken back off the chopping block.
Thanks,
drew
Quoted 82 lines · Anup Patel
Quoted 80 lines · Alistair Francis
Quoted 68 lines · Andrew Jones
Quoted 13 lines · Alistair Francis
Quoted 13 lines
Quoted 13 lines
From memory the "debug" property is for the original debug spec:
https://github.com/riscv/riscv-debug-spec/releases/tag/task_group_voteThat was ratified and is an official extension. AFAIK this is what is in physical hardware as well.
The actual PDF says draft though, I'm not sure what's going on there.
The debug spec doesn't have a Z* name, so it's just "debug", at least AFAIK.
"sdtrig" seems to be a new backwards-incompatible extension doing basically the same thing. What a mess
...
Quoted 43 lines
Quoted 12 lines
I've done a bit of digging and I agree things are quite messy. Here are my discoveries:
The debug option and the code for triggers was added in these commits:
c9711bd778target/riscv: cpu: Enable native debug feature38b4e781a4target/riscv: machine: Add debug state descriptionb6092544fctarget/riscv: csr: Hook debug CSR read/write1acdb3b013target/riscv: cpu: Add a config option for native debug95799e36c1target/riscv: Add initial support for the Sdtrig extensionQuoted 4 lines
In March 2022 - since the commit refers to the Sdtrig extension name and from the date this was an implementation not of the ratified 0.13 debug spec (which did not have Sdtrig as a separate extension) but rather a version of the in development 1.0 debug spec.
Yeah... We used the "stable" from master. That is our mistake there.
I'm pretty sure we targeted the 0.13. The "Sdtrig" was only added in the v4 as the changelog says: "mention Sdtrig extension in the commit"
Quoted 13 lines
It's not trivial to tell if it's closer to the ratified 0.13 version or the (hopefully soon to be frozen) 1.0 version.
As the only part of the debug specification to be implemented is the triggers then effectively the debug option is x-sdtrig.
I don't think there is any way for code running on the machine to identify what version of the debug is implemented - the appropriate register is only available for external debug. Once 1.0 is frozen then the presence of Sdtrig isa string would indicate 1.0 trigger support is available.
Quoted 7 lines
According to JIRA - https://jira.riscv.org/browse/RVS-981 the debug specification should freeze this month.
How about considering this as a solution:
- Add a new x-sdtrig option that defaults to false
- Deprecate debug option - but retain it with default onQuoted 8 lines
We can't deprecate a ratified spec. The 0.13 just seems to call it "debug" so that's what we are stuck with
Quoted 2 lines
- Add warning if triggers are used and x-sdtrig is not enabled
- Update the trigger implementation to match frozen specWe will need to support two versions, as there are two ratified specs.
Quoted 7 lines
We'll likely want to be allowed to deprecate ratified extensions as riscv evolves. Despite best intentions, extensions may be designed and ratified which ultimately fail to be of much utility, and new extensions will supersede old extensions. If QEMU keeps every extension it adds, then we'll slow progress on new extensions by maintaining old extension code. The old extensions will also bitrot or waste CI resources getting tested for no reason.
I agree that we might need to deprecate extensions.
Quoted 7 lines
Quoted 4 lines
I'm not sure the debug extension is there though. The debug extension is used in current shipping hardware and has been ratified. The Sdtrig isn't even ratified yet
(https://lists.riscv.org/g/tech-announce/message/320)Is shipping real hardware OR ratification a requirement of QEMU patch acceptance ?
We will accept an extension when it is ratified. The question here is, what if two ratified extensions conflict?
The answer to me seems that we need to support both them. *Maybe* at some point in the future we can then drop the debug extension. That would require the Sdtrig extension to be widely used and debug not used (which is why I brought up shipping hardware).
Alistair
Quoted 23 lines
Regards,
AnupQuoted 19 lines
Right now I feel that we should at least wait for hardware that supports Sdtrig to start to come out. Then we can look at deprecating debug. Deprecating it now seems a bit premature.
Alistair
Quoted 11 lines
I don't know the history of 'debug' and 'sdtrig', other than what I've read above, but, to me, it looks like 'debug' might be one of the first extensions which should be deprecated. Assuming we have a long enough deprecation period, then I think it's always safe to attempt a deprecation. If somebody shouts, then it can always be taken back off the chopping block.
Thanks,
drew