Skip to content

Commit

Permalink
target/riscv: remove RISCV_FEATURE_DEBUG
Browse files Browse the repository at this point in the history
RISCV_FEATURE_DEBUG will always follow the value defined by
cpu->cfg.debug flag. Read the flag instead.

Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
Reviewed-by: Weiwei Li <liweiwei@iscas.ac.cn>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: LIU Zhiwei <zhiwei_liu@linux.alibaba.com>
Message-ID: <20230222185205.355361-5-dbarboza@ventanamicro.com>
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
  • Loading branch information
danielhb authored and palmer-dabbelt committed Mar 1, 2023
1 parent 54bd9b6 commit cdfb290
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 10 deletions.
6 changes: 1 addition & 5 deletions target/riscv/cpu.c
Expand Up @@ -637,7 +637,7 @@ static void riscv_cpu_reset_hold(Object *obj)
set_default_nan_mode(1, &env->fp_status);

#ifndef CONFIG_USER_ONLY
if (riscv_feature(env, RISCV_FEATURE_DEBUG)) {
if (cpu->cfg.debug) {
riscv_trigger_init(env);
}

Expand Down Expand Up @@ -935,10 +935,6 @@ static void riscv_cpu_realize(DeviceState *dev, Error **errp)
}
}

if (cpu->cfg.debug) {
riscv_set_feature(env, RISCV_FEATURE_DEBUG);
}


#ifndef CONFIG_USER_ONLY
if (cpu->cfg.ext_sstc) {
Expand Down
1 change: 0 additions & 1 deletion target/riscv/cpu.h
Expand Up @@ -89,7 +89,6 @@ enum {
RISCV_FEATURE_MMU,
RISCV_FEATURE_PMP,
RISCV_FEATURE_EPMP,
RISCV_FEATURE_DEBUG
};

/* Privileged specification version */
Expand Down
2 changes: 1 addition & 1 deletion target/riscv/cpu_helper.c
Expand Up @@ -105,7 +105,7 @@ void cpu_get_tb_cpu_state(CPURISCVState *env, target_ulong *pc,
flags = FIELD_DP32(flags, TB_FLAGS, MSTATUS_HS_VS,
get_field(env->mstatus_hs, MSTATUS_VS));
}
if (riscv_feature(env, RISCV_FEATURE_DEBUG) && !icount_enabled()) {
if (cpu->cfg.debug && !icount_enabled()) {
flags = FIELD_DP32(flags, TB_FLAGS, ITRIGGER, env->itrigger_enabled);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion target/riscv/csr.c
Expand Up @@ -437,7 +437,7 @@ static RISCVException epmp(CPURISCVState *env, int csrno)

static RISCVException debug(CPURISCVState *env, int csrno)
{
if (riscv_feature(env, RISCV_FEATURE_DEBUG)) {
if (riscv_cpu_cfg(env)->debug) {
return RISCV_EXCP_NONE;
}

Expand Down
3 changes: 1 addition & 2 deletions target/riscv/machine.c
Expand Up @@ -226,9 +226,8 @@ static const VMStateDescription vmstate_kvmtimer = {
static bool debug_needed(void *opaque)
{
RISCVCPU *cpu = opaque;
CPURISCVState *env = &cpu->env;

return riscv_feature(env, RISCV_FEATURE_DEBUG);
return cpu->cfg.debug;
}

static int debug_post_load(void *opaque, int version_id)
Expand Down

0 comments on commit cdfb290

Please sign in to comment.