Skip to contentSkip to conversation

VMState port of all cpus

PATCH Superseded Juan Quintela 1 participant 29 messages Oct 26, 2011 Kbuild

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover VMState port of all cpus

Hi

[v2] Changes since v1

- preserve arm comment that was missing (pbrook)
- add copyright notice to the files that were empty
- new patches:
* fix formating for i386
* remove unneeded includes
* rename machine.c to vmstate.c

Later, Juan.

[v1]

This series port all cpus to use vmstate.
- 1st patch is a fix of vmstate.
- I discussed the arm changes over irc with Peter, he agreed that some simplification could be good, but he didn't saw the patches O:-)
- mips: no pci chipset has been ported, so migration don't work there. I have embedded a couple of structs to improve vmstate checking. Notice that they were always allocated, so there shouldn't be any problem.
- sparc: I changed the format a little bit to be able to use normal arrays.
- sparc: If we always send the whole register windows, we don't need VMSTATE_VARRAY_MULTIPLY. As that array is quite big (520 elements), I am not sure what is best.
- cpsr_vmstate on arm: I am not sure if I could "abuse" uncached_cpsr for that purpose?

I have only tested on x86, for the rest, I double checked, but it is possible that I missed something. I expect all patches to be integrated by Anthony in one go. Architecture maintainers are CC'd for an ACK/NACK/comments.

Please, review.

PD. Is there an easy way of creating this "CC" list of mail addresses,
or the only way is to edit comments and write it by hand as I did?

Juan Quintela (28):
vmstate: Fix VMSTATE_VARRAY_UINT32
vmstate: Simplify test for CPU_SAVE_VERSION
vmstate: make all architectures export a way to migrate cpu's
vmstate: unicore32 don't support cpu migration
vmstate: use new cpu style for x86
vmstate: use new style for lm32 cpus
vmstate: make microblaze cpus not migrateable
vmstate: port cris cpu to vmstate
vmstate: machine.c is only compiled for !CONFIG_USER_ONLY
vmstate: introduce float32 arrays
vmstate: introduce float64 arrays
vmstate: Introduce VMSTATE_STRUCT_VARRAY_INT32_TEST
vmstate: port ppc cpu
vmstate: introduce VMSTATE_VARRAY_MULTIPLY
vmstate: define vmstate_info_uinttls
vmstate: port sparc cpu
vmstate: make incompatible change for sparc
mips_fulong2e: cpu vmstate already registered in cpu_exec_init
mips: make mvp an embedded struct instead of pointer
mips: make tlb an embedded struct instead of a pointer
mips: bump migration version to 4
vmstate: port mips cpu
arm: save always 32 fpu registers
vmstate: port arm cpu
vmstate: all cpus converted
vmstate: fix vmstate formating for i386
vmstate: remove unneeded includes from target-*/machine.c
vmstate: rename machine.c to vmstate.c

 Makefile.target                        |    2 +-
 exec.c                                 |    7 +-
 hw/hw.h                                |   58 +++++--
 hw/mips_fulong2e.c                     |    1 -
 hw/mips_malta.c                        |    4 +-
 hw/mips_timer.c                        |    2 +-
 hw/sun4u.c                             |   20 --
 qemu-common.h                          |    4 -
 savevm.c                               |   68 +++++++
 target-alpha/{machine.c => vmstate.c}  |   13 +--
 target-arm/cpu.h                       |    5 +-
 target-arm/machine.c                   |  225 -----------------------
 target-arm/vmstate.c                   |  173 ++++++++++++++++++
 target-cris/cpu.h                      |   13 +-
 target-cris/machine.c                  |   90 ---------
 target-cris/vmstate.c                  |   59 ++++++
 target-i386/cpu.h                      |    2 -
 target-i386/{machine.c => vmstate.c}   |   36 +---
 target-lm32/cpu.h                      |    2 -
 target-lm32/{machine.c => vmstate.c}   |   17 +--
 target-m68k/vmstate.c                  |   21 +++
 target-microblaze/cpu.h                |    2 -
 target-microblaze/machine.c            |   11 --
 target-microblaze/vmstate.c            |   21 +++
 target-mips/cpu.h                      |   11 +-
 target-mips/helper.c                   |   30 ++--
 target-mips/machine.c                  |  308 --------------------------------
 target-mips/op_helper.c                |   70 ++++----
 target-mips/translate.c                |   22 ++-
 target-mips/translate_init.c           |   36 ++--
 target-mips/vmstate.c                  |  196 ++++++++++++++++++++
 target-ppc/cpu.h                       |    5 +-
 target-ppc/machine.c                   |  181 -------------------
 target-ppc/vmstate.c                   |  100 ++++++++++
 target-s390x/{machine.c => vmstate.c}  |   14 +-
 target-sh4/vmstate.c                   |   21 +++
 target-sparc/cpu.h                     |    9 +-
 target-sparc/machine.c                 |  225 -----------------------
 target-sparc/vmstate.c                 |  145 +++++++++++++++
 target-unicore32/cpu.h                 |    2 -
 target-xtensa/{machine.c => vmstate.c} |   14 +-
 41 files changed, 988 insertions(+), 1257 deletions(-)
 rename target-alpha/{machine.c => vmstate.c} (88%)
 delete mode 100644 target-arm/machine.c
 create mode 100644 target-arm/vmstate.c
 delete mode 100644 target-cris/machine.c
 create mode 100644 target-cris/vmstate.c
 rename target-i386/{machine.c => vmstate.c} (94%)
 rename target-lm32/{machine.c => vmstate.c} (61%)
 delete mode 100644 target-m68k/machine.c
 create mode 100644 target-m68k/vmstate.c
 delete mode 100644 target-microblaze/machine.c
 create mode 100644 target-microblaze/vmstate.c
 delete mode 100644 target-mips/machine.c
 create mode 100644 target-mips/vmstate.c
 delete mode 100644 target-ppc/machine.c
 create mode 100644 target-ppc/vmstate.c
 rename target-s390x/{machine.c => vmstate.c} (79%)
 delete mode 100644 target-sh4/machine.c
 create mode 100644 target-sh4/vmstate.c
 delete mode 100644 target-sparc/machine.c
 create mode 100644 target-sparc/vmstate.c
 rename target-xtensa/{machine.c => vmstate.c} (88%)
Signature · 1 line
1.7.6.4
#1 lore raw

PATCH v2 1/28 vmstate: Fix VMSTATE_VARRAY_UINT32

We didn't saved elemnts with that size (brown paper bag for me).

---
 savevm.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
savevm.c +2 -0
index f01838f..557eba4 100644
@@ -1457,6 +1457,8 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
                 n_elems = field->num;
             } else if (field->flags & VMS_VARRAY_INT32) {
                 n_elems = *(int32_t *)(opaque+field->num_offset);
+            } else if (field->flags & VMS_VARRAY_UINT32) {
+                n_elems = *(uint32_t *)(opaque+field->num_offset);
             } else if (field->flags & VMS_VARRAY_UINT16) {
                 n_elems = *(uint16_t *)(opaque+field->num_offset);
             } else if (field->flags & VMS_VARRAY_UINT8) {
Signature · 1 line
1.7.6.4
#2 lore raw

PATCH v2 2/28 vmstate: Simplify test for CPU_SAVE_VERSION

In reply to Juan Quintela

Some cpu's definitions define CPU_SAVE_VERSION, others not, but they have defined cpu_save/load.

---
 exec.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
exec.c +4 -2
index 9dc4edb..165cfe8 100644
@@ -591,7 +591,7 @@ void cpu_exec_init_all(void)
 #endif
 }
 
-#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
 
 static int cpu_common_post_load(void *opaque, int version_id)
 {
@@ -658,11 +658,13 @@ void cpu_exec_init(CPUState *env)
 #if defined(CONFIG_USER_ONLY)
     cpu_list_unlock();
 #endif
-#if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY)
+#if !defined(CONFIG_USER_ONLY)
     vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env);
+#if defined(CPU_SAVE_VERSION)
     register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
                     cpu_save, cpu_load, env);
 #endif
+#endif
 }
 
 /* Allocate a new translation block. Flush the translation buffer if
Signature · 1 line
1.7.6.4
#3 lore raw

PATCH v2 3/28 vmstate: make all architectures export a way to migrate cpu's

In reply to Juan Quintela

This makes several changes:
- exports VMStateDescription vmstate_cpu non-static.
- makes sure that every cpu has a vmstate_cpu or cpu_save/load defined
- for the architecture that had nothing, it just register the cpu as unmigratable.
- Depending on CPU_SAVE_VERSION we register old/new migration style
- Add copyrights to the new files

---
 exec.c                  |    2 ++
 hw/hw.h                 |    2 ++
 target-alpha/machine.c  |   12 +-----------
 target-i386/machine.c   |    2 +-
 target-lm32/machine.c   |    2 +-
 target-m68k/machine.c   |   21 +++++++++++++++++++++
 target-s390x/machine.c  |   14 ++++++--------
 target-sh4/machine.c    |   21 +++++++++++++++++++++
 target-xtensa/machine.c |   14 ++++++--------
 9 files changed, 61 insertions(+), 29 deletions(-)
exec.c +2 -0
index 165cfe8..09f3f01 100644
@@ -663,6 +663,8 @@ void cpu_exec_init(CPUState *env)
 #if defined(CPU_SAVE_VERSION)
     register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
                     cpu_save, cpu_load, env);
+#else
+    vmstate_register(NULL, cpu_index, &vmstate_cpu, env);
 #endif
 #endif
 }
hw/hw.h +2 -0
index ed20f5a..0f0200a 100644
@@ -359,6 +359,8 @@ extern const VMStateInfo vmstate_info_ptimer;
 extern const VMStateInfo vmstate_info_buffer;
 extern const VMStateInfo vmstate_info_unused_buffer;
 
+extern const VMStateDescription vmstate_cpu;
+
 #define type_check_array(t1,t2,n) ((t1(*)[n])0 - (t2*)0)
 #define type_check_pointer(t1,t2) ((t1**)0 - (t2*)0)
 
target-alpha/machine.c +1 -11
index 76d70d9..8d32d7c 100644
@@ -68,20 +68,10 @@ static VMStateField vmstate_cpu_fields[] = {
     VMSTATE_END_OF_LIST()
 };
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
     .fields = vmstate_cpu_fields,
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
-}
target-i386/machine.c +1 -1
index 25fa97d..54f5643 100644
@@ -310,7 +310,7 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
     }
 };
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = CPU_SAVE_VERSION,
     .minimum_version_id = 3,
target-lm32/machine.c +1 -1
index 70ca52a..9014a9f 100644
@@ -1,7 +1,7 @@
 #include "hw/hw.h"
 #include "hw/boards.h"
 
-static const VMStateDescription vmstate_cpu = {
+const VMStateDescription vmstate_cpu = {
     .name = "cpu",
     .version_id = CPU_SAVE_VERSION,
     .minimum_version_id = 1,
target-m68k/machine.c +21 -0
index e69de29..f2e095f 100644
@@ -0,0 +1,21 @@
+/*
+ * Migration support for m68k cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include "hw/hw.h"
+
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
+
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
target-s390x/machine.c +6 -8
index 3e79be6..5a7b219 100644
@@ -18,13 +18,11 @@
  */
 
 #include "hw/hw.h"
-#include "hw/boards.h"
 
