Add get_sys() to retrieve a CPUSysState by VM level. Use it to access the host state in CPU reset path to handle possible reset requests under vm_level 1.
Signed-off-by: SignKirigami <[email protected]> Signed-off-by: Hengyu Yu <[email protected]> --- target/loongarch/cpu.c | 2 +- target/loongarch/cpu.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 6c6e1d81b8..e1245235be 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -621,7 +621,7 @@ static void loongarch_cpu_reset_hold(Object *obj, ResetType type) CPUState *cs = CPU(obj); LoongArchCPUClass *lacc = LOONGARCH_CPU_GET_CLASS(obj); CPULoongArchState *env = cpu_env(cs); - CPUSysState *sys = env_sys(env); + CPUSysState *sys = get_sys(env, VM_LEVEL0); if (lacc->parent_phases.hold) { lacc->parent_phases.hold(obj, type); diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h index 391445f614..c0edcc9065 100644 --- a/target/loongarch/cpu.h +++ b/target/loongarch/cpu.h @@ -515,6 +515,11 @@ static inline void set_sys(CPULoongArchState *env, int vm_level) env->sys_state = &env->sys_states[vm_level]; } +static inline CPUSysState *get_sys(CPULoongArchState *env, int vm_level) +{ + return &env->sys_states[vm_level]; +} + static inline CPUTimerState *env_timer(CPULoongArchState *env) { return &env->sys_states[0].timer_state; -- 2.55.0
