68 lines
2.4 KiB
Diff
68 lines
2.4 KiB
Diff
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
|
|
From: Simon Marchi <simon.marchi@efficios.com>
|
|
Date: Thu, 11 Apr 2024 14:05:46 -0700
|
|
Subject: gdb-rhel-10464-xsave-update-18of21.patch
|
|
|
|
;; Backport "gdbserver: i387_cache_to_xsave: fix copy dest of zmm registers"
|
|
;; (Simon Marchi, RHEL-10464)
|
|
|
|
On a machine with AVX512 support (AMD EPYC 9634), I see these failures:
|
|
|
|
$ make check TESTS="gdb.arch/i386-avx512.exp" RUNTESTFLAGS="--target_board=native-gdbserver"
|
|
...
|
|
FAIL: gdb.arch/i386-avx512.exp: check contents of zmm_data[16] after writing ZMM regs
|
|
FAIL: gdb.arch/i386-avx512.exp: check contents of zmm_data[17] after writing ZMM regs
|
|
FAIL: gdb.arch/i386-avx512.exp: check contents of zmm_data[18] after writing ZMM regs
|
|
...
|
|
|
|
The problem can be reduced to:
|
|
|
|
(gdb) print $zmm16.v8_int64
|
|
$1 = {0, 0, 0, 0, 0, 0, 0, 0}
|
|
(gdb) print $zmm16.v8_int64 = {11,22,33,44,55,66,77,88}
|
|
$2 = {11, 22, 33, 44, 55, 66, 77, 88}
|
|
(gdb) print $zmm16.v8_int64
|
|
$3 = {11, 22, 33, 44, 55, 66, 77, 88}
|
|
(gdb) step
|
|
5 ++x;
|
|
(gdb) print $zmm16.v8_int64
|
|
$4 = {11, 22, 77, 88, 0, 0, 0, 0}
|
|
|
|
Writing to the local regcache in GDB works fine, but the writeback to
|
|
gdbserver (which happens when resuming / stepping) doesn't work (the
|
|
code being stepped doesn't touch AVX registers, so we don't expect the
|
|
value of zmm16 to change when stepping).
|
|
|
|
The problem is on the gdbserver side, the zmmh and ymmh portions of the
|
|
zmm register are not memcpied at the right place in the xsave buffer. Fix
|
|
that. Note now how the two modified memcpy calls match the memcmp calls
|
|
just above them.
|
|
|
|
With this patch, gdb.arch/i386-avx512.exp passes completely for me.
|
|
|
|
Change-Id: I22c417e0f5e88d4bc635a0f08f8817a031c76433
|
|
Reviewed-by: John Baldwin <jhb@FreeBSD.org>
|
|
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30818
|
|
|
|
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
|
|
--- a/gdbserver/i387-fp.cc
|
|
+++ b/gdbserver/i387-fp.cc
|
|
@@ -470,7 +470,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
|
|
if (memcmp (raw, p + 32, 32) != 0)
|
|
{
|
|
xstate_bv |= X86_XSTATE_ZMM;
|
|
- memcpy (p, raw, 32);
|
|
+ memcpy (p + 32, raw, 32);
|
|
}
|
|
|
|
/* YMMH sub-register. */
|
|
@@ -478,7 +478,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
|
|
if (memcmp (raw, p + 16, 16) != 0)
|
|
{
|
|
xstate_bv |= X86_XSTATE_ZMM;
|
|
- memcpy (p, raw, 16);
|
|
+ memcpy (p + 16, raw, 16);
|
|
}
|
|
|
|
/* XMM sub-register. */
|