-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
 
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return 0;
-}
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
target-sh4/machine.c +21 -0
index e69de29..d0a0d48 100644
@@ -0,0 +1,21 @@
+/*
+ * Migration support for sh4 cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+#include "hw/hw.h"
+
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
+
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
target-xtensa/machine.c +6 -8
index ddeffb2..3f98330 100644
@@ -26,13 +26,11 @@
  */
 
 #include "hw/hw.h"
-#include "hw/boards.h"
 
-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
 
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return 0;
-}
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
Signature · 1 line
1.7.6.4
#4 lore raw

PATCH v2 4/28 vmstate: unicore32 don't support cpu migration

In reply to Juan Quintela
---
 target-unicore32/cpu.h |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
target-unicore32/cpu.h +0 -2
index b4e72cf..5632272 100644
@@ -132,8 +132,6 @@ int uc32_cpu_signal_handler(int host_signum, void *pinfo, void *puc);
 int uc32_cpu_handle_mmu_fault(CPUState *env, target_ulong address, int rw,
                               int mmu_idx);
 
-#define CPU_SAVE_VERSION 2
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
Signature · 1 line
1.7.6.4
#5 lore raw

PATCH v2 5/28 vmstate: use new cpu style for x86

In reply to Juan Quintela
---
 target-i386/cpu.h     |    2 --
 target-i386/machine.c |   12 +-----------
 2 files changed, 1 insertions(+), 13 deletions(-)
target-i386/cpu.h +0 -2
index a973f2e..ef6f9f4 100644
@@ -949,8 +949,6 @@ uint64_t cpu_get_tsc(CPUX86State *env);
 #define cpu_list_id x86_cpu_list
 #define cpudef_setup	x86_cpudef_setup
 
-#define CPU_SAVE_VERSION 13
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
target-i386/machine.c +1 -11
index 54f5643..0ecbfe9 100644
@@ -312,7 +312,7 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
 
 const VMStateDescription vmstate_cpu = {
     .name = "cpu",
-    .version_id = CPU_SAVE_VERSION,
+    .version_id = 13,
     .minimum_version_id = 3,
     .minimum_version_id_old = 3,
     .pre_save = cpu_pre_save,
@@ -426,13 +426,3 @@ const VMStateDescription vmstate_cpu = {
         }
     }
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
-}
Signature · 1 line
1.7.6.4
#6 lore raw

PATCH v2 6/28 vmstate: use new style for lm32 cpus

In reply to Juan Quintela
---
 target-lm32/cpu.h     |    2 --
 target-lm32/machine.c |   14 ++------------
 2 files changed, 2 insertions(+), 14 deletions(-)
target-lm32/cpu.h +0 -2
index 037ef52..bd37af8 100644
@@ -202,8 +202,6 @@ void cpu_lm32_set_phys_msb_ignore(CPUState *env, int value);
 #define cpu_gen_code cpu_lm32_gen_code
 #define cpu_signal_handler cpu_lm32_signal_handler
 
-#define CPU_SAVE_VERSION 1
-
 int cpu_lm32_handle_mmu_fault(CPUState *env, target_ulong address, int rw,
                               int mmu_idx);
 #define cpu_handle_mmu_fault cpu_lm32_handle_mmu_fault
target-lm32/machine.c +2 -12
index 9014a9f..c31b744 100644
@@ -3,10 +3,10 @@
 
 const VMStateDescription vmstate_cpu = {
     .name = "cpu",
-    .version_id = CPU_SAVE_VERSION,
+    .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField[]) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32_ARRAY(regs, CPUState, 32),
         VMSTATE_UINT32(pc, CPUState),
         VMSTATE_UINT32(ie, CPUState),
@@ -21,13 +21,3 @@ const VMStateDescription vmstate_cpu = {
         VMSTATE_END_OF_LIST()
     }
 };
-
-void cpu_save(QEMUFile *f, void *opaque)
-{
-    vmstate_save_state(f, &vmstate_cpu, opaque);
-}
-
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return vmstate_load_state(f, &vmstate_cpu, opaque, version_id);
-}
Signature · 1 line
1.7.6.4
#7 lore raw

PATCH v2 7/28 vmstate: make microblaze cpus not migrateable

In reply to Juan Quintela
---
 target-microblaze/cpu.h     |    2 --
 target-microblaze/machine.c |   26 ++++++++++++++++++--------
 2 files changed, 18 insertions(+), 10 deletions(-)
target-microblaze/cpu.h +0 -2
index 3530286..fc5c098 100644
@@ -287,8 +287,6 @@ enum {
 #define cpu_gen_code cpu_mb_gen_code
 #define cpu_signal_handler cpu_mb_signal_handler
 
-#define CPU_SAVE_VERSION 1
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _nommu
 #define MMU_MODE1_SUFFIX _kernel
target-microblaze/machine.c +18 -8
index 1be1c35..e110a93 100644
@@ -1,11 +1,21 @@
+/*
+ * Migration support for microblaze cpus
+ *
+ * Copyright (C) 2011 Red Hat, Inc.
+ *
+ * Author(s):
+ *  Juan Quintela <[email protected]>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
 #include "hw/hw.h"
-#include "hw/boards.h"
 
-void cpu_save(QEMUFile *f, void *opaque)
-{
-}
+/* To make this architecture migratable, we need to define cpu state
+   here.  Other things need to be done elsewhere */
 
-int cpu_load(QEMUFile *f, void *opaque, int version_id)
-{
-    return 0;
-}
+const VMStateDescription vmstate_cpu = {
+    .name = "cpu",
+    .unmigratable = 1,
+};
Signature · 1 line
1.7.6.4
#8 lore raw

PATCH v2 8/28 vmstate: port cris cpu to vmstate

In reply to Juan Quintela

Have to define TLBSet struct.
Multidimensional arrays in C are a mess, just unroll them.

---
 target-cris/cpu.h     |   13 ++---
 target-cris/machine.c |  138 +++++++++++++++++++------------------------------
 2 files changed, 60 insertions(+), 91 deletions(-)
target-cris/cpu.h +6 -7
index 8ae0ce3..2cec75c 100644
@@ -99,6 +99,11 @@
 
 #define NB_MMU_MODES 2
 
+typedef struct {
+    uint32_t hi;
+    uint32_t lo;
+} TLBSet;
+
 typedef struct CPUCRISState {
 	uint32_t regs[16];
 	/* P0 - P15 are referred to as special registers in the docs.  */
@@ -152,11 +157,7 @@ typedef struct CPUCRISState {
 	 *
 	 * One for I and another for D.
 	 */
-	struct
-	{
-		uint32_t hi;
-		uint32_t lo;
-	} tlbsets[2][4][16];
+	TLBSet tlbsets[2][4][16];
 
 	CPU_COMMON
 
@@ -214,8 +215,6 @@ enum {
 #define cpu_gen_code cpu_cris_gen_code
 #define cpu_signal_handler cpu_cris_signal_handler
 
-#define CPU_SAVE_VERSION 1
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
target-cris/machine.c +54 -84

144 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#9 lore raw

PATCH v2 9/28 vmstate: machine.c is only compiled for !CONFIG_USER_ONLY

In reply to Juan Quintela
---
 target-ppc/machine.c |    8 --------
 1 files changed, 0 insertions(+), 8 deletions(-)
target-ppc/machine.c +0 -8
index 1c40d43..226b4a5 100644
@@ -32,7 +32,6 @@ void cpu_save(QEMUFile *f, void *opaque)
     }
     qemu_put_be32s(f, &env->fpscr);
     qemu_put_sbe32s(f, &env->access_type);
-#if !defined(CONFIG_USER_ONLY)
 #if defined(TARGET_PPC64)
     qemu_put_betls(f, &env->asr);
     qemu_put_sbe32s(f, &env->slb_nr);
@@ -62,7 +61,6 @@ void cpu_save(QEMUFile *f, void *opaque)
     }
     for (i = 0; i < 4; i++)
         qemu_put_betls(f, &env->pb[i]);
-#endif
     for (i = 0; i < 1024; i++)
         qemu_put_betls(f, &env->spr[i]);
     qemu_put_be32s(f, &env->vscr);
@@ -72,7 +70,6 @@ void cpu_save(QEMUFile *f, void *opaque)
     qemu_put_be32s(f, &env->flags);
     qemu_put_sbe32s(f, &env->error_code);
     qemu_put_be32s(f, &env->pending_interrupts);
-#if !defined(CONFIG_USER_ONLY)
     qemu_put_be32s(f, &env->irq_input_state);
     for (i = 0; i < POWERPC_EXCP_NB; i++)
         qemu_put_betls(f, &env->excp_vectors[i]);
@@ -81,7 +78,6 @@ void cpu_save(QEMUFile *f, void *opaque)
     qemu_put_betls(f, &env->ivor_mask);
     qemu_put_betls(f, &env->ivpr_mask);
     qemu_put_betls(f, &env->hreset_vector);
-#endif
     qemu_put_betls(f, &env->nip);
     qemu_put_betls(f, &env->hflags);
     qemu_put_betls(f, &env->hflags_nmsr);
@@ -120,7 +116,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     }
     qemu_get_be32s(f, &env->fpscr);
     qemu_get_sbe32s(f, &env->access_type);
-#if !defined(CONFIG_USER_ONLY)
 #if defined(TARGET_PPC64)
     qemu_get_betls(f, &env->asr);
     qemu_get_sbe32s(f, &env->slb_nr);
@@ -150,7 +145,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     }
     for (i = 0; i < 4; i++)
         qemu_get_betls(f, &env->pb[i]);
-#endif
     for (i = 0; i < 1024; i++)
         qemu_get_betls(f, &env->spr[i]);
     ppc_store_sdr1(env, sdr1);
@@ -161,7 +155,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_be32s(f, &env->flags);
     qemu_get_sbe32s(f, &env->error_code);
     qemu_get_be32s(f, &env->pending_interrupts);
-#if !defined(CONFIG_USER_ONLY)
     qemu_get_be32s(f, &env->irq_input_state);
     for (i = 0; i < POWERPC_EXCP_NB; i++)
         qemu_get_betls(f, &env->excp_vectors[i]);
@@ -170,7 +163,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_betls(f, &env->ivor_mask);
     qemu_get_betls(f, &env->ivpr_mask);
     qemu_get_betls(f, &env->hreset_vector);
-#endif
     qemu_get_betls(f, &env->nip);
     qemu_get_betls(f, &env->hflags);
     qemu_get_betls(f, &env->hflags_nmsr);
Signature · 1 line
1.7.6.4
#10 lore raw

PATCH v2 10/28 vmstate: introduce float32 arrays

In reply to Juan Quintela
---
 hw/hw.h  |    5 +++++
 savevm.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
hw/hw.h +5 -0
index 0f0200a..014cdc1 100644
@@ -354,6 +354,8 @@ extern const VMStateInfo vmstate_info_uint16;
 extern const VMStateInfo vmstate_info_uint32;
 extern const VMStateInfo vmstate_info_uint64;
 
+extern const VMStateInfo vmstate_info_float32;
+
 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_ptimer;
 extern const VMStateInfo vmstate_info_buffer;
@@ -875,6 +877,9 @@ extern const VMStateDescription vmstate_hid_ptr_device;
 #define VMSTATE_INT64_ARRAY(_f, _s, _n)                               \
     VMSTATE_INT64_ARRAY_V(_f, _s, _n, 0)
 
