aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/i387-fp.c
diff options
context:
space:
mode:
authorWalfred Tedeschi <walfred.tedeschi@intel.com>2013-10-10 07:12:49 +0000
committerWalfred Tedeschi <walfred.tedeschi@intel.com>2013-11-20 14:42:52 +0100
commita196ebeb91d1149b1615faaeafc31d72a28ba98e (patch)
treecd7bef0d65b80a45777d278c0f2870e68c3f664c /gdb/gdbserver/i387-fp.c
parente43e105e0d3a6cf324b19adc10d4952b553f43ee (diff)
downloadgdb-a196ebeb91d1149b1615faaeafc31d72a28ba98e.zip
gdb-a196ebeb91d1149b1615faaeafc31d72a28ba98e.tar.gz
gdb-a196ebeb91d1149b1615faaeafc31d72a28ba98e.tar.bz2
Add MPX support to gdbserver.
2013-05-22 Walfred Tedeschi <walfred.tedeschi@intel.com> gdbserver/ * Makefile.in: Add i386-mpx.c, i386-mpx-linux.c, amd64-mpx.c, amd64-mpx-linux.c, x32-mpx.c and x32-mpx-linux.c generation. * configure.srv (srv_i386_regobj): Add i386-mpx.o. (srv_i386_linux_regobj): Add i386-mpx-linux.o. (srv_amd64_regobj): Add amd64-mpx.o. (srv_amd64_linux_regobj): Add amd64-mpx-linux.o. (srv_i386_32bit_xmlfiles): Add i386/32bit-mpx.xml. (srv_i386_64bit_xmlfiles): Add i386/64bit-mpx.xml. * i387-fp.c (num_pl_bnd_register) Added constant. (num_pl_bnd_cfg_registers) Added constant. (struct i387_xsave) Added reserved area and MPX fields. (i387_cache_to_xsave, i387_xsave_to_cache) Add MPX. * linux-x86-low.c (init_registers_i386_mpx_linux): Declare new function. (tdesc_i386_mpx_linux): Add MPX amd64 target. (init_registers_amd64_mpx_linux): Declare new function. (tdesc_amd64_mpx_linux): Add MPX amd64 target. (x86_64_regmap): Add MPX registers. (x86_linux_read_description): Add MPX case. (initialize_low_arch): Initialize MPX targets. Change-Id: I394d81afa76d11375ce792cefad0ceb9825fb379 Signed-off-by: Walfred Tedeschi <walfred.tedeschi@intel.com>
Diffstat (limited to 'gdb/gdbserver/i387-fp.c')
-rw-r--r--gdb/gdbserver/i387-fp.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/gdb/gdbserver/i387-fp.c b/gdb/gdbserver/i387-fp.c
index 2886519..1240b67 100644
--- a/gdb/gdbserver/i387-fp.c
+++ b/gdb/gdbserver/i387-fp.c
@@ -20,6 +20,9 @@
#include "i387-fp.h"
#include "i386-xstate.h"
+static const int num_mpx_bnd_registers = 4;
+static const int num_mpx_cfg_registers = 2;
+
/* Note: These functions preserve the reserved bits in control registers.
However, gdbserver promptly throws away that information. */
@@ -108,6 +111,15 @@ struct i387_xsave {
/* Space for eight upper 128-bit YMM values, or 16 on x86-64. */
unsigned char ymmh_space[256];
+
+ unsigned char reserved4[128];
+
+ /* Space for 4 bound registers values of 128 bits. */
+ unsigned char mpx_bnd_space[64];
+
+ /* Space for 2 MPX configuration registers of 64 bits
+ plus reserved space. */
+ unsigned char mpx_cfg_space[16];
};
void
@@ -271,6 +283,14 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
if ((clear_bv & I386_XSTATE_AVX))
for (i = 0; i < num_xmm_registers; i++)
memset (((char *) &fp->ymmh_space[0]) + i * 16, 0, 16);
+
+ if ((clear_bv & I386_XSTATE_BNDREGS))
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ memset (((char *) &fp->mpx_bnd_space[0]) + i * 16, 0, 16);
+
+ if ((clear_bv & I386_XSTATE_BNDCFG))
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ memset (((char *) &fp->mpx_cfg_space[0]) + i * 8, 0, 8);
}
/* Check if any x87 registers are changed. */
@@ -324,6 +344,40 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
}
+ /* Check if any bound register has changed. */
+ if ((x86_xcr0 & I386_XSTATE_BNDREGS))
+ {
+ int bnd0r_regnum = find_regno (regcache->tdesc, "bnd0raw");
+
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ {
+ collect_register (regcache, i + bnd0r_regnum, raw);
+ p = ((char *) &fp->mpx_bnd_space[0]) + i * 16;
+ if (memcmp (raw, p, 16))
+ {
+ xstate_bv |= I386_XSTATE_BNDREGS;
+ memcpy (p, raw, 16);
+ }
+ }
+ }
+
+ /* Check if any status register has changed. */
+ if ((x86_xcr0 & I386_XSTATE_BNDCFG))
+ {
+ int bndcfg_regnum = find_regno (regcache->tdesc, "bndcfgu");
+
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ {
+ collect_register (regcache, i + bndcfg_regnum, raw);
+ p = ((char *) &fp->mpx_cfg_space[0]) + i * 8;
+ if (memcmp (raw, p, 8))
+ {
+ xstate_bv |= I386_XSTATE_BNDCFG;
+ memcpy (p, raw, 8);
+ }
+ }
+ }
+
/* Update the corresponding bits in xstate_bv if any SSE/AVX
registers are changed. */
fp->xstate_bv |= xstate_bv;
@@ -531,6 +585,42 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
+ if ((x86_xcr0 & I386_XSTATE_BNDREGS))
+ {
+ int bnd0r_regnum = find_regno (regcache->tdesc, "bnd0raw");
+
+
+ if ((clear_bv & I386_XSTATE_BNDREGS) != 0)
+ {
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ supply_register_zeroed (regcache, i + bnd0r_regnum);
+ }
+ else
+ {
+ p = (gdb_byte *) &fp->mpx_bnd_space[0];
+ for (i = 0; i < num_mpx_bnd_registers; i++)
+ supply_register (regcache, i + bnd0r_regnum, p + i * 16);
+ }
+
+ }
+
+ if ((x86_xcr0 & I386_XSTATE_BNDCFG))
+ {
+ int bndcfg_regnum = find_regno (regcache->tdesc, "bndcfgu");
+
+ if ((clear_bv & I386_XSTATE_BNDCFG) != 0)
+ {
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ supply_register_zeroed (regcache, i + bndcfg_regnum);
+ }
+ else
+ {
+ p = (gdb_byte *) &fp->mpx_cfg_space[0];
+ for (i = 0; i < num_mpx_cfg_registers; i++)
+ supply_register (regcache, i + bndcfg_regnum, p + i * 8);
+ }
+ }
+
supply_register_by_name (regcache, "fioff", &fp->fioff);
supply_register_by_name (regcache, "fooff", &fp->fooff);
supply_register_by_name (regcache, "mxcsr", &fp->mxcsr);