aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat/x86-xstate.c
AgeCommit message (Collapse)AuthorFilesLines
2024-09-25gdb, gdbserver, python, testsuite: Remove MPX.Schimpe, Christina1-2/+0
GDB deprecated the commands "show/set mpx bound" in GDB 15.1, as Intel listed Intel(R) Memory Protection Extensions (MPX) as removed in 2019. MPX is also deprecated in gcc (since v9.1), the linux kernel (since v5.6) and glibc (since v2.35). Let's now remove MPX support in GDB completely. This includes the removal of: - MPX functionality including register support - deprecated mpx commands - i386 and amd64 implementation of the hooks report_signal_info and get_siginfo_type - tests - and pretty printer. We keep MPX register numbers to not break compatibility with old gdbservers. Approved-By: Felix Willgerodt <felix.willgerodt@intel.com>
2024-03-26gdb, gdbserver, gdbsupport: remove includes of early headersSimon Marchi1-1/+0
Now that defs.h, server.h and common-defs.h are included via the `-include` option, it is no longer necessary for source files to include them. Remove all the inclusions of these files I could find. Update the generation scripts where relevant. Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837 Approved-By: Pedro Alves <pedro@palves.net>
2024-01-12Update copyright year range in header of all files managed by GDBAndrew Burgess1-1/+1
This commit is the result of the following actions: - Running gdb/copyright.py to update all of the copyright headers to include 2024, - Manually updating a few files the copyright.py script told me to update, these files had copyright headers embedded within the file, - Regenerating gdbsupport/Makefile.in to refresh it's copyright date, - Using grep to find other files that still mentioned 2023. If these files were updated last year from 2022 to 2023 then I've updated them this year to 2024. I'm sure I've probably missed some dates. Feel free to fix them up as you spot them.
2023-09-28gdb/x86: use size of XSAVE area of enabled featuresSimon Marchi1-3/+3
Since commit b42405a1594 ("gdb: Update x86 Linux architectures to support XSAVE layouts."), the test gdb.base/gcore.exp fails on my AMD Ryzen 3700X machine: FAIL: gdb.base/gcore.exp: corefile restored all registers The test gets the register state (saves the output of "info all-registers"), saves a core with the "gcore" command, loads the core, and checks the register state against the one previously saved. The problem is that when reading registers from the core file, the last half of ymm registers is unavailable: (gdb) print $ymm0.v32_int8 $1 = {0, -77, -23, -9, -1, 127, 0, 0, 0, -77, -23, -9, -1, 127, 0, 0, <unavailable> <repeats 16 times>} One strange thing with this machine is that the bitset of state components supported by XCR0 is 0x207, meaning "x87 | SSE | AVX | PKRU", but XCR0 at runtime is 0x7, meaning "x87 | SSE | AVX". So, PKRU appears to be supported by the processor, but disabled by the kernel. I didn't find why yet. From CPUID leaf EAX=0Dh, ECX=00h, GDB can get: - from EBX: max size of the XSAVE area required by features currently enabled in XCR0. On my machine, it's 0x340 (832). - from ECX: max size of the XSAVE area required by all features supported by XCR0. On my machine, it's 0x380 (896). At runtime, GDB uses ECX (max size required by all supported features) to fill the x86_xsave_layout::sizeof_xsave. So, when writing the core file note for the XSAVE state, it writes a note of size 896, even though it doesn't write the PKRU state. When loading back the core, GDB tries to figure out the layout of the XSAVE area based on what features are enabled in XCR0 and the size of the note (the size of the XSAVE area). Since my combination of XCR0 and size of XSAVE area doesn't match any combination known by GDB, GDB falls back to a gdbarch supporting only x87 and SSE. This patch changes GDB to populate the x86_xsave_layout::sizeof_xsave field (and consequently the size of the XSAVE state note in core files) using EBX, the size of the XSAVE area required by currently enabled features in XCR0. This makes i387_guess_xsave_layout recognize my case with this condition: else if (HAS_AVX (xcr0) && xsave_size == 832) { /* Intel and AMD CPUs supporting AVX. */ layout.avx_offset = 576; } In other words, just as if my machine didn't support PKRU at all. Another reason why I think this change makes sense is that XSAVE state notes in kernel-generated cores on this machine have size 832. So this change makes GDB-generated cores more similar to kernel-generated ones, reducing the diversity of XSAVE state notes that GDB needs to be able to figure out. Note that if PKRU was enabled on my machine, then the effective XSAVE area size would be 896 bytes. We would need to add a case in i387_guess_xsave_layout for that combination, since there is no currently. But I don't have a way to test that right now, since I don't know why PKRU is disabled. Relevant review note from John Baldwin: One further note is that the Linux x86 arches use x86_xsave_length() to infer ("guess") the size of the XSAVE register set that the Linux kernel writes out in core dumps. On FreeBSD x86 arches, GDB is able to query this size directly from the kernel via ptrace. My use of ECX for this guess earlier was just not the best guess. In the case that the kernel enables all of the available features, then ECX and EBX have the same values, so this only matters for a system where the kernel has enabled a subset of available XSAVE extensions. Change-Id: If64f30307f3a2e5ca3e1fd1cb7379ea840805a85 Reviewed-By: John Baldwin <jhb@FreeBSD.org>
2023-08-28x86 nat: Add helper functions to save the XSAVE layout for the host.John Baldwin1-0/+67
x86_xsave_length returns the total length of the XSAVE state area standard format as queried from CPUID. x86_fetch_xsave_layout uses CPUID to query the offsets of XSAVE extended regions from the running host. The total length of the XSAVE state area can either be supplied by the caller if known (e.g. from FreeBSD's PT_GETXSTATEINFO) or it can be queried from the running host using x86_xsave_length. Approved-By: Simon Marchi <simon.marchi@efficios.com>