+#define VMSTATE_FLOAT32_ARRAY(_f, _s, _n)                             \
+    VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
 
savevm.c +30 -0
index 557eba4..cd0178c 100644
@@ -1027,6 +1027,36 @@ const VMStateInfo vmstate_info_uint16_equal = {
     .put  = put_uint16,
 };
 
+/* 32 bit float */
+
+typedef union {
+    float32 f;
+    uint32_t i;
+} VMStateFloat32;
+
+static int get_float32(QEMUFile *f, void *pv, size_t size)
+{
+    float32 *v = pv;
+    VMStateFloat32 u;
+    qemu_get_be32s(f, &u.i);
+    *v = u.f;
+    return 0;
+}
+
+static void put_float32(QEMUFile *f, void *pv, size_t size)
+{
+    float32 *v = pv;
+    VMStateFloat32 u;
+    u.f = *v;
+    qemu_put_be32s(f, &u.i);
+}
+
+const VMStateInfo vmstate_info_float32 = {
+    .name = "float32",
+    .get  = get_float32,
+    .put  = put_float32,
+};
+
 /* timers  */
 
 static int get_timer(QEMUFile *f, void *pv, size_t size)
Signature · 1 line
1.7.6.4
#11 lore raw

PATCH v2 11/28 vmstate: introduce float64 arrays

In reply to Juan Quintela
---
 hw/hw.h  |    4 ++++
 savevm.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
hw/hw.h +4 -0
index 014cdc1..3044cec 100644
@@ -355,6 +355,7 @@ extern const VMStateInfo vmstate_info_uint32;
 extern const VMStateInfo vmstate_info_uint64;
 
 extern const VMStateInfo vmstate_info_float32;
+extern const VMStateInfo vmstate_info_float64;
 
 extern const VMStateInfo vmstate_info_timer;
 extern const VMStateInfo vmstate_info_ptimer;
@@ -880,6 +881,9 @@ extern const VMStateDescription vmstate_hid_ptr_device;
 #define VMSTATE_FLOAT32_ARRAY(_f, _s, _n)                             \
     VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float32, float32)
 
+#define VMSTATE_FLOAT64_ARRAY(_f, _s, _n)                             \
+    VMSTATE_ARRAY(_f, _s, _n, 0, vmstate_info_float64, float64)
+
 #define VMSTATE_BUFFER_V(_f, _s, _v)                                  \
     VMSTATE_STATIC_BUFFER(_f, _s, _v, NULL, 0, sizeof(typeof_field(_s, _f)))
 
savevm.c +30 -0
index cd0178c..2e191ad 100644
@@ -1057,6 +1057,36 @@ const VMStateInfo vmstate_info_float32 = {
     .put  = put_float32,
 };
 
+/* 64 bit float */
+
+typedef union {
+    float64 d;
+    uint64_t l;
+} VMStateFloat64;
+
+static int get_float64(QEMUFile *f, void *pv, size_t size)
+{
+    float64 *v = pv;
+    VMStateFloat64 u;
+    qemu_get_be64s(f, &u.l);
+    *v = u.d;
+    return 0;
+}
+
+static void put_float64(QEMUFile *f, void *pv, size_t size)
+{
+    float64 *v = pv;
+    VMStateFloat64 u;
+    u.d = *v;
+    qemu_put_be64s(f, &u.l);
+}
+
+const VMStateInfo vmstate_info_float64 = {
+    .name = "float64",
+    .get  = get_float64,
+    .put  = put_float64,
+};
+
 /* timers  */
 
 static int get_timer(QEMUFile *f, void *pv, size_t size)
Signature · 1 line
1.7.6.4
#12 lore raw

PATCH v2 12/28 vmstate: Introduce VMSTATE_STRUCT_VARRAY_INT32_TEST

In reply to Juan Quintela

We have an array of structs whose size is an int32 in the same struct that depends on a test value to know if it is there or not.

---
 hw/hw.h |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
hw/hw.h +10 -0
index 3044cec..798732f 100644
@@ -533,6 +533,16 @@ extern const VMStateDescription vmstate_cpu;
     .offset     = offsetof(_state, _field),                          \
 }
 
+#define VMSTATE_STRUCT_VARRAY_INT32_TEST(_field, _state, _field_num, _test, _vmsd, _type) { \
+    .name       = (stringify(_field)),                               \
+    .num_offset = vmstate_offset_value(_state, _field_num, int32_t), \
+    .vmsd       = &(_vmsd),                                          \
+    .field_exists = (_test),                                         \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_STRUCT|VMS_VARRAY_INT32,                       \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_STRUCT_VARRAY_POINTER_INT32(_field, _state, _field_num, _vmsd, _type) { \
     .name       = (stringify(_field)),                               \
     .version_id = 0,                                                 \
Signature · 1 line
1.7.6.4
#13 lore raw

PATCH v2 13/28 vmstate: port ppc cpu

In reply to Juan Quintela

Added sdr1_vmstate because storing the value requires calling ppc_store_sdr1(). The position when the function is called also changes (I think it is save).

---
 target-ppc/cpu.h     |    5 +-
 target-ppc/machine.c |  245 ++++++++++++++++++--------------------------------
 2 files changed, 90 insertions(+), 160 deletions(-)
target-ppc/cpu.h +3 -2
index 3f77e30..89bb69d 100644
@@ -1029,6 +1029,9 @@ struct CPUPPCState {
      */
     uint8_t fit_period[4];
     uint8_t wdt_period[4];
+
+    /* Fields needed as intermediate for vmstate */
+    target_ulong sdr1_vmstate;
 };
 
 #define SET_FIT_PERIOD(a_, b_, c_, d_)          \
@@ -1183,8 +1186,6 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, uint32_t val);
 #define cpu_signal_handler cpu_ppc_signal_handler
 #define cpu_list ppc_cpu_list
 
-#define CPU_SAVE_VERSION 4
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _user
 #define MMU_MODE1_SUFFIX _kernel
target-ppc/machine.c +87 -158

259 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#14 lore raw

PATCH v2 14/28 vmstate: introduce VMSTATE_VARRAY_MULTIPLY

In reply to Juan Quintela

This allows to sent a partial array where the size is another structure field multiplied by a constant.

---
 hw/hw.h  |   35 +++++++++++++++++++++++------------
 savevm.c |    6 ++++++
 2 files changed, 29 insertions(+), 12 deletions(-)
hw/hw.h +23 -12
index 798732f..ab17bb6 100644
@@ -288,18 +288,19 @@ struct VMStateInfo {
 };
 
 enum VMStateFlags {
-    VMS_SINGLE           = 0x001,
-    VMS_POINTER          = 0x002,
-    VMS_ARRAY            = 0x004,
-    VMS_STRUCT           = 0x008,
-    VMS_VARRAY_INT32     = 0x010,  /* Array with size in int32_t field*/
-    VMS_BUFFER           = 0x020,  /* static sized buffer */
-    VMS_ARRAY_OF_POINTER = 0x040,
-    VMS_VARRAY_UINT16    = 0x080,  /* Array with size in uint16_t field */
-    VMS_VBUFFER          = 0x100,  /* Buffer with size in int32_t field */
-    VMS_MULTIPLY         = 0x200,  /* multiply "size" field by field_size */
-    VMS_VARRAY_UINT8     = 0x400,  /* Array with size in uint8_t field*/
-    VMS_VARRAY_UINT32    = 0x800,  /* Array with size in uint32_t field*/
+    VMS_SINGLE            = 0x0001,
+    VMS_POINTER           = 0x0002,
+    VMS_ARRAY             = 0x0004,
+    VMS_STRUCT            = 0x0008,
+    VMS_VARRAY_INT32      = 0x0010,  /* Array with size in int32_t field*/
+    VMS_BUFFER            = 0x0020,  /* static sized buffer */
+    VMS_ARRAY_OF_POINTER  = 0x0040,
+    VMS_VARRAY_UINT16     = 0x0080,  /* Array with size in uint16_t field */
+    VMS_VBUFFER           = 0x0100,  /* Buffer with size in int32_t field */
+    VMS_MULTIPLY          = 0x0200,  /* multiply "size" field by field_size */
+    VMS_VARRAY_UINT8      = 0x0400,  /* Array with size in uint8_t field*/
+    VMS_VARRAY_UINT32     = 0x0800,  /* Array with size in uint32_t field*/
+    VMS_MULTIPLY_ELEMENTS = 0x1000,  /* multiply "size" field by field_size */
 };
 
 typedef struct {
@@ -424,6 +425,16 @@ extern const VMStateDescription vmstate_cpu;
     .offset     = vmstate_offset_array(_state, _field, _type, _num), \
 }
 
+#define VMSTATE_VARRAY_MULTIPLY(_field, _state, _field_num, _multiply, _info, _type) { \
+    .name       = (stringify(_field)),                               \
+    .num_offset = vmstate_offset_value(_state, _field_num, uint32_t),\
+    .num        = (_multiply),                                       \
+    .info       = &(_info),                                          \
+    .size       = sizeof(_type),                                     \
+    .flags      = VMS_VARRAY_UINT32|VMS_MULTIPLY_ELEMENTS,           \
+    .offset     = offsetof(_state, _field),                          \
+}
+
 #define VMSTATE_ARRAY_TEST(_field, _state, _num, _test, _info, _type) {\
     .name         = (stringify(_field)),                              \
     .field_exists = (_test),                                          \
savevm.c +6 -0
index 2e191ad..8ef46a1 100644
@@ -1460,6 +1460,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd,
             } else if (field->flags & VMS_VARRAY_UINT8) {
                 n_elems = *(uint8_t *)(opaque+field->num_offset);
             }
+            if (field->flags & VMS_MULTIPLY_ELEMENTS) {
+                    n_elems *= field->num;
+            }
             if (field->flags & VMS_POINTER) {
                 base_addr = *(void **)base_addr + field->start;
             }
@@ -1524,6 +1527,9 @@ void vmstate_save_state(QEMUFile *f, const VMStateDescription *vmsd,
             } else if (field->flags & VMS_VARRAY_UINT8) {
                 n_elems = *(uint8_t *)(opaque+field->num_offset);
             }
+            if (field->flags & VMS_MULTIPLY_ELEMENTS) {
+                    n_elems *= field->num;
+            }
             if (field->flags & VMS_POINTER) {
                 base_addr = *(void **)base_addr + field->start;
             }
Signature · 1 line
1.7.6.4
#15 lore raw

PATCH v2 15/28 vmstate: define vmstate_info_uinttls

In reply to Juan Quintela

We are going to define arrays of this type, so we need the integer type.

---
 hw/hw.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
hw/hw.h +2 -0
index ab17bb6..5d4383c 100644
@@ -947,11 +947,13 @@ extern const VMStateDescription vmstate_hid_ptr_device;
     VMSTATE_UINT64_V(_f, _s, _v)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
     VMSTATE_UINT64_ARRAY_V(_f, _s, _n, _v)
+#define vmstate_info_uinttls vmstate_info_uint64
 #else
 #define VMSTATE_UINTTL_V(_f, _s, _v)                                  \
     VMSTATE_UINT32_V(_f, _s, _v)
 #define VMSTATE_UINTTL_ARRAY_V(_f, _s, _n, _v)                        \
     VMSTATE_UINT32_ARRAY_V(_f, _s, _n, _v)
