From: Walfred Tedeschi <walfred.tedeschi@intel.com>
To: tromey@redhat.com, mark.kettenis@xs4all.nl
Cc: gdb-patches@sourceware.org,
Walfred Tedeschi <walfred.tedeschi@intel.com>
Subject: [PATCH V7 4/8] MPX for amd64
Date: Wed, 09 Oct 2013 12:01:00 -0000 [thread overview]
Message-ID: <1381320034-4092-5-git-send-email-walfred.tedeschi@intel.com> (raw)
In-Reply-To: <1381320034-4092-1-git-send-email-walfred.tedeschi@intel.com>
2013-06-24 Walfred Tedeschi <walfred.tedeschi@intel.com>
* amd64-linux-nat.c (amd64_linux_gregset32_reg_offset):
Add MPX registers.
(amd64_linux_read_description): Add initialization for MPX and
AVX independently.
* amd64-linux-tdep.c: Includes features/i386/amd64-mpx-linux.c and
features/i386/x32-mpx-linux.c.
(amd64_linux_gregset_reg_offset): Add MPX registers.
(amd64_linux_core_read_description): Add initialization for MPX
registers.
(_initialize_amd64_linux_tdep): Initialize MPX targets.
* amd64-linux-tdep.h (AMD64_LINUX_NUM_REGS): Set it to the last
register on the list.
(tdesc_amd64_mpx_linux and tdesc_x32_mpx_linux) Add new targets
for MPX.
* amd64-tdep.c: Includes features/i386/amd64-mpx.c and
features/i386/x32-mpx.c.
(amd64_mpx_names): MPX register names.
(amd64_init_abi): Add MPX register while initializing the ABI.
(_initialize_amd64_tdep): Initialize MPX targets.
* amd64-tdep.h (amd64_regnum): Add MPX registers.
(AMD64_NUM_REGS): Set number of registers taking MPX into account.
---
gdb/amd64-linux-nat.c | 43 ++++++++++++++++++++++++++++++++++---------
gdb/amd64-linux-tdep.c | 14 +++++++++++++-
gdb/amd64-linux-tdep.h | 4 +++-
gdb/amd64-tdep.c | 16 ++++++++++++++++
gdb/amd64-tdep.h | 8 ++++++--
5 files changed, 72 insertions(+), 13 deletions(-)
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c
index a61d218..a24b415 100644
--- a/gdb/amd64-linux-nat.c
+++ b/gdb/amd64-linux-nat.c
@@ -100,7 +100,9 @@ static int amd64_linux_gregset32_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
- ORIG_RAX * 8 /* "orig_eax" */
+ -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
+ -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */
+ ORIG_RAX * 8, /* "orig_eax" */
};
\f
@@ -1094,18 +1096,41 @@ amd64_linux_read_description (struct target_ops *ops)
}
/* Check the native XCR0 only if PTRACE_GETREGSET is available. */
- if (have_ptrace_getregset
- && (xcr0 & I386_XSTATE_AVX_MASK) == I386_XSTATE_AVX_MASK)
+ if (have_ptrace_getregset && (xcr0 & I386_XSTATE_ALL_MASK))
{
- if (is_64bit)
+ switch (xcr0 & I386_XSTATE_ALL_MASK)
{
- if (is_x32)
- return tdesc_x32_avx_linux;
+ case I386_XSTATE_MPX_MASK:
+ if (is_64bit)
+ {
+ if (is_x32)
+ return tdesc_x32_mpx_linux;
+ else
+ return tdesc_amd64_mpx_linux;
+ }
+ else
+ return tdesc_i386_mpx_linux;
+ case I386_XSTATE_AVX_MASK:
+ if (is_64bit)
+ {
+ if (is_x32)
+ return tdesc_x32_avx_linux;
+ else
+ return tdesc_amd64_avx_linux;
+ }
+ else
+ return tdesc_i386_avx_linux;
+ default:
+ if (is_64bit)
+ {
+ if (is_x32)
+ return tdesc_x32_linux;
+ else
+ return tdesc_amd64_linux;
+ }
else
- return tdesc_amd64_avx_linux;
+ return tdesc_i386_linux;
}
- else
- return tdesc_i386_avx_linux;
}
else
{
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 4f67762..9740aff 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -42,8 +42,10 @@
#include "features/i386/amd64-linux.c"
#include "features/i386/amd64-avx-linux.c"
+#include "features/i386/amd64-mpx-linux.c"
#include "features/i386/x32-linux.c"
#include "features/i386/x32-avx-linux.c"
+#include "features/i386/x32-mpx-linux.c"
/* The syscall's XML filename for i386. */
#define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml"
@@ -96,6 +98,8 @@ int amd64_linux_gregset_reg_offset[] =
-1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */
+ -1, -1, /* MPX registers BNDCFGU and BNDSTATUS. */
15 * 8 /* "orig_rax" */
};
\f
@@ -1287,8 +1291,14 @@ amd64_linux_core_read_description (struct gdbarch *gdbarch,
{
/* Linux/x86-64. */
uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd);
- switch ((xcr0 & I386_XSTATE_AVX_MASK))
+
+ switch (xcr0 & I386_XSTATE_ALL_MASK)
{
+ case I386_XSTATE_MPX_MASK:
+ if (gdbarch_ptr_bit (gdbarch) == 32)
+ return tdesc_x32_mpx_linux;
+ else
+ return tdesc_amd64_mpx_linux;
case I386_XSTATE_AVX_MASK:
if (gdbarch_ptr_bit (gdbarch) == 32)
return tdesc_x32_avx_linux;
@@ -1623,6 +1633,8 @@ _initialize_amd64_linux_tdep (void)
/* Initialize the Linux target description. */
initialize_tdesc_amd64_linux ();
initialize_tdesc_amd64_avx_linux ();
+ initialize_tdesc_amd64_mpx_linux ();
initialize_tdesc_x32_linux ();
initialize_tdesc_x32_avx_linux ();
+ initialize_tdesc_x32_mpx_linux ();
}
diff --git a/gdb/amd64-linux-tdep.h b/gdb/amd64-linux-tdep.h
index e9eaeaa..5783fa3 100644
--- a/gdb/amd64-linux-tdep.h
+++ b/gdb/amd64-linux-tdep.h
@@ -26,7 +26,7 @@
/* Register number for the "orig_rax" register. If this register
contains a value >= 0 it is interpreted as the system call number
that the kernel is supposed to restart. */
-#define AMD64_LINUX_ORIG_RAX_REGNUM (AMD64_YMM15H_REGNUM + 1)
+#define AMD64_LINUX_ORIG_RAX_REGNUM (AMD64_BNDSTATUS_REGNUM + 1)
/* Total number of registers for GNU/Linux. */
#define AMD64_LINUX_NUM_REGS (AMD64_LINUX_ORIG_RAX_REGNUM + 1)
@@ -34,8 +34,10 @@
/* Linux target description. */
extern struct target_desc *tdesc_amd64_linux;
extern struct target_desc *tdesc_amd64_avx_linux;
+extern struct target_desc *tdesc_amd64_mpx_linux;
extern struct target_desc *tdesc_x32_linux;
extern struct target_desc *tdesc_x32_avx_linux;
+extern struct target_desc *tdesc_x32_mpx_linux;
/* Enum that defines the syscall identifiers for amd64 linux.
Used for process record/replay, these will be translated into
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 4d6b325..d0a62a7 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -43,8 +43,10 @@
#include "features/i386/amd64.c"
#include "features/i386/amd64-avx.c"
+#include "features/i386/amd64-mpx.c"
#include "features/i386/x32.c"
#include "features/i386/x32-avx.c"
+#include "features/i386/x32-mpx.c"
#include "ax.h"
#include "ax-gdb.h"
@@ -92,6 +94,11 @@ static const char *amd64_ymmh_names[] =
"ymm12h", "ymm13h", "ymm14h", "ymm15h"
};
+static const char *amd64_mpx_names[] =
+{
+ "bnd0raw", "bnd1raw", "bnd2raw", "bnd3raw", "bndcfgu", "bndstatus"
+};
+
/* DWARF Register Number Mapping as defined in the System V psABI,
section 3.6. */
@@ -2845,6 +2852,13 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->ymm0h_regnum = AMD64_YMM0H_REGNUM;
}
+ if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.mpx") != NULL)
+ {
+ tdep->mpx_register_names = amd64_mpx_names;
+ tdep->bndcfgu_regnum = AMD64_BNDCFGU_REGNUM;
+ tdep->bnd0r_regnum = AMD64_BND0R_REGNUM;
+ }
+
tdep->num_byte_regs = 20;
tdep->num_word_regs = 16;
tdep->num_dword_regs = 16;
@@ -2986,8 +3000,10 @@ _initialize_amd64_tdep (void)
{
initialize_tdesc_amd64 ();
initialize_tdesc_amd64_avx ();
+ initialize_tdesc_amd64_mpx ();
initialize_tdesc_x32 ();
initialize_tdesc_x32_avx ();
+ initialize_tdesc_x32_mpx ();
}
\f
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 265e535..ff58c35 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -64,13 +64,17 @@ enum amd64_regnum
AMD64_XMM1_REGNUM, /* %xmm1 */
AMD64_MXCSR_REGNUM = AMD64_XMM0_REGNUM + 16,
AMD64_YMM0H_REGNUM, /* %ymm0h */
- AMD64_YMM15H_REGNUM = AMD64_YMM0H_REGNUM + 15
+ AMD64_YMM15H_REGNUM = AMD64_YMM0H_REGNUM + 15,
+ AMD64_BND0R_REGNUM = AMD64_YMM15H_REGNUM + 1,
+ AMD64_BND3R_REGNUM = AMD64_BND0R_REGNUM + 3,
+ AMD64_BNDCFGU_REGNUM,
+ AMD64_BNDSTATUS_REGNUM
};
/* Number of general purpose registers. */
#define AMD64_NUM_GREGS 24
-#define AMD64_NUM_REGS (AMD64_YMM15H_REGNUM + 1)
+#define AMD64_NUM_REGS (AMD64_BNDSTATUS_REGNUM + 1)
extern struct displaced_step_closure *amd64_displaced_step_copy_insn
(struct gdbarch *gdbarch, CORE_ADDR from, CORE_ADDR to,
--
1.7.10.4
next prev parent reply other threads:[~2013-10-09 12:01 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-09 12:01 [PATCH V7 0/8] Intel(R) MPX register support Walfred Tedeschi
2013-10-09 12:01 ` [PATCH V7 7/8] Add MPX registers tests Walfred Tedeschi
2013-10-09 12:01 ` Walfred Tedeschi [this message]
2013-10-09 12:01 ` [PATCH V7 1/8] Fix conditions in creating a bitfield Walfred Tedeschi
2013-10-09 12:01 ` [PATCH V7 6/8] Add pretty-printer for MPX bnd registers Walfred Tedeschi
2013-10-09 12:01 ` [PATCH V7 8/8] Add MPX feature description to GDB manual Walfred Tedeschi
2013-11-18 20:26 ` Pedro Alves
2013-11-19 8:32 ` Tedeschi, Walfred
2013-10-09 12:01 ` [PATCH V7 3/8] Add MPX support for i386 Walfred Tedeschi
2013-10-09 12:02 ` [PATCH V7 2/8] Add MPX registers XML files Walfred Tedeschi
2013-10-20 19:23 ` [PATCH V7 0/8] Intel(R) MPX register support Mark Kettenis
2013-10-21 11:33 ` Tedeschi, Walfred
2013-11-04 9:07 ` Tedeschi, Walfred
2013-11-04 10:30 ` Mark Kettenis
2013-11-11 8:24 ` Tedeschi, Walfred
2013-11-11 10:12 ` Mark Kettenis
2013-11-11 11:48 ` Walfred Tedeschi
2013-11-19 10:28 ` Tedeschi, Walfred
2013-11-19 11:13 ` Mark Kettenis
2013-11-19 12:15 ` Tedeschi, Walfred
[not found] ` <1381320034-4092-6-git-send-email-walfred.tedeschi@intel.com>
2013-11-19 15:14 ` [PATCH V7 5/8] Add MPX support to gdbserver Pedro Alves
2013-11-19 15:43 ` Tedeschi, Walfred
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1381320034-4092-5-git-send-email-walfred.tedeschi@intel.com \
--to=walfred.tedeschi@intel.com \
--cc=gdb-patches@sourceware.org \
--cc=mark.kettenis@xs4all.nl \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox