Skip to content

Commit 04ff272

Browse files
atishp04alistair23
authored andcommitted
target/riscv: Invoke pmu init after feature enable
The dependant ISA features are enabled at the end of cpu_realize in finalize_features. Thus, PMU init should be invoked after that only. Move the init invocation to riscv_tcg_cpu_finalize_features. Reviewed-by: Alistair Francis <[email protected]> Signed-off-by: Atish Patra <[email protected]> Message-ID: <[email protected]> Signed-off-by: Alistair Francis <[email protected]>
1 parent 6247dc2 commit 04ff272

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

target/riscv/tcg/tcg-cpu.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,20 @@ void riscv_tcg_cpu_finalize_features(RISCVCPU *cpu, Error **errp)
963963
error_propagate(errp, local_err);
964964
return;
965965
}
966+
#ifndef CONFIG_USER_ONLY
967+
if (cpu->cfg.pmu_mask) {
968+
riscv_pmu_init(cpu, &local_err);
969+
if (local_err != NULL) {
970+
error_propagate(errp, local_err);
971+
return;
972+
}
973+
974+
if (cpu->cfg.ext_sscofpmf) {
975+
cpu->pmu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
976+
riscv_pmu_timer_cb, cpu);
977+
}
978+
}
979+
#endif
966980
}
967981

968982
void riscv_tcg_cpu_finalize_dynamic_decoder(RISCVCPU *cpu)
@@ -1010,27 +1024,13 @@ static bool riscv_tcg_cpu_realize(CPUState *cs, Error **errp)
10101024

10111025
#ifndef CONFIG_USER_ONLY
10121026
CPURISCVState *env = &cpu->env;
1013-
Error *local_err = NULL;
10141027

10151028
tcg_cflags_set(CPU(cs), CF_PCREL);
10161029

10171030
if (cpu->cfg.ext_sstc) {
10181031
riscv_timer_init(cpu);
10191032
}
10201033

1021-
if (cpu->cfg.pmu_mask) {
1022-
riscv_pmu_init(cpu, &local_err);
1023-
if (local_err != NULL) {
1024-
error_propagate(errp, local_err);
1025-
return false;
1026-
}
1027-
1028-
if (cpu->cfg.ext_sscofpmf) {
1029-
cpu->pmu_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL,
1030-
riscv_pmu_timer_cb, cpu);
1031-
}
1032-
}
1033-
10341034
/* With H-Ext, VSSIP, VSTIP, VSEIP and SGEIP are hardwired to one. */
10351035
if (riscv_has_ext(env, RVH)) {
10361036
env->mideleg = MIP_VSSIP | MIP_VSTIP | MIP_VSEIP | MIP_SGEIP;

0 commit comments

Comments
 (0)