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>
This commit is contained in:
H.J. Lu 2025-06-09 08:17:49 +08:00
parent 848f0e46f0
commit 0ef7965e5b
8 changed files with 80 additions and 29 deletions

View 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;

View 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

View 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.

View File

@ -1 +1 @@
#include <elf/tst-gnu2-tls2.c>
#include <tst-gnu2-tls2.c>

View File

@ -1 +1 @@
#include <elf/tst-gnu2-tls2.c>
#include <tst-gnu2-tls2.c>

View File

@ -1 +1 @@
#include <elf/tst-gnu2-tls2.c>
#include <tst-gnu2-tls2.c>

View 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)
# define IS_SUPPORTED() CPU_FEATURE_ACTIVE (SSE2)
# endif
/* 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
/* 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" ); \
}
#include <elf/tst-gnu2-tls2.c>
#ifndef TEST_AMX
v2di v1, v2, v3;
#endif

View File

@ -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>