+#define vmstate_info_uinttls vmstate_info_uint32
 #endif
 #define VMSTATE_UINTTL(_f, _s)                                        \
     VMSTATE_UINTTL_V(_f, _s, 0)
Signature · 1 line
1.7.6.4
#16 lore raw

PATCH v2 16/28 vmstate: port sparc cpu

In reply to Juan Quintela
---
 hw/sun4u.c             |   20 --
 target-sparc/cpu.h     |    9 +-
 target-sparc/machine.c |  482 ++++++++++++++++++++++++++++--------------------
 3 files changed, 283 insertions(+), 228 deletions(-)
hw/sun4u.c +0 -20
index eaaefe3..b0f671d 100644
@@ -324,26 +324,6 @@ typedef struct ResetData {
     uint64_t prom_addr;
 } ResetData;
 
-void cpu_put_timer(QEMUFile *f, CPUTimer *s)
-{
-    qemu_put_be32s(f, &s->frequency);
-    qemu_put_be32s(f, &s->disabled);
-    qemu_put_be64s(f, &s->disabled_mask);
-    qemu_put_sbe64s(f, &s->clock_offset);
-
-    qemu_put_timer(f, s->qtimer);
-}
-
-void cpu_get_timer(QEMUFile *f, CPUTimer *s)
-{
-    qemu_get_be32s(f, &s->frequency);
-    qemu_get_be32s(f, &s->disabled);
-    qemu_get_be64s(f, &s->disabled_mask);
-    qemu_get_sbe64s(f, &s->clock_offset);
-
-    qemu_get_timer(f, s->qtimer);
-}
-
 static CPUTimer* cpu_timer_create(const char* name, CPUState *env,
                                   QEMUBHFunc *cb, uint32_t frequency,
                                   uint64_t disabled_mask)
target-sparc/cpu.h +3 -6
index 6bf9275..27fbf4e 100644
@@ -352,10 +352,6 @@ struct CPUTimer
 
 typedef struct CPUTimer CPUTimer;
 
