This adds new fields in the CPUX86State struct to store the x87
exception pointers.
Also it adds a new enum type that encodes the operand size and the
processor operating mode (protected and real mode).
The patch also adds a new option (tcg-exception-pointers) in the
 configure script to enable or disable the functionality
implemented in this development.

Signed-off-by: jaume.mar...@gmail.com
---
 configure             | 10 ++++++++++
 target-i386/cpu.h     | 25 +++++++++++++++++++++++--
 target-i386/machine.c | 11 ++++++++++-
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 47048f0..62f1979 100755
--- a/configure
+++ b/configure
@@ -264,6 +264,7 @@ debug_tcg="no"
 debug="no"
 strip_opt="yes"
 tcg_interpreter="no"
+tcg_exception_pointers="no"
 bigendian="no"
 mingw32="no"
 gcov="no"
@@ -926,6 +927,10 @@ for opt do
   ;;
   --enable-tcg-interpreter) tcg_interpreter="yes"
   ;;
+  --disable-tcg-exception-pointers) tcg_exception_pointers="no"
+  ;;
+  --enable-tcg-exception-pointers) tcg_exception_pointers="yes"
+  ;;
   --disable-cap-ng)  cap_ng="no"
   ;;
   --enable-cap-ng) cap_ng="yes"
@@ -1321,6 +1326,7 @@ Advanced options (experts only):
   --disable-rdma           disable RDMA-based migration support
   --enable-rdma            enable RDMA-based migration support
   --enable-tcg-interpreter enable TCG with bytecode interpreter (TCI)
+  --enable-tcg-exception-pointers enable exception pointers support for TCG 
based emmulation
   --enable-system          enable all system emulation targets
   --disable-system         disable all system emulation targets
   --enable-user            enable supported user emulation targets
@@ -4296,6 +4302,7 @@ echo "Install blobs     $blobs"
 echo "KVM support       $kvm"
 echo "RDMA support      $rdma"
 echo "TCG interpreter   $tcg_interpreter"
+echo "TCG exception pointers $tcg_exception_pointers"
 echo "fdt support       $fdt"
 echo "preadv support    $preadv"
 echo "fdatasync         $fdatasync"
@@ -4651,6 +4658,9 @@ fi
 if test "$tcg_interpreter" = "yes" ; then
   echo "CONFIG_TCG_INTERPRETER=y" >> $config_host_mak
 fi
+if test "$tcg_exception_pointers" = "yes" ; then
+  echo "CONFIG_TCG_EXCEPTION_POINTERS=y" >> $config_host_mak
+fi
 if test "$fdatasync" = "yes" ; then
   echo "CONFIG_FDATASYNC=y" >> $config_host_mak
 fi
diff --git a/target-i386/cpu.h b/target-i386/cpu.h
index 015f5b5..69c6222 100644
--- a/target-i386/cpu.h
+++ b/target-i386/cpu.h
@@ -697,6 +697,24 @@ typedef enum {
     CC_OP_NB,
 } CCOp;
 
+typedef enum {
+    B8     = 0,
+    B16    = 1,
+    B32    = 2,
+    B64    = 3,
+    BSIZE  = 3,   /* Mask for the above.  */
+
+    RM     = 4,
+    PM     = 8,
+
+    PM32   = PM | B32,
+    PM16   = PM | B16,
+    RM32   = RM | B32,
+    RM16   = RM | B16,
+} OMode;
+
+#define TO_OMODE(bsize, is_pm) ((bsize & BSIZE) | (1 << (is_pm ? 3 : 2)))
+
 typedef struct SegmentCache {
     uint32_t selector;
     target_ulong base;
@@ -876,10 +894,13 @@ typedef struct CPUX86State {
     uint16_t fpuc;
     uint8_t fptags[8];   /* 0 = valid, 1 = empty */
     FPReg fpregs[8];
-    /* KVM-only so far */
-    uint16_t fpop;
+    uint32_t fpop;
     uint64_t fpip;
     uint64_t fpdp;
+#ifdef CONFIG_TCG_EXCEPTION_POINTERS
+    uint32_t fpcs;
+    uint32_t fpds;
+#endif
 
     /* emulator internal variables */
     float_status fp_status;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 1c13b14..8ef0204 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -427,7 +427,12 @@ static bool fpop_ip_dp_needed(void *opaque)
     X86CPU *cpu = opaque;
     CPUX86State *env = &cpu->env;
 
+#ifdef CONFIG_TCG_EXCEPTION_POINTERS
+    return env->fpop != 0 || env->fpip != 0 || env->fpdp != 0
+            || env->fpcs != 0 || env->fpds != 0;
+#else
     return env->fpop != 0 || env->fpip != 0 || env->fpdp != 0;
+#endif
 }
 
 static const VMStateDescription vmstate_fpop_ip_dp = {
@@ -435,9 +440,13 @@ static const VMStateDescription vmstate_fpop_ip_dp = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (VMStateField[]) {
-        VMSTATE_UINT16(env.fpop, X86CPU),
+        VMSTATE_UINT32(env.fpop, X86CPU),
         VMSTATE_UINT64(env.fpip, X86CPU),
         VMSTATE_UINT64(env.fpdp, X86CPU),
+#ifdef CONFIG_TCG_EXCEPTION_POINTERS
+        VMSTATE_UINT32(env.fpcs, X86CPU),
+        VMSTATE_UINT32(env.fpds, X86CPU),
+#endif
         VMSTATE_END_OF_LIST()
     }
 };
-- 
2.1.0


Reply via email to