aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2025-06-09 08:17:49 +0800
committerH.J. Lu <hjl.tools@gmail.com>2025-06-19 05:46:31 +0800
commit0ef7965e5b251473f7d451739324c45b0fefaf1a (patch)
tree2c6c518f76a66bcf902080549ce6c9c9ecba88db
parent848f0e46f03f22404ed9a8aabf3fd5ce8809a1be (diff)
downloadglibc-0ef7965e5b251473f7d451739324c45b0fefaf1a.zip
glibc-0ef7965e5b251473f7d451739324c45b0fefaf1a.tar.gz
glibc-0ef7965e5b251473f7d451739324c45b0fefaf1a.tar.bz2
x86: Update tst-gnu2-tls2 tests
Update tst-gnu2-tls2 tests to set XMM0...XMM7 to all 1s in malloc to verify that XMM registers are preserved when _dl_tlsdesc_dynamic is called by clearing vectors with zeroed XMM registers before _dl_tlsdesc_dynamic and using these XMM registers to clear vectors after _dl_tlsdesc_dynamic. This improves the BZ #31372 test. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Sam James <sam@gentoo.org>
-rw-r--r--elf/tst-gnu2-tls2.c4
-rw-r--r--sysdeps/unix/sysv/linux/x86_64/Makefile8
-rw-r--r--sysdeps/x86/Makefile16
-rw-r--r--sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c2
-rw-r--r--sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c2
-rw-r--r--sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c2
-rw-r--r--sysdeps/x86/tst-gnu2-tls2.c36
-rw-r--r--sysdeps/x86/tst-gnu2-tls2.h37
8 files changed, 79 insertions, 28 deletions
diff --git a/elf/tst-gnu2-tls2.c b/elf/tst-gnu2-tls2.c
index 74637ee..6a253c9 100644
--- a/elf/tst-gnu2-tls2.c
+++ b/elf/tst-gnu2-tls2.c
@@ -25,7 +25,7 @@
#include <support/xthread.h>
#include <support/check.h>
#include <support/test-driver.h>
-#include "tst-gnu2-tls2.h"
+#include <tst-gnu2-tls2.h>
#ifndef IS_SUPPORTED
# define IS_SUPPORTED() true
@@ -75,7 +75,7 @@ close_mod (int i)
static void
access_mod (int i, const char *sym)
{
- struct tls var = { -1, -1, -1, -1 };
+ struct tls var = { -4, -4, -4, -4 };
struct tls *(*f) (struct tls *) = xdlsym (mod[i], sym);
/* Check that our malloc is called. */
malloc_counter = 0;
diff --git a/sysdeps/unix/sysv/linux/x86_64/Makefile b/sysdeps/unix/sysv/linux/x86_64/Makefile
index fb834a7..6938382 100644
--- a/sysdeps/unix/sysv/linux/x86_64/Makefile
+++ b/sysdeps/unix/sysv/linux/x86_64/Makefile
@@ -87,10 +87,10 @@ $(objpfx)tst-gnu2-tls2-amx-mod0.so: $(libsupport)
$(objpfx)tst-gnu2-tls2-amx-mod1.so: $(libsupport)
$(objpfx)tst-gnu2-tls2-amx-mod2.so: $(libsupport)
-CFLAGS-tst-gnu2-tls2-amx.c += -mamx-tile
-CFLAGS-tst-gnu2-tls2-amx-mod0.c += -mamx-tile -mtls-dialect=gnu2
-CFLAGS-tst-gnu2-tls2-amx-mod1.c += -mamx-tile -mtls-dialect=gnu2
-CFLAGS-tst-gnu2-tls2-amx-mod2.c += -mamx-tile -mtls-dialect=gnu2
+CFLAGS-tst-gnu2-tls2-amx.c += -mamx-tile -DTEST_AMX
+CFLAGS-tst-gnu2-tls2-amx-mod0.c += -mamx-tile -DTEST_AMX -mtls-dialect=gnu2
+CFLAGS-tst-gnu2-tls2-amx-mod1.c += -mamx-tile -DTEST_AMX -mtls-dialect=gnu2
+CFLAGS-tst-gnu2-tls2-amx-mod2.c += -mamx-tile -DTEST_AMX -mtls-dialect=gnu2
endif
endif # $(subdir) == elf
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index f64cee3..2aca36c 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -96,14 +96,22 @@ tst-ifunc-isa-2-ENV = GLIBC_TUNABLES=glibc.cpu.hwcaps=-SSE4_2,-AVX,-AVX2,-AVX512
tst-ifunc-isa-2-static-ENV = $(tst-ifunc-isa-2-ENV)
tst-hwcap-tunables-ARGS = -- $(host-test-program-cmd)
-CFLAGS-tst-gnu2-tls2.c += -msse
+CFLAGS-tst-gnu2-tls2.c += -msse2
CFLAGS-tst-gnu2-tls2mod0.c += -msse2 -mtune=haswell
CFLAGS-tst-gnu2-tls2mod1.c += -msse2 -mtune=haswell
CFLAGS-tst-gnu2-tls2mod2.c += -msse2 -mtune=haswell
-LDFLAGS-tst-gnu2-tls2-x86-noxsave += -Wl,-z,lazy
-LDFLAGS-tst-gnu2-tls2-x86-noxsavec += -Wl,-z,lazy
-LDFLAGS-tst-gnu2-tls2-x86-noxsavexsavec += -Wl,-z,lazy
+LDFLAGS-tst-gnu2-tls2 += -rdynamic
+LDFLAGS-tst-gnu2-tls2mod0.so += -Wl,-z,undefs
+LDFLAGS-tst-gnu2-tls2mod1.so += -Wl,-z,undefs
+LDFLAGS-tst-gnu2-tls2mod2.so += -Wl,-z,undefs
+
+CFLAGS-tst-gnu2-tls2-x86-noxsave.c += -msse2
+CFLAGS-tst-gnu2-tls2-x86-noxsavec.c += -msse2
+CFLAGS-tst-gnu2-tls2-x86-noxsavexsavec.c += -msse2
+LDFLAGS-tst-gnu2-tls2-x86-noxsave += -Wl,-z,lazy -rdynamic
+LDFLAGS-tst-gnu2-tls2-x86-noxsavec += -Wl,-z,lazy -rdynamic
+LDFLAGS-tst-gnu2-tls2-x86-noxsavexsavec += -Wl,-z,lazy -rdynamic
# Test for bug 32810: incorrect XSAVE state size if XSAVEC is disabled
# via tunable.
diff --git a/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c b/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
index f0024c1..963c4f3 100644
--- a/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
+++ b/sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
diff --git a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
index f0024c1..963c4f3 100644
--- a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
+++ b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
diff --git a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
index f0024c1..963c4f3 100644
--- a/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
+++ b/sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
diff --git a/sysdeps/x86/tst-gnu2-tls2.c b/sysdeps/x86/tst-gnu2-tls2.c
index de900a4..b3195ff 100644
--- a/sysdeps/x86/tst-gnu2-tls2.c
+++ b/sysdeps/x86/tst-gnu2-tls2.c
@@ -1,20 +1,26 @@
-#ifndef __x86_64__
-#include <sys/platform/x86.h>
+#ifndef TEST_AMX
+# ifndef __x86_64__
+# include <sys/platform/x86.h>
-#define IS_SUPPORTED() CPU_FEATURE_ACTIVE (SSE2)
-#endif
+# define IS_SUPPORTED() CPU_FEATURE_ACTIVE (SSE2)
+# endif
-/* Clear XMM0...XMM7 */
-#define PREPARE_MALLOC() \
-{ \
- asm volatile ("xorps %%xmm0, %%xmm0" : : : "xmm0" ); \
- asm volatile ("xorps %%xmm1, %%xmm1" : : : "xmm1" ); \
- asm volatile ("xorps %%xmm2, %%xmm2" : : : "xmm2" ); \
- asm volatile ("xorps %%xmm3, %%xmm3" : : : "xmm3" ); \
- asm volatile ("xorps %%xmm4, %%xmm4" : : : "xmm4" ); \
- asm volatile ("xorps %%xmm5, %%xmm5" : : : "xmm5" ); \
- asm volatile ("xorps %%xmm6, %%xmm6" : : : "xmm6" ); \
- asm volatile ("xorps %%xmm7, %%xmm7" : : : "xmm7" ); \
+/* Set XMM0...XMM7 to all 1s. */
+# define PREPARE_MALLOC() \
+{ \
+ asm volatile ("pcmpeqd %%xmm0, %%xmm0" : : : "xmm0" ); \
+ asm volatile ("pcmpeqd %%xmm1, %%xmm1" : : : "xmm1" ); \
+ asm volatile ("pcmpeqd %%xmm2, %%xmm2" : : : "xmm2" ); \
+ asm volatile ("pcmpeqd %%xmm3, %%xmm3" : : : "xmm3" ); \
+ asm volatile ("pcmpeqd %%xmm4, %%xmm4" : : : "xmm4" ); \
+ asm volatile ("pcmpeqd %%xmm5, %%xmm5" : : : "xmm5" ); \
+ asm volatile ("pcmpeqd %%xmm6, %%xmm6" : : : "xmm6" ); \
+ asm volatile ("pcmpeqd %%xmm7, %%xmm7" : : : "xmm7" ); \
}
+#endif
#include <elf/tst-gnu2-tls2.c>
+
+#ifndef TEST_AMX
+v2di v1, v2, v3;
+#endif
diff --git a/sysdeps/x86/tst-gnu2-tls2.h b/sysdeps/x86/tst-gnu2-tls2.h
new file mode 100644
index 0000000..fdbb565
--- /dev/null
+++ b/sysdeps/x86/tst-gnu2-tls2.h
@@ -0,0 +1,37 @@
+/* Test TLSDESC relocation, x86 version.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef TEST_AMX
+# include <support/check.h>
+
+typedef long long v2di __attribute__((vector_size(16)));
+extern v2di v1, v2, v3;
+
+# define BEFORE_TLSDESC_CALL() \
+ v1 = __extension__(v2di){0, 0}; \
+ v2 = __extension__(v2di){0, 0};
+
+# define AFTER_TLSDESC_CALL() \
+ v3 = __extension__(v2di){0, 0}; \
+ asm volatile ("" : "+x" (v3)); \
+ union { v2di x; long long a[2]; } u; \
+ u.x = v3; \
+ TEST_VERIFY_EXIT (u.a[0] == 0 && u.a[1] == 0);
+#endif
+
+#include <elf/tst-gnu2-tls2.h>