target/riscv: Initial support for native debug feature via M-mode CSRs
Subsystems (2)
v2 cover target/riscv: Initial support for native debug feature via M-mode CSRs
This adds initial support for the native debug via the Trigger Module, as defined in the RISC-V Debug Specification [1].
Only "Address / Data Match" trigger (type 2) is implemented as of now, which is mainly used for hardware breakpoint and watchpoint. The number of type 2 triggers implemented is 2, which is the number that we can find in the SiFive U54/U74 cores.
[1] https://github.com/riscv/riscv-debug-spec/raw/master/riscv-debug-stable.pdf
Based-on: [email protected]
Changes in v2:
- new patch: add debug state description
- use 0 instead of GETPC()
- change the config option to 'disabled' by default
- new patch: enable native debug feature on virt and sifive_u CPUs
Bin Meng (7):
target/riscv: Add initial support for native debug target/riscv: machine: Add debug state description target/riscv: debug: Implement debug related TCGCPUOps target/riscv: cpu: Add a config option for native debug target/riscv: csr: Hook debug CSR read/write target/riscv: cpu: Enable native debug feature on virt and sifive_u
CPUs
hw/core: tcg-cpu-ops.h: Update comments of debug_check_watchpoint()
include/hw/core/tcg-cpu-ops.h | 1 + target/riscv/cpu.h | 7 + target/riscv/debug.h | 114 +++++++++ target/riscv/cpu.c | 18 ++ target/riscv/csr.c | 57 +++++ target/riscv/debug.c | 441 ++++++++++++++++++++++++++++++++++ target/riscv/machine.c | 33 +++ target/riscv/meson.build | 1 + 8 files changed, 672 insertions(+) create mode 100644 target/riscv/debug.h create mode 100644 target/riscv/debug.c
Signature · 1 line
2.25.1
PATCH v2 1/7 target/riscv: Add initial support for native debug
This adds initial support for the native debug via the Trigger Module, as defined in the RISC-V Debug Specification [1].
Only "Address / Data Match" trigger (type 2) is implemented as of now, which is mainly used for hardware breakpoint and watchpoint. The number of type 2 triggers implemented is 2, which is the number that we can find in the SiFive U54/U74 cores.
[1] https://github.com/riscv/riscv-debug-spec/raw/master/riscv-debug-stable.pdf
---
(no changes since v1)
target/riscv/cpu.h | 5 + target/riscv/debug.h | 110 ++++++++++++ target/riscv/debug.c | 366 +++++++++++++++++++++++++++++++++++++++ target/riscv/meson.build | 1 + 4 files changed, 482 insertions(+) create mode 100644 target/riscv/debug.h create mode 100644 target/riscv/debug.c
target/riscv/cpu.h +5 -0
@@ -98,6 +98,7 @@ typedef struct CPURISCVState CPURISCVState;#if !defined(CONFIG_USER_ONLY )#include "pmp.h" +#include "debug.h" #endif #define RV_VLEN_MAX 256
@@ -232,6 +233,10 @@ struct CPURISCVState {pmp_table_t pmp_state;target_ulong mseccfg; +/* trigger module */ +target_ulong trigger_cur; +trigger_type2_t trigger_type2[TRIGGER_TYPE2_NUM ]; +/* machine specific rdtime callback */ uint64_t (*rdtime_fn)(uint32_t );uint32_t rdtime_fn_arg;
target/riscv/debug.h new file +110 -0
110 lines not on this page · raw message
target/riscv/debug.c new file +366 -0
366 lines not on this page · raw message
target/riscv/meson.build +1 -0
@@ -24,6 +24,7 @@ riscv_softmmu_ss = ss.source_set() riscv_softmmu_ss.add(files( 'arch_dump.c', 'pmp.c', + 'debug.c', 'monitor.c', 'machine.c' ))
Signature · 1 line
2.25.1
PATCH v2 2/7 target/riscv: machine: Add debug state description
In reply to Bin MengAdd a subsection to machine.c to migrate debug CSR state.
---
Changes in v2:
- new patch: add debug state description
target/riscv/machine.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
target/riscv/machine.c +33 -0
@@ -164,6 +164,38 @@ static const VMStateDescription vmstate_pointermasking = { } }; +static bool debug_needed (void *opaque) +{ +RISCVCPU *cpu = opaque; +CPURISCVState *env = &cpu->env; + +return riscv_feature (env,RISCV_FEATURE_DEBUG ); +} + +static const VMStateDescription vmstate_debug_type2 = { + .name ="cpu/debug/type2" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINTTL (mcontrol, trigger_type2_t), +VMSTATE_UINTTL (maddress, trigger_type2_t), +VMSTATE_END_OF_LIST () + } +}; + +static const VMStateDescription vmstate_debug = { + .name ="cpu/debug" , + .version_id =1 , + .minimum_version_id =1 , + .needed = debug_needed, + .fields = (VMStateField []) { +VMSTATE_UINTTL (env.trigger_cur,RISCVCPU ), +VMSTATE_STRUCT_ARRAY (env.trigger_type2,RISCVCPU ,TRIGGER_TYPE2_NUM , +0 , vmstate_debug_type2, trigger_type2_t), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_riscv_cpu = { .name ="cpu" , .version_id =3 ,
@@ -218,6 +250,7 @@ const VMStateDescription vmstate_riscv_cpu = { &vmstate_hyper, &vmstate_vector, &vmstate_pointermasking, + &vmstate_debug, NULL } };
Signature · 1 line
2.25.1
Re: [PATCH v2 2/7] target/riscv: machine: Add debug state description
Quoted 4 lines · Bin Meng
Add a subsection to
machine.cto migrate debug CSR state.Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 64 lines
---
Changes in v2:
- new patch: add debug state descriptiontarget/riscv/machine.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)target/riscv/machine.c +33
-1@@ -164,6 +164,38 @@ static const VMStateDescription vmstate_pointermasking = { } }; +static bool debug_needed (void *opaque) +{ +RISCVCPU *cpu = opaque; +CPURISCVState *env = &cpu->env; + +return riscv_feature (env,RISCV_FEATURE_DEBUG ); +} + +static const VMStateDescription vmstate_debug_type2 = { + .name ="cpu/debug/type2" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_UINTTL (mcontrol, trigger_type2_t), +VMSTATE_UINTTL (maddress, trigger_type2_t), +VMSTATE_END_OF_LIST () + } +}; + +static const VMStateDescription vmstate_debug = { + .name ="cpu/debug" , + .version_id =1 , + .minimum_version_id =1 , + .needed = debug_needed, + .fields = (VMStateField []) { +VMSTATE_UINTTL (env.trigger_cur,RISCVCPU ), +VMSTATE_STRUCT_ARRAY (env.trigger_type2,RISCVCPU ,TRIGGER_TYPE2_NUM , +0 , vmstate_debug_type2, trigger_type2_t), +VMSTATE_END_OF_LIST () + } +}; +const VMStateDescription vmstate_riscv_cpu = { .name ="cpu" , .version_id =3 ,@@ -218,6 +250,7 @@ const VMStateDescription vmstate_riscv_cpu = { &vmstate_hyper, &vmstate_vector, &vmstate_pointermasking, + &vmstate_debug, NULL } }; --2.25.1
PATCH v2 3/7 target/riscv: debug: Implement debug related TCGCPUOps
In reply to Bin MengImplement .debug_excp_handler, .debug_check_{breakpoint, watchpoint} TCGCPUOps and hook them into riscv_tcg_ops.
---
Changes in v2:
- use 0 instead of GETPC()
target/riscv/debug.h | 4 +++ target/riscv/cpu.c | 3 ++ target/riscv/debug.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)
target/riscv/debug.h +4 -0
@@ -107,4 +107,8 @@ void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val);void riscv_trigger_init (CPURISCVState *env); +void riscv_cpu_debug_excp_handler (CPUState *cs); +bool riscv_cpu_debug_check_breakpoint (CPUState *cs); +bool riscv_cpu_debug_check_watchpoint (CPUState *cs,CPUWatchpoint *wp); +#endif /* RISCV_DEBUG_H */
target/riscv/cpu.c +3 -0
@@ -701,6 +701,9 @@ static const struct TCGCPUOps riscv_tcg_ops = { .do_interrupt = riscv_cpu_do_interrupt, .do_transaction_failed = riscv_cpu_do_transaction_failed, .do_unaligned_access = riscv_cpu_do_unaligned_access, + .debug_excp_handler = riscv_cpu_debug_excp_handler, + .debug_check_breakpoint = riscv_cpu_debug_check_breakpoint, + .debug_check_watchpoint = riscv_cpu_debug_check_watchpoint,#endif /* !CONFIG_USER_ONLY */ };
target/riscv/debug.c +75 -0
78 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 3/7] target/riscv: debug: Implement debug related TCGCPUOps
Quoted 5 lines · Bin Meng
Implement .debug_excp_handler, .debug_check_{breakpoint, watchpoint} TCGCPUOps and hook them into
riscv_tcg_ops.Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 125 lines
---
Changes in v2:
- use 0 instead ofGETPC()target/riscv/debug.h | 4 +++ target/riscv/cpu.c | 3 ++ target/riscv/debug.c | 75 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+)target/riscv/debug.h +4
-0@@ -107,4 +107,8 @@ void tdata_csr_write(CPURISCVState *env, int tdata_index, target_ulong val);void riscv_trigger_init (CPURISCVState *env); +void riscv_cpu_debug_excp_handler (CPUState *cs); +bool riscv_cpu_debug_check_breakpoint (CPUState *cs); +bool riscv_cpu_debug_check_watchpoint (CPUState *cs,CPUWatchpoint *wp); +#endif /* RISCV_DEBUG_H */ target/riscv/cpu.c +3
-0@@ -701,6 +701,9 @@ static const struct TCGCPUOps riscv_tcg_ops = { .do_interrupt = riscv_cpu_do_interrupt, .do_transaction_failed = riscv_cpu_do_transaction_failed, .do_unaligned_access = riscv_cpu_do_unaligned_access, + .debug_excp_handler = riscv_cpu_debug_excp_handler, + .debug_check_breakpoint = riscv_cpu_debug_check_breakpoint, + .debug_check_watchpoint = riscv_cpu_debug_check_watchpoint,#endif /* !CONFIG_USER_ONLY */ };target/riscv/debug.c +75
-1@@ -364,3 +364,78 @@ void riscv_trigger_init(CPURISCVState *env) env->trigger_type2[i].wp =NULL ; } } + +void riscv_cpu_debug_excp_handler (CPUState *cs) +{ +RISCVCPU *cpu =RISCV_CPU (cs); +CPURISCVState *env = &cpu->env; + +if (cs->watchpoint_hit) { +if (cs->watchpoint_hit->flags &BP_CPU ) { + cs->watchpoint_hit =NULL ; +riscv_raise_exception (env,RISCV_EXCP_BREAKPOINT ,0 ); + } + }else { +if (cpu_breakpoint_test (cs, env->pc,BP_CPU )) { +riscv_raise_exception (env,RISCV_EXCP_BREAKPOINT ,0 ); + } + } +} + +bool riscv_cpu_debug_check_breakpoint (CPUState *cs) +{ +RISCVCPU *cpu =RISCV_CPU (cs); +CPURISCVState *env = &cpu->env; +CPUBreakpoint *bp; +target_ulong ctrl; +target_ulong pc; +int i; + + QTAILQ_FOREACH(bp, &cs->breakpoints, entry) { +for (i =0 ; i <TRIGGER_TYPE2_NUM ; i++) { + ctrl = env->trigger_type2[i].mcontrol; + pc = env->trigger_type2[i].maddress; + +if ((ctrl &TYPE2_EXEC ) && (bp->pc == pc)) { +/* check U/S/M bit against current privilege level */ +if ((ctrl >>3 ) &BIT (env->priv)) { +return true; + } + } + } + } + +return false; +} + +bool riscv_cpu_debug_check_watchpoint (CPUState *cs,CPUWatchpoint *wp) +{ +RISCVCPU *cpu =RISCV_CPU (cs); +CPURISCVState *env = &cpu->env; +target_ulong ctrl; +target_ulong addr; +int flags; +int i; + +for (i =0 ; i <TRIGGER_TYPE2_NUM ; i++) { + ctrl = env->trigger_type2[i].mcontrol; + addr = env->trigger_type2[i].maddress; + flags =0 ; + +if (ctrl &TYPE2_LOAD ) { + flags |=BP_MEM_READ ; + } +if (ctrl &TYPE2_STORE ) { + flags |=BP_MEM_WRITE ; + } + +if ((wp->flags & flags) && (wp->vaddr == addr)) { +/* check U/S/M bit against current privilege level */ +if ((ctrl >>3 ) &BIT (env->priv)) { +return true; + } + } + } + +return false; +} --2.25.1
PATCH v2 4/7 target/riscv: cpu: Add a config option for native debug
In reply to Bin MengAdd a config option to enable support for native M-mode debug. This is disabled by default and can be enabled with 'debug=true'.
---
Changes in v2:
- change the config option to 'disabled' by default
target/riscv/cpu.h | 2 ++ target/riscv/cpu.c | 5 +++++ 2 files changed, 7 insertions(+)
target/riscv/cpu.h +2 -0
@@ -75,6 +75,7 @@ enum {RISCV_FEATURE_MMU ,RISCV_FEATURE_PMP ,RISCV_FEATURE_EPMP , +RISCV_FEATURE_DEBUG , RISCV_FEATURE_MISA };
@@ -327,6 +328,7 @@ struct RISCVCPU {bool mmu;bool pmp;bool epmp; +bool debug;uint64_t resetvec; } cfg; };
target/riscv/cpu.c +5 -0
@@ -448,6 +448,10 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } } +if (cpu->cfg.debug) { +set_feature (env,RISCV_FEATURE_DEBUG ); + } +set_resetvec (env, cpu->cfg.resetvec);/* Validate that MISA_MXL is set properly. */
@@ -631,6 +635,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("Zicsr" ,RISCVCPU , cfg.ext_icsr, true),DEFINE_PROP_BOOL ("mmu" ,RISCVCPU , cfg.mmu, true),DEFINE_PROP_BOOL ("pmp" ,RISCVCPU , cfg.pmp, true), +DEFINE_PROP_BOOL ("debug" ,RISCVCPU , cfg.debug, false), DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec),
Signature · 1 line
2.25.1
Re: [PATCH v2 4/7] target/riscv: cpu: Add a config option for native debug
Quoted 5 lines · Bin Meng
Add a config option to enable support for native M-mode debug. This is disabled by default and can be enabled with 'debug=true'.
Signed-off-by Bin Meng <[email protected]>
Alistair
Quoted 57 lines
---
Changes in v2:
- change the config option to 'disabled' by defaulttarget/riscv/cpu.h | 2 ++ target/riscv/cpu.c | 5 +++++ 2 files changed, 7 insertions(+)target/riscv/cpu.h +2
-0@@ -75,6 +75,7 @@ enum {RISCV_FEATURE_MMU ,RISCV_FEATURE_PMP ,RISCV_FEATURE_EPMP , +RISCV_FEATURE_DEBUG , RISCV_FEATURE_MISA };@@ -327,6 +328,7 @@ struct RISCVCPU {bool mmu;bool pmp;bool epmp; +bool debug;uint64_t resetvec; } cfg; };target/riscv/cpu.c +5
-1@@ -448,6 +448,10 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp) } } +if (cpu->cfg.debug) { +set_feature (env,RISCV_FEATURE_DEBUG ); + } +set_resetvec (env, cpu->cfg.resetvec);/* Validate that MISA_MXL is set properly. */ @@ -631,6 +635,7 @@ static Property riscv_cpu_properties[] = {DEFINE_PROP_BOOL ("Zicsr" ,RISCVCPU , cfg.ext_icsr, true),DEFINE_PROP_BOOL ("mmu" ,RISCVCPU , cfg.mmu, true),DEFINE_PROP_BOOL ("pmp" ,RISCVCPU , cfg.pmp, true), +DEFINE_PROP_BOOL ("debug" ,RISCVCPU , cfg.debug, false), DEFINE_PROP_STRING("priv_spec", RISCVCPU, cfg.priv_spec), --2.25.1
PATCH v2 5/7 target/riscv: csr: Hook debug CSR read/write
In reply to Bin MengThis adds debug CSR read/write support to the RISC-V CSR RW table.
---
(no changes since v1)
target/riscv/cpu.c | 6 +++++ target/riscv/csr.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
target/riscv/cpu.c +6 -0
@@ -575,6 +575,12 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)riscv_cpu_register_gdb_regs_for_features (cs); +#ifndef CONFIG_USER_ONLY +if (riscv_feature (env,RISCV_FEATURE_DEBUG )) { +riscv_trigger_init (env); + } +#endif +qemu_init_vcpu (cs);cpu_reset (cs);
target/riscv/csr.c +57 -0
75 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v2 5/7] target/riscv: csr: Hook debug CSR read/write
Quoted 17 lines · Bin Meng
This adds debug CSR read/write support to the RISC-V CSR RW table.
Signed-off-by Bin Meng <[email protected]>---
(no changes since v1)
target/riscv/cpu.c | 6 +++++ target/riscv/csr.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)target/riscv/cpu.c +0
-0
target/riscv/cpu.c static void riscv_cpu_realize(DeviceState *dev, Error **errp) · line 580
Quoted 6 lines
target/riscv/cpu.c +3
-0@@ -575,6 +575,12 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)riscv_cpu_register_gdb_regs_for_features (cs); +#ifndef CONFIG_USER_ONLY +if (riscv_feature (env,RISCV_FEATURE_DEBUG )) { +riscv_trigger_init (env);
This function should be added here instead of patch 1
Alistair
Quoted 92 lines
target/riscv/cpu.c +3
-0+ } +#endif +qemu_init_vcpu (cs);cpu_reset (cs);target/riscv/csr.c +57
-1@@ -219,6 +219,15 @@ static RISCVException epmp(CPURISCVState *env, int csrno) return RISCV_EXCP_ILLEGAL_INST; } + +static RISCVException debug (CPURISCVState *env,int csrno) +{ +if (riscv_feature (env,RISCV_FEATURE_DEBUG )) { +return RISCV_EXCP_NONE ; + } + +return RISCV_EXCP_ILLEGAL_INST ; +}#endif /* User Floating-Point CSRs */ @@ -1435,6 +1444,48 @@ static RISCVException write_pmpaddr(CPURISCVState *env, int csrno,return RISCV_EXCP_NONE ; } +static RISCVException read_tselect (CPURISCVState *env,int csrno, +target_ulong *val) +{ + *val =tselect_csr_read (env); +return RISCV_EXCP_NONE ; +} + +static RISCVException write_tselect (CPURISCVState *env,int csrno, +target_ulong val) +{ +tselect_csr_write (env, val); +return RISCV_EXCP_NONE ; +} + +static RISCVException read_tdata (CPURISCVState *env,int csrno, +target_ulong *val) +{ +/* return 0 in tdata1 to end the trigger enumeration */ +if (env->trigger_cur >=TRIGGER_NUM && csrno ==CSR_TDATA1 ) { + *val =0 ; +return RISCV_EXCP_NONE ; + } + +if (!tdata_available (env, csrno -CSR_TDATA1 )) { +return RISCV_EXCP_ILLEGAL_INST ; + } + + *val =tdata_csr_read (env, csrno -CSR_TDATA1 ); +return RISCV_EXCP_NONE ; +} + +static RISCVException write_tdata (CPURISCVState *env,int csrno, +target_ulong val) +{ +if (!tdata_available (env, csrno -CSR_TDATA1 )) { +return RISCV_EXCP_ILLEGAL_INST ; + } + +tdata_csr_write (env, csrno -CSR_TDATA1 , val); +return RISCV_EXCP_NONE ; +} +/* * Functions to access Pointer Masking feature registers * We have to check if current priv lvl could modify @@ -1931,6 +1982,12 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] = { [CSR_PMPADDR14] = { "pmpaddr14", pmp, read_pmpaddr, write_pmpaddr }, [CSR_PMPADDR15] = { "pmpaddr15", pmp, read_pmpaddr, write_pmpaddr }, + /* Debug CSRs */ + [CSR_TSELECT] = { "tselect", debug, read_tselect, write_tselect }, + [CSR_TDATA1] = { "tdata1", debug, read_tdata, write_tdata }, + [CSR_TDATA2] = { "tdata2", debug, read_tdata, write_tdata }, + [CSR_TDATA3] = { "tdata3", debug, read_tdata, write_tdata }, + /* User Pointer Masking */ [CSR_UMTE] = { "umte", pointer_masking, read_umte, write_umte }, [CSR_UPMMASK] = { "upmmask", pointer_masking, read_upmmask, write_upmmask }, --2.25.1
PATCH v2 6/7 target/riscv: cpu: Enable native debug feature on virt and sifive_u CPUs
In reply to Bin MengTurn on native debug feature on virt and sifive_u CPUs.
---
Changes in v2:
- new patch: enable native debug feature on virt and sifive_u CPUs
target/riscv/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)
target/riscv/cpu.c +4 -0
@@ -153,6 +153,7 @@ static void rv64_base_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;/* We set this in the realise function */ set_misa (env,MXL_RV64 ,0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv64_sifive_u_cpu_init (Object *obj)
@@ -160,6 +161,7 @@ static void rv64_sifive_u_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;set_misa (env,MXL_RV64 ,RVI |RVM |RVA |RVF |RVD |RVC |RVS |RVU );set_priv_version (env,PRIV_VERSION_1_10_0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv64_sifive_e_cpu_init (Object *obj)
@@ -175,6 +177,7 @@ static void rv32_base_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;/* We set this in the realise function */ set_misa (env,MXL_RV32 ,0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv32_sifive_u_cpu_init (Object *obj)
@@ -182,6 +185,7 @@ static void rv32_sifive_u_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;set_misa (env,MXL_RV32 ,RVI |RVM |RVA |RVF |RVD |RVC |RVS |RVU );set_priv_version (env,PRIV_VERSION_1_10_0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv32_sifive_e_cpu_init (Object *obj)
Signature · 1 line
2.25.1
Re: [PATCH v2 6/7] target/riscv: cpu: Enable native debug feature on virt and sifive_u CPUs
Quoted 2 lines · Bin Meng
Turn on native debug feature on virt and
sifive_uCPUs.
Is there a reason why it's only these 2 machines? Could this be enabled by default for all CPUs?
Alistair
Quoted 51 lines
Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- new patch: enable native debug feature on virt andsifive_uCPUstarget/riscv/cpu.c | 4 ++++ 1 file changed, 4 insertions(+)target/riscv/cpu.c +4
-1@@ -153,6 +153,7 @@ static void rv64_base_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;/* We set this in the realise function */ set_misa (env,MXL_RV64 ,0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv64_sifive_u_cpu_init (Object *obj)@@ -160,6 +161,7 @@ static void rv64_sifive_u_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;set_misa (env,MXL_RV64 ,RVI |RVM |RVA |RVF |RVD |RVC |RVS |RVU );set_priv_version (env,PRIV_VERSION_1_10_0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv64_sifive_e_cpu_init (Object *obj)@@ -175,6 +177,7 @@ static void rv32_base_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;/* We set this in the realise function */ set_misa (env,MXL_RV32 ,0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv32_sifive_u_cpu_init (Object *obj)@@ -182,6 +185,7 @@ static void rv32_sifive_u_cpu_init(Object *obj)CPURISCVState *env = &RISCV_CPU (obj)->env;set_misa (env,MXL_RV32 ,RVI |RVM |RVA |RVF |RVD |RVC |RVS |RVU );set_priv_version (env,PRIV_VERSION_1_10_0 ); +qdev_prop_set_bit (DEVICE (obj),"debug" , true); }static void rv32_sifive_e_cpu_init (Object *obj) --2.25.1
Re: [PATCH v2 6/7] target/riscv: cpu: Enable native debug feature on virt and sifive_u CPUs
Quoted 8 lines · Alistair Francis
Quoted 2 lines · Bin Meng
Turn on native debug feature on virt and
sifive_uCPUs.Is there a reason why it's only these 2 machines? Could this be enabled by default for all CPUs?
Yes, I think so. I only enabled these 2 as I did not check all hardware specs like OpenTitan, etc.
Regards,
Bin
PATCH v2 7/7 hw/core: tcg-cpu-ops.h: Update comments of debug_check_watchpoint()
In reply to Bin MengThis is now used by RISC-V as well. Update the comments.
---
(no changes since v1)
include/hw/core/tcg-cpu-ops.h | 1 + 1 file changed, 1 insertion(+)
include/hw/core/tcg-cpu-ops.h +1 -0
@@ -92,6 +92,7 @@ struct TCGCPUOps {/** * @debug_check_watchpoint: return true if the architectural * watchpoint whose address has matched should really fire, used by ARM +* and RISC-V */ bool (*debug_check_watchpoint)(CPUState *cpu,CPUWatchpoint *wp);
Signature · 1 line
2.25.1
Re: [PATCH v2 7/7] hw/core: tcg-cpu-ops.h: Update comments of debug_check_watchpoint()
Quoted 5 lines · Bin Meng
This is now used by RISC-V as well. Update the comments.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Richard Henderson <[email protected]>
Alistair
Quoted 24 lines
---
(no changes since v1)
include/hw/core/tcg-cpu-ops.h | 1 + 1 file changed, 1 insertion(+)include/hw/core/tcg-cpu-ops.h +1
-1@@ -92,6 +92,7 @@ struct TCGCPUOps {/** * @debug_check_watchpoint: return true if the architectural * watchpoint whose address has matched should really fire, used by ARM +* and RISC-V */ bool (*debug_check_watchpoint)(CPUState *cpu,CPUWatchpoint *wp); --2.25.1