On 2026/10/9 上午11:04, SignKirigami wrote:
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.
---
  target/loongarch/cpu.c | 4 ++--
  target/loongarch/cpu.h | 7 +++++--
  2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 54c2699897..6c6e1d81b8 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -298,7 +298,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;
      }
@@ -428,7 +428,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 c592f69885..391445f614 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -321,6 +321,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"
@@ -507,9 +510,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)

Reviewed-by: Bibo Mao <[email protected]>


Reply via email to