@samitouri / QOSamiQemu / commits / 92dd54a0bf

target/loongarch: Add new field curState in CPULoongArchState

New field sys_state is added in structure CPULoongArchState, it points to CPULoongArchState itself now. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Philippe Mathieu-Daudé <philmd@mailo.com> Tested-by: Song Gao <gaosong@loongson.cn> Message-ID: <20260605082552.175336-2-maobibo@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn>

Bibo Mao committed Jun 5, 2026 at 16:25 UTC 92dd54a0bf4c0a78e05e48658ed1aa62e61a3cf9
2 files changed +15
target/loongarch/cpu.c
+2
@@ -278,6 +278,7 @@ static void loongarch_la464_initfn(Object *obj)
278 uint32_t data = 0, field;
279 int i;
280
281 + set_sys_state(env, env);
282 for (i = 0; i < 21; i++) {
283 env->cpucfg[i] = 0x0;
284 }
@@ -406,6 +407,7 @@ static void loongarch_la132_initfn(Object *obj)
407 uint32_t data = 0;
408 int i;
409
410 + set_sys_state(env, env);
411 for (i = 0; i < 21; i++) {
412 env->cpucfg[i] = 0x0;
413 }
target/loongarch/cpu.h
+13
@@ -317,6 +317,8 @@ typedef struct LoongArchBT {
317 #define CPU_VENDOR_LOONGSON "Loongson"
318 #define CPU_MODEL_3A5000 "3A5000"
319 #define CPU_MODEL_1C101 "1C101"
320 +struct CPUArchState;
321 +typedef struct CPUArchState CPUSysState;
322
323 typedef struct CPUArchState {
324 uint64_t gpr[32];
@@ -415,6 +417,7 @@ typedef struct CPUArchState {
417 AddressSpace *address_space_iocsr;
418 uint32_t mp_state;
419 #endif
420 + CPUSysState *sys_state;
421 } CPULoongArchState;
422
423 typedef struct LoongArchCPUTopo {
@@ -481,6 +484,16 @@ struct LoongArchCPUClass {
484 #define MMU_USER_IDX MMU_PLV_USER
485 #define MMU_DA_IDX 4
486
487 +static inline CPUSysState *env_sys(CPULoongArchState *env)
488 +{
489 + return env->sys_state;
490 +}
491 +
492 +static inline void set_sys_state(CPULoongArchState *env, CPUSysState *sys)
493 +{
494 + env->sys_state = sys;
495 +}
496 +
497 static inline bool is_la64(CPULoongArchState *env)
498 {
499 return FIELD_EX32(env->cpucfg[1], CPUCFG1, ARCH) == CPUCFG1_ARCH_LA64;