]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86: Update tst-gnu2-tls2 tests
authorH.J. Lu <hjl.tools@gmail.com>
Mon, 9 Jun 2025 00:17:49 +0000 (08:17 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 18 Jun 2025 21:46:31 +0000 (05:46 +0800)
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>
elf/tst-gnu2-tls2.c
sysdeps/unix/sysv/linux/x86_64/Makefile
sysdeps/x86/Makefile
sysdeps/x86/tst-gnu2-tls2-x86-noxsave.c
sysdeps/x86/tst-gnu2-tls2-x86-noxsavec.c
sysdeps/x86/tst-gnu2-tls2-x86-noxsavexsavec.c
sysdeps/x86/tst-gnu2-tls2.c
sysdeps/x86/tst-gnu2-tls2.h [new file with mode: 0644]

index 74637ee19e157754ace5ea06b82b63f6acf0da99..6a253c9b94633a39a818e6a47ac6727f9d31e67d 100644 (file)
@@ -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;
index fb834a7089ac3ba2c0fdd1d2135a088d59f40093..6938382801fe04d4619aa2ee2d6a127f829fd9c2 100644 (file)
@@ -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
index f64cee3cd9a13c3edf001d869843bdf55cc41a0a..2aca36c1f0cbd5eeaf29ee43ea2d6534303c56a0 100644 (file)
@@ -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.
index f0024c143d1a1df5ae839b66c7edafe6276393f9..963c4f381134fa64a5b2d7f60db0614ef164195b 100644 (file)
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
index f0024c143d1a1df5ae839b66c7edafe6276393f9..963c4f381134fa64a5b2d7f60db0614ef164195b 100644 (file)
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
index f0024c143d1a1df5ae839b66c7edafe6276393f9..963c4f381134fa64a5b2d7f60db0614ef164195b 100644 (file)
@@ -1 +1 @@
-#include <elf/tst-gnu2-tls2.c>
+#include <tst-gnu2-tls2.c>
index de900a423bb70321dc19449de484fff1025c0f39..b3195fff2eb3e4386a57c6fe6f0a42037a85c5db 100644 (file)
@@ -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 (file)
index 0000000..fdbb565
--- /dev/null
@@ -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>