proc: use CPUID to determine ZMM_Hi256 region offset (#3831)

The offset of state component i can be found via
CPUID.(EAX=0DH,ECX=i):EBX. The ZMM_Hi256 is state component 6, so we use
CPUID to enumerate the offset instead of hardcoding.

For core dumps, we guess the ZMM_Hi256 offset based on xcr0 and the
length of xsave region. The logic comes from binutils-gdb.

Fixes #3827.
This commit is contained in:
Chen
2024-10-22 00:16:57 +08:00
committed by GitHub
parent 423644e288
commit bef326c6a5
7 changed files with 50 additions and 8 deletions

View File

@ -338,7 +338,7 @@ func readNote(r io.ReadSeeker, machineType elf.Machine) (*note, error) {
case _NT_X86_XSTATE:
if machineType == _EM_X86_64 {
var fpregs amd64util.AMD64Xstate
if err := amd64util.AMD64XstateRead(desc, true, &fpregs); err != nil {
if err := amd64util.AMD64XstateRead(desc, true, &fpregs, 0); err != nil {
return nil, err
}
note.Desc = &fpregs