-struct QEMUFile;
-void cpu_put_timer(struct QEMUFile *f, CPUTimer *s);
-void cpu_get_timer(struct QEMUFile *f, CPUTimer *s);
-
 typedef struct CPUSPARCState {
     target_ulong gregs[8]; /* general registers */
     target_ulong *regwptr; /* pointer to current register window */
@@ -482,6 +478,9 @@ typedef struct CPUSPARCState {
 
     /* Leon3 cache control */
     uint32_t cache_control;
+
+    /* Fields needed as intermediate for vmstate */
+    uint32_t psr_vmstate;
 } CPUSPARCState;
 
 #ifndef NO_CPU_IO_DEFS
@@ -569,8 +568,6 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 #define cpu_signal_handler cpu_sparc_signal_handler
 #define cpu_list sparc_cpu_list
 
-#define CPU_SAVE_VERSION 7
-
 /* MMU modes definitions */
 #if defined (TARGET_SPARC64)
 #define MMU_USER_IDX   0
target-sparc/machine.c +280 -202

502 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#17 lore raw

PATCH v2 17/28 vmstate: make incompatible change for sparc

In reply to Juan Quintela

With this change, we sent arrays as arrays, making state description much simpler. The change is incompatible, but as far as I know, sparc don't care about migration compatibility beteween versions.

---
 target-sparc/machine.c |  172 +++---------------------------------------------
 1 files changed, 9 insertions(+), 163 deletions(-)
target-sparc/machine.c +9 -163
index 5ba098e..e3e57b5 100644
@@ -74,9 +74,9 @@ static int cpu_post_load(void *opaque, int version_id)
 
 const VMStateDescription vmstate_cpu = {
     .name = "cpu",
-    .version_id = 7,
-    .minimum_version_id = 7,
-    .minimum_version_id_old = 7,
+    .version_id = 8,
+    .minimum_version_id = 8,
+    .minimum_version_id_old = 8,
     .pre_save = cpu_pre_save,
     .post_load = cpu_post_load,
     .fields = (VMStateField[]) {
@@ -106,166 +106,12 @@ const VMStateDescription vmstate_cpu = {
         VMSTATE_UINT64_ARRAY(mmubpregs, CPUState, 4),
 #else
         VMSTATE_UINT64(lsu, CPUState),
-        VMSTATE_UINT64(immuregs[0], CPUState),
-        VMSTATE_UINT64(dmmuregs[0], CPUState),
-        VMSTATE_UINT64(immuregs[1], CPUState),
-        VMSTATE_UINT64(dmmuregs[1], CPUState),
-        VMSTATE_UINT64(immuregs[2], CPUState),
-        VMSTATE_UINT64(dmmuregs[2], CPUState),
-        VMSTATE_UINT64(immuregs[3], CPUState),
-        VMSTATE_UINT64(dmmuregs[3], CPUState),
-        VMSTATE_UINT64(immuregs[4], CPUState),
-        VMSTATE_UINT64(dmmuregs[4], CPUState),
-        VMSTATE_UINT64(immuregs[5], CPUState),
-        VMSTATE_UINT64(dmmuregs[5], CPUState),
-        VMSTATE_UINT64(immuregs[6], CPUState),
-        VMSTATE_UINT64(dmmuregs[6], CPUState),
-        VMSTATE_UINT64(immuregs[7], CPUState),
-        VMSTATE_UINT64(dmmuregs[7], CPUState),
-        VMSTATE_UINT64(immuregs[8], CPUState),
-        VMSTATE_UINT64(dmmuregs[8], CPUState),
-        VMSTATE_UINT64(immuregs[9], CPUState),
-        VMSTATE_UINT64(dmmuregs[9], CPUState),
-        VMSTATE_UINT64(immuregs[10], CPUState),
-        VMSTATE_UINT64(dmmuregs[10], CPUState),
-        VMSTATE_UINT64(immuregs[11], CPUState),
-        VMSTATE_UINT64(dmmuregs[11], CPUState),
-        VMSTATE_UINT64(immuregs[12], CPUState),
-        VMSTATE_UINT64(dmmuregs[12], CPUState),
-        VMSTATE_UINT64(immuregs[13], CPUState),
-        VMSTATE_UINT64(dmmuregs[13], CPUState),
-        VMSTATE_UINT64(immuregs[14], CPUState),
-        VMSTATE_UINT64(dmmuregs[14], CPUState),
-        VMSTATE_UINT64(immuregs[15], CPUState),
-        VMSTATE_UINT64(dmmuregs[15], CPUState),
-        VMSTATE_STRUCT(itlb[0], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[0], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[1], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[1], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[2], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[2], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[3], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[3], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[4], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[4], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[5], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[5], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[6], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[6], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[7], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[7], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[8], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[8], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[9], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[9], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[10], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[10], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[11], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[11], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[12], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[12], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[13], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[13], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[14], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[14], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[15], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[15], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[16], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[16], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[17], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[17], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[18], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[18], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[19], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[19], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[20], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[20], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[21], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[21], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[22], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[22], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[23], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[23], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[24], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[24], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[25], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[25], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[26], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[26], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[27], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[27], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[28], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[28], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[29], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[29], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[30], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[30], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[31], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[31], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[32], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[32], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[33], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[33], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[34], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[34], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[35], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[35], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[36], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[36], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[37], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[37], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[38], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[38], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[39], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[39], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[40], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[40], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[41], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[41], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[42], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[42], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[43], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[43], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[44], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[44], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[45], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[45], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[46], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[46], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[47], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[47], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[48], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[48], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[49], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[49], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[50], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[50], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[51], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[51], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[52], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[52], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[53], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[53], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[54], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[54], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[55], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[55], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[56], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[56], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[57], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[57], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[58], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[58], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[59], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[59], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[60], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[60], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[61], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[61], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[62], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[62], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(itlb[63], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
-        VMSTATE_STRUCT(dtlb[63], CPUState, 0, vmstate_tlb_entry, SparcTLBEntry),
+        VMSTATE_UINT64_ARRAY(immuregs, CPUState, 16),
+        VMSTATE_UINT64_ARRAY(dmmuregs, CPUState, 16),
+        VMSTATE_STRUCT_ARRAY(itlb, CPUState, 64, 0,
+                             vmstate_tlb_entry, SparcTLBEntry),
+        VMSTATE_STRUCT_ARRAY(dtlb, CPUState, 64, 0,
+                             vmstate_tlb_entry, SparcTLBEntry),
         VMSTATE_UINT32(mmu_version, CPUState),
         VMSTATE_STRUCT_ARRAY(ts, CPUState, MAXTL_MAX, 0,
                              vmstate_trap_state, trap_state),
Signature · 1 line
1.7.6.4
#18 lore raw

PATCH v2 18/28 mips_fulong2e: cpu vmstate already registered in cpu_exec_init

In reply to Juan Quintela

This is the second place that register cpu migration code, it is done in general in cpu_exec_init(), just remove this call.

---
 hw/mips_fulong2e.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
hw/mips_fulong2e.c +0 -1
index 04921c1..d96b7dc 100644
@@ -281,7 +281,6 @@ static void mips_fulong2e_init(ram_addr_t ram_size, const char *boot_device,
         exit(1);
     }
 
-    register_savevm(NULL, "cpu", 0, 3, cpu_save, cpu_load, env);
     qemu_register_reset(main_cpu_reset, env);
 
     /* fulong 2e has 256M ram. */
Signature · 1 line
1.7.6.4
#19 lore raw

PATCH v2 19/28 mips: make mvp an embedded struct instead of pointer

In reply to Juan Quintela

Adjust all callers.

---
 hw/mips_malta.c              |    4 ++--
 target-mips/cpu.h            |    4 ++--
 target-mips/machine.c        |   12 ++++++------
 target-mips/op_helper.c      |   30 +++++++++++++++++-------------
 target-mips/translate.c      |    6 +++---
 target-mips/translate_init.c |   14 ++++++--------
 6 files changed, 36 insertions(+), 34 deletions(-)
hw/mips_malta.c +2 -2
index bb49749..cd40e7b 100644
@@ -732,8 +732,8 @@ static int64_t load_kernel (void)
 
 static void malta_mips_config(CPUState *env)
 {
-    env->mvp->CP0_MVPConf0 |= ((smp_cpus - 1) << CP0MVPC0_PVPE) |
-                         ((smp_cpus * env->nr_threads - 1) << CP0MVPC0_PTC);
+    env->mvp.CP0_MVPConf0 |= ((smp_cpus - 1) << CP0MVPC0_PVPE) |
+                          ((smp_cpus * env->nr_threads - 1) << CP0MVPC0_PTC);
 }
 
 static void main_cpu_reset(void *opaque)
target-mips/cpu.h +2 -2
index 79e2558..e11865b 100644
@@ -473,7 +473,7 @@ struct CPUMIPSState {
 
     CPU_COMMON
 
-    CPUMIPSMVPContext *mvp;
+    CPUMIPSMVPContext mvp;
 #if !defined(CONFIG_USER_ONLY)
     CPUMIPSTLBContext *tlb;
 #endif
@@ -675,7 +675,7 @@ static inline int mips_vpe_active(CPUState *env)
     int active = 1;
 
     /* Check that the VPE is enabled.  */
-    if (!(env->mvp->CP0_MVPControl & (1 << CP0MVPCo_EVP))) {
+    if (!(env->mvp.CP0_MVPControl & (1 << CP0MVPCo_EVP))) {
         active = 0;
     }
     /* Check that the VPE is actived.  */
target-mips/machine.c +6 -6
index be72b36..8137488 100644
@@ -52,9 +52,9 @@ void cpu_save(QEMUFile *f, void *opaque)
     save_fpu(f, &env->active_fpu);
 
     /* Save MVP */
-    qemu_put_sbe32s(f, &env->mvp->CP0_MVPControl);
-    qemu_put_sbe32s(f, &env->mvp->CP0_MVPConf0);
-    qemu_put_sbe32s(f, &env->mvp->CP0_MVPConf1);
+    qemu_put_sbe32s(f, &env->mvp.CP0_MVPControl);
+    qemu_put_sbe32s(f, &env->mvp.CP0_MVPConf0);
+    qemu_put_sbe32s(f, &env->mvp.CP0_MVPConf1);
 
     /* Save TLB */
     qemu_put_be32s(f, &env->tlb->nb_tlb);
@@ -203,9 +203,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     load_fpu(f, &env->active_fpu);
 
     /* Load MVP */
-    qemu_get_sbe32s(f, &env->mvp->CP0_MVPControl);
-    qemu_get_sbe32s(f, &env->mvp->CP0_MVPConf0);
-    qemu_get_sbe32s(f, &env->mvp->CP0_MVPConf1);
+    qemu_get_sbe32s(f, &env->mvp.CP0_MVPControl);
+    qemu_get_sbe32s(f, &env->mvp.CP0_MVPConf0);
+    qemu_get_sbe32s(f, &env->mvp.CP0_MVPConf1);
 
     /* Load TLB */
     qemu_get_be32s(f, &env->tlb->nb_tlb);
target-mips/op_helper.c +17 -13
index c51b9cb..a5d095c 100644
@@ -909,17 +909,17 @@ static void sync_c0_entryhi(CPUState *cpu, int tc)
 /* CP0 helpers */
 target_ulong helper_mfc0_mvpcontrol (void)
 {
-    return env->mvp->CP0_MVPControl;
+    return env->mvp.CP0_MVPControl;
 }
 
 target_ulong helper_mfc0_mvpconf0 (void)
 {
-    return env->mvp->CP0_MVPConf0;
+    return env->mvp.CP0_MVPConf0;
 }
 
 target_ulong helper_mfc0_mvpconf1 (void)
 {
-    return env->mvp->CP0_MVPConf1;
+    return env->mvp.CP0_MVPConf1;
 }
 
 target_ulong helper_mfc0_random (void)
@@ -1172,13 +1172,14 @@ void helper_mtc0_mvpcontrol (target_ulong arg1)
     if (env->CP0_VPEConf0 & (1 << CP0VPEC0_MVP))
         mask |= (1 << CP0MVPCo_CPA) | (1 << CP0MVPCo_VPC) |
                 (1 << CP0MVPCo_EVP);
-    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
+    if (env->mvp.CP0_MVPControl & (1 << CP0MVPCo_VPC)) {
         mask |= (1 << CP0MVPCo_STLB);
-    newval = (env->mvp->CP0_MVPControl & ~mask) | (arg1 & mask);
+    }
+    newval = (env->mvp.CP0_MVPControl & ~mask) | (arg1 & mask);
 
     // TODO: Enable/disable shared TLB, enable/disable VPEs.
 
-    env->mvp->CP0_MVPControl = newval;
+    env->mvp.CP0_MVPControl = newval;
 }
 
 void helper_mtc0_vpecontrol (target_ulong arg1)
@@ -1266,9 +1267,10 @@ void helper_mtc0_vpeconf1 (target_ulong arg1)
     uint32_t mask = 0;
     uint32_t newval;
 
-    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
+    if (env->mvp.CP0_MVPControl & (1 << CP0MVPCo_VPC)) {
         mask |= (0xff << CP0VPEC1_NCX) | (0xff << CP0VPEC1_NCP2) |
                 (0xff << CP0VPEC1_NCP1);
+    }
     newval = (env->CP0_VPEConf1 & ~mask) | (arg1 & mask);
 
     /* UDI not implemented. */
@@ -1325,8 +1327,9 @@ void helper_mtc0_tcbind (target_ulong arg1)
     uint32_t mask = (1 << CP0TCBd_TBE);
     uint32_t newval;
 
-    if (env->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
+    if (env->mvp.CP0_MVPControl & (1 << CP0MVPCo_VPC)) {
         mask |= (1 << CP0TCBd_CurVPE);
+    }
     newval = (env->active_tc.CP0_TCBind & ~mask) | (arg1 & mask);
     env->active_tc.CP0_TCBind = newval;
 }
@@ -1338,8 +1341,9 @@ void helper_mttc0_tcbind (target_ulong arg1)
     uint32_t newval;
     CPUState *other = mips_cpu_map_tc(&other_tc);
 
-    if (other->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
+    if (other->mvp.CP0_MVPControl & (1 << CP0MVPCo_VPC)) {
         mask |= (1 << CP0TCBd_CurVPE);
+    }
     if (other_tc == other->current_tc) {
         newval = (other->active_tc.CP0_TCBind & ~mask) | (arg1 & mask);
         other->active_tc.CP0_TCBind = newval;
@@ -1910,12 +1914,12 @@ target_ulong helper_emt(void)
 target_ulong helper_dvpe(void)
 {
     CPUState *other_cpu = first_cpu;
-    target_ulong prev = env->mvp->CP0_MVPControl;
+    target_ulong prev = env->mvp.CP0_MVPControl;
 
     do {
         /* Turn off all VPEs except the one executing the dvpe.  */
         if (other_cpu != env) {
-            other_cpu->mvp->CP0_MVPControl &= ~(1 << CP0MVPCo_EVP);
+            other_cpu->mvp.CP0_MVPControl &= ~(1 << CP0MVPCo_EVP);
             mips_vpe_sleep(other_cpu);
         }
         other_cpu = other_cpu->next_cpu;
@@ -1926,14 +1930,14 @@ target_ulong helper_dvpe(void)
 target_ulong helper_evpe(void)
 {
     CPUState *other_cpu = first_cpu;
-    target_ulong prev = env->mvp->CP0_MVPControl;
+    target_ulong prev = env->mvp.CP0_MVPControl;
 
     do {
         if (other_cpu != env
            /* If the VPE is WFI, dont distrub it's sleep.  */
            && !mips_vpe_is_wfi(other_cpu)) {
             /* Enable the VPE.  */
-            other_cpu->mvp->CP0_MVPControl |= (1 << CP0MVPCo_EVP);
+            other_cpu->mvp.CP0_MVPControl |= (1 << CP0MVPCo_EVP);
             mips_vpe_wake(other_cpu); /* And wake it up.  */
         }
         other_cpu = other_cpu->next_cpu;
target-mips/translate.c +3 -3
index d5b1c76..c655a34 100644
@@ -5533,7 +5533,7 @@ static void gen_mftr(CPUState *env, DisasContext *ctx, int rt, int rd,
          (env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
         tcg_gen_movi_tl(t0, -1);
     else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) >
-             (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
+             (env->mvp.CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
         tcg_gen_movi_tl(t0, -1);
     else if (u == 0) {
         switch (rt) {
@@ -5751,7 +5751,7 @@ static void gen_mttr(CPUState *env, DisasContext *ctx, int rd, int rt,
          (env->active_tc.CP0_TCBind & (0xf << CP0TCBd_CurVPE))))
         /* NOP */ ;
     else if ((env->CP0_VPEControl & (0xff << CP0VPECo_TargTC)) >
-             (env->mvp->CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
+             (env->mvp.CP0_MVPConf0 & (0xff << CP0MVPC0_PTC)))
         /* NOP */ ;
     else if (u == 0) {
         switch (rd) {
@@ -12827,7 +12827,7 @@ void cpu_reset (CPUMIPSState *env)
 
         if (!env->cpu_index) {
             /* VPE0 starts up enabled.  */
-            env->mvp->CP0_MVPControl |= (1 << CP0MVPCo_EVP);
+            env->mvp.CP0_MVPControl |= (1 << CP0MVPCo_EVP);
             env->CP0_VPEConf0 |= (1 << CP0VPEC0_MVP) | (1 << CP0VPEC0_VPA);
 
             /* TC0 starts up unhalted.  */
target-mips/translate_init.c +6 -8
index c39138f..54fd1eb 100644
@@ -568,27 +568,25 @@ static void fpu_init (CPUMIPSState *env, const mips_def_t *def)
 
 static void mvp_init (CPUMIPSState *env, const mips_def_t *def)
 {
-    env->mvp = g_malloc0(sizeof(CPUMIPSMVPContext));
-
     /* MVPConf1 implemented, TLB sharable, no gating storage support,
        programmable cache partitioning implemented, number of allocatable
        and sharable TLB entries, MVP has allocatable TCs, 2 VPEs
        implemented, 5 TCs implemented. */
-    env->mvp->CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) |
-                             (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) |
+    env->mvp.CP0_MVPConf0 = (1 << CP0MVPC0_M) | (1 << CP0MVPC0_TLBS) |
+                            (0 << CP0MVPC0_GS) | (1 << CP0MVPC0_PCP) |
 // TODO: actually do 2 VPEs.
 //                             (1 << CP0MVPC0_TCA) | (0x1 << CP0MVPC0_PVPE) |
 //                             (0x04 << CP0MVPC0_PTC);
-                             (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) |
-                             (0x00 << CP0MVPC0_PTC);
+                            (1 << CP0MVPC0_TCA) | (0x0 << CP0MVPC0_PVPE) |
+                            (0x00 << CP0MVPC0_PTC);
 #if !defined(CONFIG_USER_ONLY)
     /* Usermode has no TLB support */
-    env->mvp->CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
+    env->mvp.CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
 #endif
 
     /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
        no UDI implemented, no CP2 implemented, 1 CP1 implemented. */
-    env->mvp->CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) |
+    env->mvp.CP0_MVPConf1 = (1 << CP0MVPC1_CIM) | (1 << CP0MVPC1_CIF) |
                              (0x0 << CP0MVPC1_PCX) | (0x0 << CP0MVPC1_PCP2) |
                              (0x1 << CP0MVPC1_PCP1);
 }
Signature · 1 line
1.7.6.4
#20 lore raw

PATCH v2 20/28 mips: make tlb an embedded struct instead of a pointer

In reply to Juan Quintela

Adjust all callers.

---
 hw/mips_timer.c              |    2 +-
 target-mips/cpu.h            |    2 +-
 target-mips/helper.c         |   30 +++++++++++++---------
 target-mips/machine.c        |   56 +++++++++++++++++++++---------------------
 target-mips/op_helper.c      |   40 +++++++++++++++---------------
 target-mips/translate.c      |   16 +++++++----
 target-mips/translate_init.c |   24 ++++++++---------
 7 files changed, 89 insertions(+), 81 deletions(-)
hw/mips_timer.c +1 -1
index cf6ac69..cb72d0d 100644
@@ -35,7 +35,7 @@ uint32_t cpu_mips_get_random (CPUState *env)
     /* Don't return same value twice, so get another value */
     do {
         lfsr = (lfsr >> 1) ^ (-(lfsr & 1u) & 0xd0000001u);
-        idx = lfsr % (env->tlb->nb_tlb - env->CP0_Wired) + env->CP0_Wired;
+        idx = lfsr % (env->tlb.nb_tlb - env->CP0_Wired) + env->CP0_Wired;
     } while (idx == prev_idx);
     prev_idx = idx;
     return idx;
target-mips/cpu.h +1 -1
index e11865b..7ca751b 100644
@@ -475,7 +475,7 @@ struct CPUMIPSState {
 
     CPUMIPSMVPContext mvp;
 #if !defined(CONFIG_USER_ONLY)
-    CPUMIPSTLBContext *tlb;
+    CPUMIPSTLBContext tlb;
 #endif
 
     const mips_def_t *cpu_model;
target-mips/helper.c +18 -12
index 1c58e0c..32209e3 100644
@@ -69,8 +69,8 @@ int r4k_map_address (CPUState *env, target_phys_addr_t *physical, int *prot,
     uint8_t ASID = env->CP0_EntryHi & 0xFF;
     int i;
 
-    for (i = 0; i < env->tlb->tlb_in_use; i++) {
-        r4k_tlb_t *tlb = &env->tlb->mmu.r4k.tlb[i];
+    for (i = 0; i < env->tlb.tlb_in_use; i++) {
+        r4k_tlb_t *tlb = &env->tlb.mmu.r4k.tlb[i];
         /* 1k pages are not supported. */
         target_ulong mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
         target_ulong tag = address & ~mask;
@@ -124,13 +124,15 @@ static int get_physical_address (CPUState *env, target_phys_addr_t *physical,
             *physical = address & 0xFFFFFFFF;
             *prot = PAGE_READ | PAGE_WRITE;
         } else {
-            ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
+            ret = env->tlb.map_address(env, physical, prot, address, rw,
+                                       access_type);
         }
 #if defined(TARGET_MIPS64)
     } else if (address < 0x4000000000000000ULL) {
         /* xuseg */
         if (UX && address <= (0x3FFFFFFFFFFFFFFFULL & env->SEGMask)) {
-            ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
+            ret = env->tlb.map_address(env, physical, prot, address, rw,
+                                       access_type);
         } else {
             ret = TLBRET_BADADDR;
         }
@@ -138,7 +140,8 @@ static int get_physical_address (CPUState *env, target_phys_addr_t *physical,
         /* xsseg */
         if ((supervisor_mode || kernel_mode) &&
             SX && address <= (0x7FFFFFFFFFFFFFFFULL & env->SEGMask)) {
-            ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
+            ret = env->tlb.map_address(env, physical, prot, address, rw,
+                                       access_type);
         } else {
             ret = TLBRET_BADADDR;
         }
@@ -155,7 +158,8 @@ static int get_physical_address (CPUState *env, target_phys_addr_t *physical,
         /* xkseg */
         if (kernel_mode && KX &&
             address <= (0xFFFFFFFF7FFFFFFFULL & env->SEGMask)) {
-            ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
+            ret = env->tlb.map_address(env, physical, prot, address, rw,
+                                       access_type);
         } else {
             ret = TLBRET_BADADDR;
         }
@@ -179,7 +183,8 @@ static int get_physical_address (CPUState *env, target_phys_addr_t *physical,
     } else if (address < (int32_t)0xE0000000UL) {
         /* sseg (kseg2) */
         if (supervisor_mode || kernel_mode) {
-            ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
+            ret = env->tlb.map_address(env, physical, prot, address, rw,
+                                       access_type);
         } else {
             ret = TLBRET_BADADDR;
         }
@@ -187,7 +192,8 @@ static int get_physical_address (CPUState *env, target_phys_addr_t *physical,
         /* kseg3 */
         /* XXX: debug segment is not emulated */
         if (kernel_mode) {
-            ret = env->tlb->map_address(env, physical, prot, address, rw, access_type);
+            ret = env->tlb.map_address(env, physical, prot, address, rw,
+                                       access_type);
         } else {
             ret = TLBRET_BADADDR;
         }
@@ -645,19 +651,19 @@ void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra)
     uint8_t ASID = env->CP0_EntryHi & 0xFF;
     target_ulong mask;
 
-    tlb = &env->tlb->mmu.r4k.tlb[idx];
+    tlb = &env->tlb.mmu.r4k.tlb[idx];
     /* The qemu TLB is flushed when the ASID changes, so no need to
        flush these entries again.  */
     if (tlb->G == 0 && tlb->ASID != ASID) {
         return;
     }
 
-    if (use_extra && env->tlb->tlb_in_use < MIPS_TLB_MAX) {
+    if (use_extra && env->tlb.tlb_in_use < MIPS_TLB_MAX) {
         /* For tlbwr, we can shadow the discarded entry into
            a new (fake) TLB entry, as long as the guest can not
            tell that it's there.  */
-        env->tlb->mmu.r4k.tlb[env->tlb->tlb_in_use] = *tlb;
-        env->tlb->tlb_in_use++;
+        env->tlb.mmu.r4k.tlb[env->tlb.tlb_in_use] = *tlb;
+        env->tlb.tlb_in_use++;
         return;
     }
 
target-mips/machine.c +28 -28

79 lines not on this page · raw message

target-mips/op_helper.c +20 -20
index a5d095c..85efac1 100644
@@ -1155,7 +1155,7 @@ target_ulong helper_dmfc0_watchlo (uint32_t sel)
 void helper_mtc0_index (target_ulong arg1)
 {
     int num = 1;
-    unsigned int tmp = env->tlb->nb_tlb;
+    unsigned int tmp = env->tlb.nb_tlb;
 
     do {
         tmp >>= 1;
@@ -1486,7 +1486,7 @@ void helper_mtc0_pagegrain (target_ulong arg1)
 
 void helper_mtc0_wired (target_ulong arg1)
 {
-    env->CP0_Wired = arg1 % env->tlb->nb_tlb;
+    env->CP0_Wired = arg1 % env->tlb.nb_tlb;
 }
 
 void helper_mtc0_srsconf0 (target_ulong arg1)
@@ -1989,14 +1989,14 @@ static void cpu_mips_tlb_flush (CPUState *env, int flush_global)
 {
     /* Flush qemu's TLB and discard all shadowed entries.  */
     tlb_flush (env, flush_global);
-    env->tlb->tlb_in_use = env->tlb->nb_tlb;
+    env->tlb.tlb_in_use = env->tlb.nb_tlb;
 }
 
 static void r4k_mips_tlb_flush_extra (CPUState *env, int first)
 {
     /* Discard entries from env->tlb[first] onwards.  */
-    while (env->tlb->tlb_in_use > first) {
-        r4k_invalidate_tlb(env, --env->tlb->tlb_in_use, 0);
+    while (env->tlb.tlb_in_use > first) {
+        r4k_invalidate_tlb(env, --env->tlb.tlb_in_use, 0);
     }
 }
 
@@ -2005,7 +2005,7 @@ static void r4k_fill_tlb (int idx)
     r4k_tlb_t *tlb;
 
     /* XXX: detect conflicting TLBs and raise a MCHECK exception when needed */
-    tlb = &env->tlb->mmu.r4k.tlb[idx];
+    tlb = &env->tlb.mmu.r4k.tlb[idx];
     tlb->VPN = env->CP0_EntryHi & (TARGET_PAGE_MASK << 1);
 #if defined(TARGET_MIPS64)
     tlb->VPN &= env->SEGMask;
@@ -2027,12 +2027,12 @@ void r4k_helper_tlbwi (void)
 {
     int idx;
 
-    idx = (env->CP0_Index & ~0x80000000) % env->tlb->nb_tlb;
+    idx = (env->CP0_Index & ~0x80000000) % env->tlb.nb_tlb;
 
     /* Discard cached TLB entries.  We could avoid doing this if the
        tlbwi is just upgrading access permissions on the current entry;
        that might be a further win.  */
-    r4k_mips_tlb_flush_extra (env, env->tlb->nb_tlb);
+    r4k_mips_tlb_flush_extra(env, env->tlb.nb_tlb);
 
     r4k_invalidate_tlb(env, idx, 0);
     r4k_fill_tlb(idx);
@@ -2056,8 +2056,8 @@ void r4k_helper_tlbp (void)
     int i;
 
     ASID = env->CP0_EntryHi & 0xFF;
-    for (i = 0; i < env->tlb->nb_tlb; i++) {
-        tlb = &env->tlb->mmu.r4k.tlb[i];
+    for (i = 0; i < env->tlb.nb_tlb; i++) {
+        tlb = &env->tlb.mmu.r4k.tlb[i];
         /* 1k pages are not supported. */
         mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
         tag = env->CP0_EntryHi & ~mask;
@@ -2069,10 +2069,10 @@ void r4k_helper_tlbp (void)
             break;
         }
     }
-    if (i == env->tlb->nb_tlb) {
+    if (i == env->tlb.nb_tlb) {
         /* No match.  Discard any shadow entries, if any of them match.  */
-        for (i = env->tlb->nb_tlb; i < env->tlb->tlb_in_use; i++) {
-            tlb = &env->tlb->mmu.r4k.tlb[i];
+        for (i = env->tlb.nb_tlb; i < env->tlb.tlb_in_use; i++) {
+            tlb = &env->tlb.mmu.r4k.tlb[i];
             /* 1k pages are not supported. */
             mask = tlb->PageMask | ~(TARGET_PAGE_MASK << 1);
             tag = env->CP0_EntryHi & ~mask;
@@ -2095,14 +2095,14 @@ void r4k_helper_tlbr (void)
     int idx;
 
     ASID = env->CP0_EntryHi & 0xFF;
-    idx = (env->CP0_Index & ~0x80000000) % env->tlb->nb_tlb;
-    tlb = &env->tlb->mmu.r4k.tlb[idx];
+    idx = (env->CP0_Index & ~0x80000000) % env->tlb.nb_tlb;
+    tlb = &env->tlb.mmu.r4k.tlb[idx];
 
     /* If this will change the current ASID, flush qemu's TLB.  */
     if (ASID != tlb->ASID)
         cpu_mips_tlb_flush (env, 1);
 
-    r4k_mips_tlb_flush_extra(env, env->tlb->nb_tlb);
+    r4k_mips_tlb_flush_extra(env, env->tlb.nb_tlb);
 
     env->CP0_EntryHi = tlb->VPN | tlb->ASID;
     env->CP0_PageMask = tlb->PageMask;
@@ -2114,22 +2114,22 @@ void r4k_helper_tlbr (void)
 
 void helper_tlbwi(void)
 {
-    env->tlb->helper_tlbwi();
+    env->tlb.helper_tlbwi();
 }
 
 void helper_tlbwr(void)
 {
-    env->tlb->helper_tlbwr();
+    env->tlb.helper_tlbwr();
 }
 
 void helper_tlbp(void)
 {
-    env->tlb->helper_tlbp();
+    env->tlb.helper_tlbp();
 }
 
 void helper_tlbr(void)
 {
-    env->tlb->helper_tlbr();
+    env->tlb.helper_tlbr();
 }
 
 /* Specials */
target-mips/translate.c +10 -6
index c655a34..48a0108 100644
@@ -5999,26 +5999,30 @@ static void gen_cp0 (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int
         break;
     case OPC_TLBWI:
         opn = "tlbwi";
-        if (!env->tlb->helper_tlbwi)
+        if (!env->tlb.helper_tlbwi) {
             goto die;
+        }
         gen_helper_tlbwi();
         break;
     case OPC_TLBWR:
         opn = "tlbwr";
-        if (!env->tlb->helper_tlbwr)
+        if (!env->tlb.helper_tlbwr) {
             goto die;
+        }
         gen_helper_tlbwr();
         break;
     case OPC_TLBP:
         opn = "tlbp";
-        if (!env->tlb->helper_tlbp)
+        if (!env->tlb.helper_tlbp) {
             goto die;
+        }
         gen_helper_tlbp();
         break;
     case OPC_TLBR:
         opn = "tlbr";
-        if (!env->tlb->helper_tlbr)
+        if (!env->tlb.helper_tlbr) {
             goto die;
+        }
         gen_helper_tlbr();
         break;
     case OPC_ERET:
@@ -12792,8 +12796,8 @@ void cpu_reset (CPUMIPSState *env)
         env->CP0_ErrorEPC = env->active_tc.PC;
     }
     env->active_tc.PC = (int32_t)0xBFC00000;
-    env->CP0_Random = env->tlb->nb_tlb - 1;
-    env->tlb->tlb_in_use = env->tlb->nb_tlb;
+    env->CP0_Random = env->tlb.nb_tlb - 1;
+    env->tlb.tlb_in_use = env->tlb.nb_tlb;
     env->CP0_Wired = 0;
     env->CP0_EBase = 0x80000000 | (env->cpu_index & 0x3FF);
     env->CP0_Status = (1 << CP0St_BEV) | (1 << CP0St_ERL);
target-mips/translate_init.c +11 -13
index 54fd1eb..0adb304 100644
@@ -513,30 +513,28 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf)
 #ifndef CONFIG_USER_ONLY
 static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def)
 {
-    env->tlb->nb_tlb = 1;
-    env->tlb->map_address = &no_mmu_map_address;
+    env->tlb.nb_tlb = 1;
+    env->tlb.map_address = &no_mmu_map_address;
 }
 
 static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def)
 {
-    env->tlb->nb_tlb = 1;
-    env->tlb->map_address = &fixed_mmu_map_address;
+    env->tlb.nb_tlb = 1;
+    env->tlb.map_address = &fixed_mmu_map_address;
 }
 
 static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def)
 {
-    env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
-    env->tlb->map_address = &r4k_map_address;
-    env->tlb->helper_tlbwi = r4k_helper_tlbwi;
-    env->tlb->helper_tlbwr = r4k_helper_tlbwr;
-    env->tlb->helper_tlbp = r4k_helper_tlbp;
-    env->tlb->helper_tlbr = r4k_helper_tlbr;
+    env->tlb.nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63);
+    env->tlb.map_address = &r4k_map_address;
+    env->tlb.helper_tlbwi = r4k_helper_tlbwi;
+    env->tlb.helper_tlbwr = r4k_helper_tlbwr;
+    env->tlb.helper_tlbp = r4k_helper_tlbp;
+    env->tlb.helper_tlbr = r4k_helper_tlbr;
 }
 
 static void mmu_init (CPUMIPSState *env, const mips_def_t *def)
 {
-    env->tlb = g_malloc0(sizeof(CPUMIPSTLBContext));
-
     switch (def->mmu_type) {
         case MMU_TYPE_NONE:
             no_mmu_init(env, def);
@@ -581,7 +579,7 @@ static void mvp_init (CPUMIPSState *env, const mips_def_t *def)
                             (0x00 << CP0MVPC0_PTC);
 #if !defined(CONFIG_USER_ONLY)
     /* Usermode has no TLB support */
-    env->mvp.CP0_MVPConf0 |= (env->tlb->nb_tlb << CP0MVPC0_PTLBE);
+    env->mvp.CP0_MVPConf0 |= (env->tlb.nb_tlb << CP0MVPC0_PTLBE);
 #endif
 
     /* Allocatable CP1 have media extensions, allocatable CP1 have FP support,
Signature · 1 line
1.7.6.4
#21 lore raw

PATCH v2 21/28 mips: bump migration version to 4

In reply to Juan Quintela

bcond state was stored as int32, but it is target_ulong. Change migration state to reflect that.

---
 target-mips/cpu.h     |    2 +-
 target-mips/machine.c |   10 ++++------
 2 files changed, 5 insertions(+), 7 deletions(-)
target-mips/cpu.h +1 -1
index 7ca751b..7810924 100644
@@ -507,7 +507,7 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 #define cpu_signal_handler cpu_mips_signal_handler
 #define cpu_list mips_cpu_list
 
-#define CPU_SAVE_VERSION 3
+#define CPU_SAVE_VERSION 4
 
 /* MMU modes definitions. We carefully match the indices with our
    hflags layout. */
target-mips/machine.c +4 -6
index a55fbb6..134dbd5 100644
@@ -84,8 +84,7 @@ void cpu_save(QEMUFile *f, void *opaque)
     qemu_put_sbe32s(f, &env->error_code);
     qemu_put_be32s(f, &env->hflags);
     qemu_put_betls(f, &env->btarget);
-    i = env->bcond;
-    qemu_put_sbe32s(f, &i);
+    qemu_put_betls(f, &env->bcond);
 
     /* Save remaining CP1 registers */
     qemu_put_sbe32s(f, &env->CP0_Index);
@@ -193,9 +192,9 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     CPUState *env = opaque;
     int i;
 
-    if (version_id != 3)
+    if (version_id != 4) {
         return -EINVAL;
-
+    }
     /* Load active TC */
     load_tc(f, &env->active_tc);
 
@@ -236,8 +235,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_sbe32s(f, &env->error_code);
     qemu_get_be32s(f, &env->hflags);
     qemu_get_betls(f, &env->btarget);
-    qemu_get_sbe32s(f, &i);
-    env->bcond = i;
+    qemu_get_betls(f, &env->bcond);
 
     /* Load remaining CP1 registers */
     qemu_get_sbe32s(f, &env->CP0_Index);
Signature · 1 line
1.7.6.4
#22 lore raw

PATCH v2 22/28 vmstate: port mips cpu

In reply to Juan Quintela
---
 target-mips/cpu.h     |    5 +-
 target-mips/machine.c |  465 +++++++++++++++++++------------------------------
 2 files changed, 182 insertions(+), 288 deletions(-)
target-mips/cpu.h +3 -2
index 7810924..af9c384 100644
@@ -37,6 +37,9 @@ struct r4k_tlb_t {
     uint_fast16_t D0:1;
     uint_fast16_t D1:1;
     target_ulong PFN[2];
+    /* Fields needed as intermediate for vmstate */
+    uint8_t asid_vmstate;
+    uint16_t flags_vmstate;
 };
 
 #if !defined(CONFIG_USER_ONLY)
@@ -507,8 +510,6 @@ void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 #define cpu_signal_handler cpu_mips_signal_handler
 #define cpu_list mips_cpu_list
 
-#define CPU_SAVE_VERSION 4
-
 /* MMU modes definitions. We carefully match the indices with our
    hflags layout. */
 #define MMU_MODE0_SUFFIX _kernel
target-mips/machine.c +179 -286

483 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#23 lore raw

PATCH v2 23/28 arm: save always 32 fpu registers

In reply to Juan Quintela

This way, we fix a bug (we were overwritten the 16 first registers on load), and we don't need to check for ARM_FEATUR_VPF3, we always send the 32 registers.

---
 target-arm/cpu.h     |    2 +-
 target-arm/machine.c |   22 ++--------------------
 2 files changed, 3 insertions(+), 21 deletions(-)
target-arm/cpu.h +1 -1
index 6ab780d..f6d9436 100644
@@ -446,7 +446,7 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
 
-#define CPU_SAVE_VERSION 4
+#define CPU_SAVE_VERSION 5
 
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
target-arm/machine.c +2 -20
index 7d4fc54..3a3b325 100644
@@ -60,7 +60,7 @@ void cpu_save(QEMUFile *f, void *opaque)
     qemu_put_be32(f, env->features);
 
     if (arm_feature(env, ARM_FEATURE_VFP)) {
-        for (i = 0;  i < 16; i++) {
+        for (i = 0;  i < 32; i++) {
             CPU_DoubleU u;
             u.d = env->vfp.regs[i];
             qemu_put_be32(f, u.l.upper);
@@ -73,15 +73,6 @@ void cpu_save(QEMUFile *f, void *opaque)
         /* TODO: Should use proper FPSCR access functions.  */
         qemu_put_be32(f, env->vfp.vec_len);
         qemu_put_be32(f, env->vfp.vec_stride);
-
-        if (arm_feature(env, ARM_FEATURE_VFP3)) {
-            for (i = 16;  i < 32; i++) {
-                CPU_DoubleU u;
-                u.d = env->vfp.regs[i];
-                qemu_put_be32(f, u.l.upper);
-                qemu_put_be32(f, u.l.lower);
-            }
-        }
     }
 
     if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
@@ -174,7 +165,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     env->features = qemu_get_be32(f);
 
     if (arm_feature(env, ARM_FEATURE_VFP)) {
-        for (i = 0;  i < 16; i++) {
+        for (i = 0;  i < 32; i++) {
             CPU_DoubleU u;
             u.l.upper = qemu_get_be32(f);
             u.l.lower = qemu_get_be32(f);
@@ -187,15 +178,6 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
         /* TODO: Should use proper FPSCR access functions.  */
         env->vfp.vec_len = qemu_get_be32(f);
         env->vfp.vec_stride = qemu_get_be32(f);
-
-        if (arm_feature(env, ARM_FEATURE_VFP3)) {
-            for (i = 0;  i < 16; i++) {
-                CPU_DoubleU u;
-                u.l.upper = qemu_get_be32(f);
-                u.l.lower = qemu_get_be32(f);
-                env->vfp.regs[i] = u.d;
-            }
-        }
     }
 
     if (arm_feature(env, ARM_FEATURE_IWMMXT)) {
Signature · 1 line
1.7.6.4
#24 lore raw

PATCH v2 24/28 vmstate: port arm cpu

In reply to Juan Quintela

Use one subsection for each feature. This means that we don't need to bump the version field each time that a new feature gets introduced.

Introduce cpsr_vmstate field, as I am not sure if I can "use" uncached_cpsr for saving state.

---
 target-arm/cpu.h     |    5 +-
 target-arm/machine.c |  333 ++++++++++++++++++++++---------------------------
 2 files changed, 153 insertions(+), 185 deletions(-)
target-arm/cpu.h +3 -2
index f6d9436..c860914 100644
@@ -228,6 +228,9 @@ typedef struct CPUARMState {
     } cp[15];
     void *nvic;
     const struct arm_boot_info *boot_info;
+
+    /* Fields needed as intermediate for vmstate */
+    uint32_t cpsr_vmstate;
 } CPUARMState;
 
 CPUARMState *cpu_arm_init(const char *cpu_model);
@@ -446,8 +449,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define cpu_signal_handler cpu_arm_signal_handler
 #define cpu_list arm_cpu_list
 
-#define CPU_SAVE_VERSION 5
-
 /* MMU modes definitions */
 #define MMU_MODE0_SUFFIX _kernel
 #define MMU_MODE1_SUFFIX _user
target-arm/machine.c +150 -183

357 lines not on this page · raw message

Signature · 1 line
1.7.6.4
#25 lore raw

PATCH v2 25/28 vmstate: all cpus converted

In reply to Juan Quintela

We don't have any more CPU_SAVEVM_VERSION users, neither cpu_save/load() ones.

---
 exec.c        |    5 -----
 qemu-common.h |    4 ----
 2 files changed, 0 insertions(+), 9 deletions(-)
exec.c +0 -5
index 09f3f01..cc84378 100644
@@ -660,13 +660,8 @@ void cpu_exec_init(CPUState *env)
 #endif
 #if !defined(CONFIG_USER_ONLY)
     vmstate_register(NULL, cpu_index, &vmstate_cpu_common, env);
-#if defined(CPU_SAVE_VERSION)
-    register_savevm(NULL, "cpu", cpu_index, CPU_SAVE_VERSION,
-                    cpu_save, cpu_load, env);
-#else
     vmstate_register(NULL, cpu_index, &vmstate_cpu, env);
 #endif
-#endif
 }
 
 /* Allocate a new translation block. Flush the translation buffer if
qemu-common.h +0 -4
index 1c15cb1..fd0fc30 100644
@@ -246,10 +246,6 @@ bool tcg_enabled(void);
 
 void cpu_exec_init_all(void);
 
-/* CPU save/load.  */
-void cpu_save(QEMUFile *f, void *opaque);
-int cpu_load(QEMUFile *f, void *opaque, int version_id);
-
 /* Unblock cpu */
 void qemu_cpu_kick(void *env);
 void qemu_cpu_kick_self(void);
Signature · 1 line
1.7.6.4
#26 lore raw

PATCH v2 26/28 vmstate: fix vmstate formating for i386

In reply to Juan Quintela
---
 target-i386/machine.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
target-i386/machine.c +8 -8
index 0ecbfe9..612e7de 100644
@@ -11,7 +11,7 @@ static const VMStateDescription vmstate_segment = {
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT32(selector, SegmentCache),
         VMSTATE_UINTTL(base, SegmentCache),
         VMSTATE_UINT32(limit, SegmentCache),
@@ -37,7 +37,7 @@ static const VMStateDescription vmstate_xmm_reg = {
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(XMM_Q(0), XMMReg),
         VMSTATE_UINT64(XMM_Q(1), XMMReg),
         VMSTATE_END_OF_LIST()
@@ -53,7 +53,7 @@ static const VMStateDescription vmstate_ymmh_reg = {
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(XMM_Q(0), XMMReg),
         VMSTATE_UINT64(XMM_Q(1), XMMReg),
         VMSTATE_END_OF_LIST()
@@ -68,7 +68,7 @@ static const VMStateDescription vmstate_mtrr_var = {
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(base, MTRRVar),
         VMSTATE_UINT64(mask, MTRRVar),
         VMSTATE_END_OF_LIST()
@@ -284,7 +284,7 @@ static const VMStateDescription vmstate_async_pf_msr = {
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT64(async_pf_en_msr, CPUState),
         VMSTATE_END_OF_LIST()
     }
@@ -302,7 +302,7 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
     .version_id = 1,
     .minimum_version_id = 1,
     .minimum_version_id_old = 1,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINT16(fpop, CPUState),
         VMSTATE_UINT64(fpip, CPUState),
         VMSTATE_UINT64(fpdp, CPUState),
@@ -317,7 +317,7 @@ const VMStateDescription vmstate_cpu = {
     .minimum_version_id_old = 3,
     .pre_save = cpu_pre_save,
     .post_load = cpu_post_load,
-    .fields      = (VMStateField []) {
+    .fields = (VMStateField[]) {
         VMSTATE_UINTTL_ARRAY(regs, CPUState, CPU_NB_REGS),
         VMSTATE_UINTTL(eip, CPUState),
         VMSTATE_UINTTL(eflags, CPUState),
@@ -414,7 +414,7 @@ const VMStateDescription vmstate_cpu = {
         VMSTATE_END_OF_LIST()
         /* The above list is not sorted /wrt version numbers, watch out! */
     },
-    .subsections = (VMStateSubsection []) {
+    .subsections = (VMStateSubsection[]) {
         {
             .vmsd = &vmstate_async_pf_msr,
             .needed = async_pf_msr_needed,
Signature · 1 line
1.7.6.4
#27 lore raw

PATCH v2 27/28 vmstate: remove unneeded includes from target-*/machine.c

In reply to Juan Quintela
---
 target-alpha/machine.c |    1 -
 target-arm/machine.c   |    1 -
 target-cris/machine.c  |    1 -
 target-i386/machine.c  |    6 ------
 target-lm32/machine.c  |    1 -
 target-mips/machine.c  |    3 ---
 target-ppc/machine.c   |    2 --
 target-sparc/machine.c |    4 ----
 8 files changed, 0 insertions(+), 19 deletions(-)
target-alpha/machine.c +0 -1
index 8d32d7c..156cb74 100644
@@ -1,5 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
 
 static int get_fpcr(QEMUFile *f, void *opaque, size_t size)
 {
target-arm/machine.c +0 -1
index 8703b8a..836d9ed 100644
@@ -1,5 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
 
 static bool feature_vfp_needed(void *opaque)
 {
target-cris/machine.c +0 -1
index 49b227d..0f732d3 100644
@@ -1,5 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
 
 static const VMStateDescription vmstate_tlbset = {
     .name = "cpu/tlbset",
target-i386/machine.c +0 -6
index 612e7de..91f5147 100644
@@ -1,10 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
-#include "hw/pc.h"
-#include "hw/isa.h"
-
-#include "cpu.h"
-#include "kvm.h"
 
 static const VMStateDescription vmstate_segment = {
     .name = "segment",
target-lm32/machine.c +0 -1
index c31b744..60b4b29 100644
@@ -1,5 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
 
 const VMStateDescription vmstate_cpu = {
     .name = "cpu",
target-mips/machine.c +0 -3
index 988a5c9..d6d7830 100644
@@ -1,7 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
-
-#include "cpu.h"
 
 static const VMStateDescription vmstate_tc = {
     .name = "tc",
target-ppc/machine.c +0 -2
index 0114733..1664d32 100644
@@ -1,6 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
-#include "kvm.h"
 
 static const VMStateDescription vmstate_tlb = {
     .name = "tlb",
target-sparc/machine.c +0 -4
index e3e57b5..080fc6a 100644
@@ -1,8 +1,4 @@
 #include "hw/hw.h"
-#include "hw/boards.h"
-#include "qemu-timer.h"
-
-#include "cpu.h"
 
 static const VMStateDescription vmstate_cpu_timer = {
     .name = "cpu_timer",
Signature · 1 line
1.7.6.4
#28 lore raw

PATCH v2 28/28 vmstate: rename machine.c to vmstate.c

In reply to Juan Quintela

They only contain vmstate cpu sections nowadays. Change name to reflect the case.

---
 Makefile.target                            |    2 +-
 target-alpha/{machine.c => vmstate.c}      |    0
 target-arm/{machine.c => vmstate.c}        |    0
 target-cris/{machine.c => vmstate.c}       |    0
 target-i386/{machine.c => vmstate.c}       |    0
 target-lm32/{machine.c => vmstate.c}       |    0
 target-m68k/{machine.c => vmstate.c}       |    0
 target-microblaze/{machine.c => vmstate.c} |    0
 target-mips/{machine.c => vmstate.c}       |    0
 target-ppc/{machine.c => vmstate.c}        |    0
 target-s390x/{machine.c => vmstate.c}      |    0
 target-sh4/{machine.c => vmstate.c}        |    0
 target-sparc/{machine.c => vmstate.c}      |    0
 target-xtensa/{machine.c => vmstate.c}     |    0
 14 files changed, 1 insertions(+), 1 deletions(-)
 rename target-alpha/{machine.c => vmstate.c} (100%)
 rename target-arm/{machine.c => vmstate.c} (100%)
 rename target-cris/{machine.c => vmstate.c} (100%)
 rename target-i386/{machine.c => vmstate.c} (100%)
 rename target-lm32/{machine.c => vmstate.c} (100%)
 rename target-m68k/{machine.c => vmstate.c} (100%)
 rename target-microblaze/{machine.c => vmstate.c} (100%)
 rename target-mips/{machine.c => vmstate.c} (100%)
 rename target-ppc/{machine.c => vmstate.c} (100%)
 rename target-s390x/{machine.c => vmstate.c} (100%)
 rename target-sh4/{machine.c => vmstate.c} (100%)
 rename target-sparc/{machine.c => vmstate.c} (100%)
 rename target-xtensa/{machine.c => vmstate.c} (100%)
Makefile.target +1 -1
index 1e90df7..7e1be3f 100644
@@ -189,7 +189,7 @@ endif #CONFIG_BSD_USER
 # System emulator target
 ifdef CONFIG_SOFTMMU
 
-obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o balloon.o ioport.o
+obj-y = arch_init.o cpus.o monitor.o vmstate.o gdbstub.o balloon.o ioport.o
 # virtio has to be here due to weird dependency between PCI and virtio-net.
 # need to fix this properly
 obj-$(CONFIG_NO_PCI) += pci-stub.o
target-alpha/vmstate.c renamed from target-alpha/machine.c +0 -0
similarity index 100%
rename from target-alpha/machine.c
rename to target-alpha/vmstate.c
target-arm/vmstate.c renamed from target-arm/machine.c +0 -0
similarity index 100%
rename from target-arm/machine.c
rename to target-arm/vmstate.c
target-cris/vmstate.c renamed from target-cris/machine.c +0 -0
similarity index 100%
rename from target-cris/machine.c
rename to target-cris/vmstate.c
target-i386/vmstate.c renamed from target-i386/machine.c +0 -0
similarity index 100%
rename from target-i386/machine.c
rename to target-i386/vmstate.c
target-lm32/vmstate.c renamed from target-lm32/machine.c +0 -0
similarity index 100%
rename from target-lm32/machine.c
rename to target-lm32/vmstate.c
target-m68k/vmstate.c renamed from target-m68k/machine.c +0 -0
similarity index 100%
rename from target-m68k/machine.c
rename to target-m68k/vmstate.c
target-microblaze/vmstate.c renamed from target-microblaze/machine.c +0 -0
similarity index 100%
rename from target-microblaze/machine.c
rename to target-microblaze/vmstate.c
target-mips/vmstate.c renamed from target-mips/machine.c +0 -0
similarity index 100%
rename from target-mips/machine.c
rename to target-mips/vmstate.c
target-ppc/vmstate.c renamed from target-ppc/machine.c +0 -0
similarity index 100%
rename from target-ppc/machine.c
rename to target-ppc/vmstate.c
target-s390x/vmstate.c renamed from target-s390x/machine.c +0 -0
similarity index 100%
rename from target-s390x/machine.c
rename to target-s390x/vmstate.c
target-sh4/vmstate.c renamed from target-sh4/machine.c +0 -0
similarity index 100%
rename from target-sh4/machine.c
rename to target-sh4/vmstate.c
target-sparc/vmstate.c renamed from target-sparc/machine.c +0 -0
similarity index 100%
rename from target-sparc/machine.c
rename to target-sparc/vmstate.c
target-xtensa/vmstate.c renamed from target-xtensa/machine.c +0 -0
similarity index 100%
rename from target-xtensa/machine.c
rename to target-xtensa/vmstate.c
Signature · 1 line
1.7.6.4