Patchwork [35/49] x86: add fpregs_format_vmstate

login
register
mail settings
Submitter Juan Quintela
Date Sept. 29, 2009, 8:48 p.m.
Message ID <7ef223438a54f88606934e70c44c015b161ed2e2.1254255997.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/34487/
State Superseded
Headers show

Comments

Juan Quintela - Sept. 29, 2009, 8:48 p.m.
Don't even ask, being able to load/save between 64<->80bit floats should be forbidden

Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 target-i386/cpu.h     |    1 +
 target-i386/machine.c |   12 +++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

Patch

diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index e13f87b..af122a1 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -595,6 +595,7 @@  typedef struct CPUX86State {
     uint16_t fpus;
     uint16_t fpus_vmstate;
     uint16_t fptag_vmstate;
+    uint16_t fpregs_format_vmstate;
     uint16_t fpuc;
     uint8_t fptags[8];   /* 0 = valid, 1 = empty */
     union {
diff --git a/target-i386/machine.c b/target-i386/machine.c
index e1621d4..69e2620 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -26,7 +26,6 @@  static void cpu_get_seg(QEMUFile *f, SegmentCache *dt)
 void cpu_save(QEMUFile *f, void *opaque)
 {
     CPUState *env = opaque;
-    uint16_t fpregs_format;
     int i, bit;

     cpu_synchronize_state(env);
@@ -49,11 +48,11 @@  void cpu_save(QEMUFile *f, void *opaque)
     qemu_put_be16s(f, &env->fptag_vmstate);

 #ifdef USE_X86LDOUBLE
-    fpregs_format = 0;
+    env->fpregs_format_vmstate = 0;
 #else
-    fpregs_format = 1;
+    env->fpregs_format_vmstate = 1;
 #endif
-    qemu_put_be16s(f, &fpregs_format);
+    qemu_put_be16s(f, &env->fpregs_format_vmstate);

     for(i = 0; i < 8; i++) {
 #ifdef USE_X86LDOUBLE
@@ -195,7 +194,6 @@  int cpu_load(QEMUFile *f, void *opaque, int version_id)
 {
     CPUState *env = opaque;
     int i, guess_mmx;
-    uint16_t fpregs_format;

     cpu_synchronize_state(env);
     if (version_id < 3 || version_id > CPU_SAVE_VERSION)
@@ -209,7 +207,7 @@  int cpu_load(QEMUFile *f, void *opaque, int version_id)
     qemu_get_be16s(f, &env->fpuc);
     qemu_get_be16s(f, &env->fpus_vmstate);
     qemu_get_be16s(f, &env->fptag_vmstate);
-    qemu_get_be16s(f, &fpregs_format);
+    qemu_get_be16s(f, &env->fpregs_format_vmstate);

     /* NOTE: we cannot always restore the FPU state if the image come
        from a host with a different 'USE_X86LDOUBLE' define. We guess
@@ -219,7 +217,7 @@  int cpu_load(QEMUFile *f, void *opaque, int version_id)
         uint64_t mant;
         uint16_t exp;

-        switch(fpregs_format) {
+        switch(env->fpregs_format_vmstate) {
         case 0:
             mant = qemu_get_be64(f);
             exp = qemu_get_be16(f);