aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/i387-fp.cc
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-08-28 14:18:19 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2023-08-28 14:18:19 -0700
commit03e6fe7e0a6fc4adccf59681962490a10fb31f7c (patch)
tree264e4e5f5946d0836d8f27f4e31c9ff54806a29c /gdbserver/i387-fp.cc
parent8938f5311757ebd7dc88edb860d568d26756ac3b (diff)
downloadbinutils-03e6fe7e0a6fc4adccf59681962490a10fb31f7c.zip
binutils-03e6fe7e0a6fc4adccf59681962490a10fb31f7c.tar.gz
binutils-03e6fe7e0a6fc4adccf59681962490a10fb31f7c.tar.bz2
gdbserver: Add a function to set the XSAVE mask and size.
Make x86_xcr0 private to i387-fp.cc and use i387_set_xsave_mask to set the value instead. Add a static global instance of x86_xsave_layout and initialize it in the new function as well to be used in a future commit to parse XSAVE extended state regions. Update the Linux port to use this function rather than setting x86_xcr0 directly. In the case that XML is not supported, don't bother setting x86_xcr0 to the default value but just omit the call to i387_set_xsave_mask as i387-fp.cc defaults to the SSE case used for non-XML. In addition, use x86_xsave_length to determine the size of the XSAVE register set via CPUID. Approved-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdbserver/i387-fp.cc')
-rw-r--r--gdbserver/i387-fp.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
index 49795ac..b8d7a91 100644
--- a/gdbserver/i387-fp.cc
+++ b/gdbserver/i387-fp.cc
@@ -19,12 +19,18 @@
#include "server.h"
#include "i387-fp.h"
#include "gdbsupport/x86-xstate.h"
+#include "nat/x86-xstate.h"
+
+/* Default to SSE. */
+static unsigned long long x86_xcr0 = X86_XSTATE_SSE_MASK;
static const int num_mpx_bnd_registers = 4;
static const int num_mpx_cfg_registers = 2;
static const int num_avx512_k_registers = 8;
static const int num_pkeys_registers = 1;
+static x86_xsave_layout xsave_layout;
+
/* Note: These functions preserve the reserved bits in control registers.
However, gdbserver promptly throws away that information. */
@@ -974,5 +980,11 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
-/* Default to SSE. */
-unsigned long long x86_xcr0 = X86_XSTATE_SSE_MASK;
+/* See i387-fp.h. */
+
+void
+i387_set_xsave_mask (uint64_t xcr0, int len)
+{
+ x86_xcr0 = xcr0;
+ xsave_layout = x86_fetch_xsave_layout (xcr0, len);
+}