From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 992B93858408; Tue, 26 Mar 2024 18:59:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 992B93858408 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711479559; bh=PH8EuAsopS9KC/Bh6eyRT28l0o1RydOt2MSb87Xxeug=; h=From:To:Subject:Date:From; b=h81TvDZLx6ChjOLcCyhY9+ujIzivSz1x1JSwc7XrIp3M8z126pgqIGR4IJ575kMQW sZwFtgetvB+F3XHYccBOi1I2N5baULWrsT3p7xRRbTcRguIHj2VjXzrnLiXrllXxDI PT/kIWzngsQqHlpudc7DZpZ4GqMP7hI9L49wLsSY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Revert "gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition" X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: 49a7660fb50cc3c68e7830eb098905d068a3ccbf X-Git-Newrev: f06daade43dc8ec839e2eb3bd8b200c4b3f9682b Message-Id: <20240326185919.992B93858408@sourceware.org> Date: Tue, 26 Mar 2024 18:59:19 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Df06daade43dc= 8ec839e2eb3bd8b200c4b3f9682b commit f06daade43dc8ec839e2eb3bd8b200c4b3f9682b Author: Andrew Burgess Date: Tue Mar 26 18:52:51 2024 +0000 Revert "gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition" =20 This reverts commit 7816b81e9b36ea0f57662bfd7446b573bf0c9e54. Diff: --- gdb/amd64-linux-tdep.c | 1 - gdb/i386-linux-tdep.c | 1 - gdb/i386-linux-tdep.h | 20 ++++++++++++++++++++ gdb/nat/x86-linux.h | 20 -------------------- gdbserver/linux-x86-low.cc | 22 +++++++++++++++++++++- 5 files changed, 41 insertions(+), 23 deletions(-) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index a512ec5dd02..1deb13b4e9a 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -42,7 +42,6 @@ #include "arch/amd64.h" #include "target-descriptions.h" #include "expop.h" -#include "nat/x86-linux.h" =20 /* The syscall's XML filename for i386. */ #define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml" diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 8dd7203b6c3..a2f937690c2 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -40,7 +40,6 @@ =20 #include "i387-tdep.h" #include "gdbsupport/x86-xstate.h" -#include "nat/x86-linux.h" =20 /* The syscall's XML filename for i386. */ #define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml" diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h index 07593c6a8ec..5891747572b 100644 --- a/gdb/i386-linux-tdep.h +++ b/gdb/i386-linux-tdep.h @@ -58,6 +58,26 @@ extern void i386_linux_report_signal_info (struct gdbarc= h *gdbarch, /* Return the target description according to XCR0. */ extern const struct target_desc *i386_linux_read_description (uint64_t xcr= 0); =20 +/* Format of XSAVE extended state is: + struct + { + fxsave_bytes[0..463] + sw_usable_bytes[464..511] + xstate_hdr_bytes[512..575] + extended state regions (AVX, MPX, AVX512, PKRU, etc.) + }; + + Same memory layout will be used for the coredump NT_X86_XSTATE + representing the XSAVE extended state registers. + + The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled + extended state mask, which is the same as the extended control register + 0 (the XFEATURE_ENABLED_MASK register), XCR0. We can use this mask + together with the mask saved in the xstate_hdr_bytes to determine what + states the processor/OS supports and what state, used or initialized, + the process/thread is in. */=20 +#define I386_LINUX_XSAVE_XCR0_OFFSET 464 + extern int i386_linux_gregset_reg_offset[]; =20 /* Return x86 siginfo type. */ diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h index 855a8d14f91..15153ea277e 100644 --- a/gdb/nat/x86-linux.h +++ b/gdb/nat/x86-linux.h @@ -22,26 +22,6 @@ =20 #include "nat/linux-nat.h" =20 -/* Format of XSAVE extended state is: - struct - { - fxsave_bytes[0..463] - sw_usable_bytes[464..511] - xstate_hdr_bytes[512..575] - extended state regions (AVX, MPX, AVX512, PKRU, etc.) - }; - - Same memory layout will be used for the coredump NT_X86_XSTATE - representing the XSAVE extended state registers. - - The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled - extended state mask, which is the same as the extended control register - 0 (the XFEATURE_ENABLED_MASK register), XCR0. We can use this mask - together with the mask saved in the xstate_hdr_bytes to determine what - states the processor/OS supports and what state, used or initialized, - the process/thread is in. */ -#define I386_LINUX_XSAVE_XCR0_OFFSET 464 - /* Set whether our local mirror of LWP's debug registers has been changed since the values were last written to the thread. Nonzero indicates that a change has been made, zero indicates no change. */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 30d876efc5d..872c3fc69c7 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -27,7 +27,6 @@ #include "gdbsupport/x86-xstate.h" #include "nat/x86-xstate.h" #include "nat/gdb_ptrace.h" -#include "nat/x86-linux.h" =20 #ifdef __x86_64__ #include "nat/amd64-linux-siginfo.h" @@ -833,6 +832,27 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_= byte *inf, int direction) =0C static int use_xml; =20 +/* Format of XSAVE extended state is: + struct + { + fxsave_bytes[0..463] + sw_usable_bytes[464..511] + xstate_hdr_bytes[512..575] + avx_bytes[576..831] + future_state etc + }; + + Same memory layout will be used for the coredump NT_X86_XSTATE + representing the XSAVE extended state registers. + + The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled + extended state mask, which is the same as the extended control register + 0 (the XFEATURE_ENABLED_MASK register), XCR0. We can use this mask + together with the mask saved in the xstate_hdr_bytes to determine what + states the processor/OS supports and what state, used or initialized, + the process/thread is in. */ +#define I386_LINUX_XSAVE_XCR0_OFFSET 464 + /* Does the current host support the GETFPXREGS request? The header file may or may not define it, and even if it is defined, the kernel will return EIO if it's running on a pre-SSE processor. */