Commit b8cb88aaa3 for qemu.org
commit b8cb88aaa32d8e1ff55c5bc347bae7da09f2e63f
Author: SignKirigami <prcups@krgm.moe>
Date: Tue Oct 13 15:35:12 2026 +0800
target/loongarch: Select sys state by VM level
Define VM_LEVEL0 and VM_LEVELS for the available VM levels. Replace
set_sys_state(), which accepted a CPUSysState pointer, with set_sys(),
which selects a state by VM level. There is no function change in this
patch.
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: SignKirigami <prcups@krgm.moe>
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 9cf566f0f6..809f0bb509 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -299,7 +299,7 @@ static void loongarch_la464_initfn(Object *obj)
uint32_t data = 0, field;
int i;
- set_sys_state(env, &env->sys_states[0]);
+ set_sys(env, VM_LEVEL0);
for (i = 0; i < 21; i++) {
env->cpucfg[i] = 0x0;
}
@@ -429,7 +429,7 @@ static void loongarch_la132_initfn(Object *obj)
uint32_t data = 0;
int i;
- set_sys_state(env, &env->sys_states[0]);
+ set_sys(env, VM_LEVEL0);
for (i = 0; i < 21; i++) {
env->cpucfg[i] = 0x0;
}
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 4ab81e0f7b..5cc2370da2 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -322,6 +322,9 @@ typedef struct CPUTimerState {
CPUState *cs;
} CPUTimerState;
+#define VM_LEVEL0 0
+#define VM_LEVELS 1
+
#define CPU_VENDOR_LOONGSON "Loongson"
#define CPU_MODEL_3A5000 "3A5000"
#define CPU_MODEL_1C101 "1C101"
@@ -510,9 +513,9 @@ static inline CPUSysState *env_sys(CPULoongArchState *env)
return env->sys_state;
}
-static inline void set_sys_state(CPULoongArchState *env, CPUSysState *sys)
+static inline void set_sys(CPULoongArchState *env, int vm_level)
{
- env->sys_state = sys;
+ env->sys_state = &env->sys_states[vm_level];
}
static inline CPUTimerState *env_timer(CPULoongArchState *env)