Skip to contentSkip to conversation

target-mips: use VMState for MIPS CPU save and load

RFC PATCH New Leon Alrae 1 participant 1 message Jan 28, 2015

lore
Share & tools
lore

Leon Alrae

author
#0 lore raw

RFC PATCH 1/1 target-mips: use VMState for MIPS CPU save and load

Convert MIPS CPU to use VMState. The saved fields are the same as before, with one exception -- for FPU actually MSA vector registers are saved. This is because FP registers are mapped on the MSA vector registers.

---
Hi,

This is a first cut of MIPS CPU state described using VMStateDescription. After I introduced a dumb bug where a new register in cpu_save was on a different position than in cpu_load which broke snapshotting, I felt even more encouraged to port MIPS CPU to use VMStateDescription.

I'm not very familiar with VMState yet, therefore I would like to get your feedback whether the new structure makes sense.

Thanks,
Leon

---
 target-mips/cpu-qom.h |   4 +
 target-mips/cpu.c     |   1 +
 target-mips/cpu.h     |   2 -
 target-mips/machine.c | 527 ++++++++++++++++++++++----------------------------
 4 files changed, 231 insertions(+), 303 deletions(-)
target-mips/cpu-qom.h +4 -0
index 2ffc1bf..4d6f9de 100644
@@ -74,6 +74,10 @@ static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env)
 
 #define ENV_OFFSET offsetof(MIPSCPU, env)
 
+#ifndef CONFIG_USER_ONLY
+extern const struct VMStateDescription vmstate_mips_cpu;
+#endif
+
 void mips_cpu_do_interrupt(CPUState *cpu);
 bool mips_cpu_exec_interrupt(CPUState *cpu, int int_req);
 void mips_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
target-mips/cpu.c +1 -0
index 98dc94e..cbdc463 100644
@@ -148,6 +148,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *data)
     cc->do_unassigned_access = mips_cpu_unassigned_access;
     cc->do_unaligned_access = mips_cpu_do_unaligned_access;
     cc->get_phys_page_debug = mips_cpu_get_phys_page_debug;
+    dc->vmsd = &vmstate_mips_cpu;
 #endif
 
     cc->gdb_num_core_regs = 73;
target-mips/cpu.h +0 -2
index 5ea61bc..59a2373 100644
@@ -614,8 +614,6 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 extern void cpu_wrdsp(uint32_t rs, uint32_t mask_num, CPUMIPSState *env);
 extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env);
 
-#define CPU_SAVE_VERSION 5
-
 /* MMU modes definitions. We carefully match the indices with our
    hflags layout. */
 #define MMU_MODE0_SUFFIX _kernel
target-mips/machine.c +226 -301

565 lines not on this page · raw message

Signature · 1 line
2.1.0