1 /* Verify that changing AVX registers in audit library won't affect
2 function parameter passing/return. */
10 #include <bits/wordsize.h>
11 #include <gnu/lib-names.h>
14 la_version (unsigned int v
)
18 printf ("version: %u\n", v
);
21 sprintf (buf
, "%u", v
);
27 la_activity (uintptr_t *cookie
, unsigned int flag
)
29 if (flag
== LA_ACT_CONSISTENT
)
30 printf ("activity: consistent\n");
31 else if (flag
== LA_ACT_ADD
)
32 printf ("activity: add\n");
33 else if (flag
== LA_ACT_DELETE
)
34 printf ("activity: delete\n");
36 printf ("activity: unknown activity %u\n", flag
);
40 la_objsearch (const char *name
, uintptr_t *cookie
, unsigned int flag
)
44 if (flag
== LA_SER_ORIG
)
45 flagstr
= "LA_SET_ORIG";
46 else if (flag
== LA_SER_LIBPATH
)
47 flagstr
= "LA_SER_LIBPATH";
48 else if (flag
== LA_SER_RUNPATH
)
49 flagstr
= "LA_SER_RUNPATH";
50 else if (flag
== LA_SER_CONFIG
)
51 flagstr
= "LA_SER_CONFIG";
52 else if (flag
== LA_SER_DEFAULT
)
53 flagstr
= "LA_SER_DEFAULT";
54 else if (flag
== LA_SER_SECURE
)
55 flagstr
= "LA_SER_SECURE";
58 sprintf (buf
, "unknown flag %d", flag
);
61 printf ("objsearch: %s, %s\n", name
, flagstr
);
67 la_objopen (struct link_map
*l
, Lmid_t lmid
, uintptr_t *cookie
)
69 printf ("objopen: %ld, %s\n", lmid
, l
->l_name
);
75 la_preinit (uintptr_t *cookie
)
81 la_objclose (uintptr_t *cookie
)
83 printf ("objclose\n");
88 la_symbind64 (Elf64_Sym
*sym
, unsigned int ndx
, uintptr_t *refcook
,
89 uintptr_t *defcook
, unsigned int *flags
, const char *symname
)
91 printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
92 symname
, (long int) sym
->st_value
, ndx
, *flags
);
98 # define pltenter la_x86_64_gnu_pltenter
99 # define pltexit la_x86_64_gnu_pltexit
100 # define La_regs La_x86_64_regs
101 # define La_retval La_x86_64_retval
103 # define pltenter la_x32_gnu_pltenter
104 # define pltexit la_x32_gnu_pltexit
105 # define La_regs La_x32_regs
106 # define La_retval La_x32_retval
108 #define int_retval lrv_rax
110 #include <tst-audit.h>
113 #include <immintrin.h>
119 __attribute ((always_inline
))
124 unsigned int eax
, ebx
, ecx
, edx
;
126 if (__get_cpuid (1, &eax
, &ebx
, &ecx
, &edx
)
135 #include <emmintrin.h>
139 pltenter (ElfW(Sym
) *sym
, unsigned int ndx
, uintptr_t *refcook
,
140 uintptr_t *defcook
, La_regs
*regs
, unsigned int *flags
,
141 const char *symname
, long int *framesizep
)
143 printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
144 symname
, (long int) sym
->st_value
, ndx
, *flags
);
147 if (check_avx () && strcmp (symname
, "audit_test") == 0)
151 __m128i xmm
= _mm_setzero_si128 ();
152 for (i
= 0; i
< 8; i
++)
153 if (memcmp (®s
->lr_xmm
[i
], &xmm
, sizeof (xmm
))
154 || memcmp (®s
->lr_vector
[i
], &xmm
, sizeof (xmm
)))
157 for (i
= 0; i
< 8; i
+= 2)
159 regs
->lr_xmm
[i
] = (La_x86_64_xmm
) _mm_set1_epi32 (i
+ 1);
160 regs
->lr_vector
[i
].xmm
[0] = regs
->lr_xmm
[i
];
161 regs
->lr_vector
[i
+ 1].ymm
[0]
162 = (La_x86_64_ymm
) _mm256_set1_epi32 (i
+ 2);
163 regs
->lr_xmm
[i
+ 1] = regs
->lr_vector
[i
+ 1].xmm
[0];
166 __m256i ymm
= _mm256_set1_epi32 (-1);
167 asm volatile ("vmovdqa %0, %%ymm0" : : "x" (ymm
) : "xmm0" );
168 asm volatile ("vmovdqa %0, %%ymm1" : : "x" (ymm
) : "xmm1" );
169 asm volatile ("vmovdqa %0, %%ymm2" : : "x" (ymm
) : "xmm2" );
170 asm volatile ("vmovdqa %0, %%ymm3" : : "x" (ymm
) : "xmm3" );
171 asm volatile ("vmovdqa %0, %%ymm4" : : "x" (ymm
) : "xmm4" );
172 asm volatile ("vmovdqa %0, %%ymm5" : : "x" (ymm
) : "xmm5" );
173 asm volatile ("vmovdqa %0, %%ymm6" : : "x" (ymm
) : "xmm6" );
174 asm volatile ("vmovdqa %0, %%ymm7" : : "x" (ymm
) : "xmm7" );
180 return sym
->st_value
;
184 pltexit (ElfW(Sym
) *sym
, unsigned int ndx
, uintptr_t *refcook
,
185 uintptr_t *defcook
, const La_regs
*inregs
, La_retval
*outregs
,
188 printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
189 symname
, (long int) sym
->st_value
, ndx
,
190 (ptrdiff_t) outregs
->int_retval
);
193 if (check_avx () && strcmp (symname
, "audit_test") == 0)
197 __m128i xmm
= _mm_setzero_si128 ();
198 if (memcmp (&outregs
->lrv_xmm0
, &xmm
, sizeof (xmm
))
199 || memcmp (&outregs
->lrv_vector0
, &xmm
, sizeof (xmm
)))
204 for (i
= 0; i
< 8; i
+= 2)
206 xmm
= _mm_set1_epi32 (i
+ 0x100);
207 if (memcmp (&inregs
->lr_xmm
[i
], &xmm
, sizeof (xmm
))
208 || memcmp (&inregs
->lr_vector
[i
], &xmm
, sizeof (xmm
)))
211 ymm
= _mm256_set1_epi32 (i
+ 0x101);
212 if (memcmp (&inregs
->lr_xmm
[i
+ 1],
213 &inregs
->lr_vector
[i
+ 1].xmm
[0], sizeof (xmm
))
214 || memcmp (&inregs
->lr_vector
[i
+ 1], &ymm
, sizeof (ymm
)))
218 outregs
->lrv_vector0
.ymm
[0]
219 = (La_x86_64_ymm
) _mm256_set1_epi32 (0x12349876);
221 ymm
= _mm256_set1_epi32 (-1);
222 asm volatile ("vmovdqa %0, %%ymm0" : : "x" (ymm
) : "xmm0" );
223 asm volatile ("vmovdqa %0, %%ymm1" : : "x" (ymm
) : "xmm1" );