public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/1] Add XSAVE layout description to Core files for debuggers to support varying XSAVE layouts
@ 2024-03-14 11:23 Vignesh Balasubramanian
  2024-03-14 11:23 ` [PATCH 1/1] x86/elf: Add a new .note section containing Xfeatures information to x86 core files Vignesh Balasubramanian
  2024-03-14 16:25 ` [PATCH 0/1] Add XSAVE layout description to Core files for debuggers to support varying XSAVE layouts Willgerodt, Felix
  0 siblings, 2 replies; 23+ messages in thread
From: Vignesh Balasubramanian @ 2024-03-14 11:23 UTC (permalink / raw)
  To: linux-kernel, linux-toolchains
  Cc: mpe, npiggin, christophe.leroy, aneesh.kumar, naveen.n.rao,
	ebiederm, keescook, x86, linuxppc-dev, linux-mm, bpetkov,
	jinisusan.george, matz, binutils, jhb, felix.willgerodt,
	Vignesh Balasubramanian

This patch proposes to add an extra .note section in the corefile to dump the CPUID information of a machine. This is being done to solve the issue of tools like the debuggers having to deal with coredumps from machines with varying XSAVE layouts in spite of having the same XCR0 bits. The new proposed .note section, at this point, consists of an array of records containing the information of each extended feature that is present. This provides details about the offsets and the sizes of the various extended save state components of the machine where the application crash occurred. Requesting a review for this patch.

Some background:

The XSAVE layouts of modern AMD and Intel CPUs differ, especially since Memory Protection Keys and the AVX-512 features have been inculcated into the AMD CPUs. This is since AMD never adopted (and hence never left room in the XSAVE layout for) the Intel MPX feature. Tools like GDB had assumed a fixed XSAVE layout matching that of Intel (based on the XCR0 mask). Hence, the core dumps from AMD CPUs didn't match the known size for the XCR0 mask. This resulted in GDB and other tools not being able to access the values of the AVX-512 and PKRU registers on AMD CPUs. To solve this, an interim solution has been accepted into GDB, and is already a part of GDB 14, thanks to these series of patches : [ https://sourceware.org/pipermail/gdb-patches/2023-March/198081.html ].
But this patch series depends on heuristics based on the total XSAVE register set size and the XCR0 mask to infer the layouts of the various register blocks for core dumps, and hence, is not a foolproof mechanism to determine the layout of the XSAVE area.

Hence this new core dump note has been proposed as a more sturdy mechanism to allow GDB/LLDB and other relevant tools to determine the layout of the XSAVE area of the machine where the corefile was dumped.
The  new core dump note (which is being proposed as a per-process .note section), NT_X86_XSAVE_LAYOUT (0x205) contains an array of structures.
Each structure describes an individual extended feature containing offset, size and flags (that is obtained through CPUID instruction) in a format roughly matching the follow C structure:

struct xfeat_component {
       u32 xfeat_type;
       u32 xfeat_sz;
       u32 xfeat_off;
       u32 xfeat_flags;
};


Vignesh Balasubramanian (1):
  x86/elf: Add a new .note section containing Xfeatures information to
    x86 core files

 arch/Kconfig                   |   9 +++
 arch/powerpc/Kconfig           |   1 +
 arch/powerpc/include/asm/elf.h |   2 -
 arch/x86/Kconfig               |   1 +
 arch/x86/include/asm/elf.h     |   7 +++
 arch/x86/kernel/fpu/xstate.c   | 101 +++++++++++++++++++++++++++++++++
 include/linux/elf.h            |   2 +-
 include/uapi/linux/elf.h       |   1 +
 8 files changed, 121 insertions(+), 3 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2024-03-26 10:09 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-14 11:23 [PATCH 0/1] Add XSAVE layout description to Core files for debuggers to support varying XSAVE layouts Vignesh Balasubramanian
2024-03-14 11:23 ` [PATCH 1/1] x86/elf: Add a new .note section containing Xfeatures information to x86 core files Vignesh Balasubramanian
2024-03-14 15:37   ` Dave Hansen
2024-03-14 16:08     ` Borislav Petkov
2024-03-14 16:19       ` Dave Hansen
2024-03-14 16:29         ` Borislav Petkov
2024-03-14 16:39           ` Dave Hansen
2024-03-26  9:59             ` Balasubrmanian, Vignesh
2024-03-15 23:51           ` Thomas Gleixner
2024-03-16 10:29             ` Borislav Petkov
2024-03-14 16:45     ` John Baldwin
2024-03-14 17:10       ` Dave Hansen
2024-03-14 17:36         ` John Baldwin
2024-03-14 17:05     ` John Baldwin
2024-03-14 16:13   ` Kees Cook
2024-03-26 10:06     ` Balasubrmanian, Vignesh
2024-03-14 22:13   ` Michael Ellerman
2024-03-26 10:09     ` Balasubrmanian, Vignesh
2024-03-15  9:59   ` kernel test robot
2024-03-15 12:59   ` kernel test robot
2024-03-14 16:25 ` [PATCH 0/1] Add XSAVE layout description to Core files for debuggers to support varying XSAVE layouts Willgerodt, Felix
2024-03-14 16:33   ` Borislav Petkov
2024-03-15  8:43     ` Willgerodt, Felix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).