|
Packit Service |
82fcde |
/* Verify that changing AVX registers in audit library won't affect
|
|
Packit Service |
82fcde |
function parameter passing/return. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <dlfcn.h>
|
|
Packit Service |
82fcde |
#include <link.h>
|
|
Packit Service |
82fcde |
#include <stddef.h>
|
|
Packit Service |
82fcde |
#include <stdint.h>
|
|
Packit Service |
82fcde |
#include <stdio.h>
|
|
Packit Service |
82fcde |
#include <stdlib.h>
|
|
Packit Service |
82fcde |
#include <string.h>
|
|
Packit Service |
82fcde |
#include <unistd.h>
|
|
Packit Service |
82fcde |
#include <bits/wordsize.h>
|
|
Packit Service |
82fcde |
#include <gnu/lib-names.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
unsigned int
|
|
Packit Service |
82fcde |
la_version (unsigned int v)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
setlinebuf (stdout);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
printf ("version: %u\n", v);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
char buf[20];
|
|
Packit Service |
82fcde |
sprintf (buf, "%u", v);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return v;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
void
|
|
Packit Service |
82fcde |
la_activity (uintptr_t *cookie, unsigned int flag)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (flag == LA_ACT_CONSISTENT)
|
|
Packit Service |
82fcde |
printf ("activity: consistent\n");
|
|
Packit Service |
82fcde |
else if (flag == LA_ACT_ADD)
|
|
Packit Service |
82fcde |
printf ("activity: add\n");
|
|
Packit Service |
82fcde |
else if (flag == LA_ACT_DELETE)
|
|
Packit Service |
82fcde |
printf ("activity: delete\n");
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
printf ("activity: unknown activity %u\n", flag);
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
char *
|
|
Packit Service |
82fcde |
la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
char buf[100];
|
|
Packit Service |
82fcde |
const char *flagstr;
|
|
Packit Service |
82fcde |
if (flag == LA_SER_ORIG)
|
|
Packit Service |
82fcde |
flagstr = "LA_SET_ORIG";
|
|
Packit Service |
82fcde |
else if (flag == LA_SER_LIBPATH)
|
|
Packit Service |
82fcde |
flagstr = "LA_SER_LIBPATH";
|
|
Packit Service |
82fcde |
else if (flag == LA_SER_RUNPATH)
|
|
Packit Service |
82fcde |
flagstr = "LA_SER_RUNPATH";
|
|
Packit Service |
82fcde |
else if (flag == LA_SER_CONFIG)
|
|
Packit Service |
82fcde |
flagstr = "LA_SER_CONFIG";
|
|
Packit Service |
82fcde |
else if (flag == LA_SER_DEFAULT)
|
|
Packit Service |
82fcde |
flagstr = "LA_SER_DEFAULT";
|
|
Packit Service |
82fcde |
else if (flag == LA_SER_SECURE)
|
|
Packit Service |
82fcde |
flagstr = "LA_SER_SECURE";
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
sprintf (buf, "unknown flag %d", flag);
|
|
Packit Service |
82fcde |
flagstr = buf;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
printf ("objsearch: %s, %s\n", name, flagstr);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return (char *) name;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
unsigned int
|
|
Packit Service |
82fcde |
la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("objopen: %ld, %s\n", lmid, l->l_name);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return 3;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
void
|
|
Packit Service |
82fcde |
la_preinit (uintptr_t *cookie)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("preinit\n");
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
unsigned int
|
|
Packit Service |
82fcde |
la_objclose (uintptr_t *cookie)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("objclose\n");
|
|
Packit Service |
82fcde |
return 0;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
uintptr_t
|
|
Packit Service |
82fcde |
la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit Service |
82fcde |
uintptr_t *defcook, unsigned int *flags, const char *symname)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("symbind32: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
|
|
Packit Service |
82fcde |
symname, (long int) sym->st_value, ndx, *flags);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return sym->st_value;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
uintptr_t
|
|
Packit Service |
82fcde |
la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit Service |
82fcde |
uintptr_t *defcook, unsigned int *flags, const char *symname)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
|
|
Packit Service |
82fcde |
symname, (long int) sym->st_value, ndx, *flags);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return sym->st_value;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <tst-audit.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __AVX__
|
|
Packit Service |
82fcde |
#include <immintrin.h>
|
|
Packit Service |
82fcde |
#include <cpuid.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static int avx = -1;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
static inline int
|
|
Packit Service |
82fcde |
__attribute ((always_inline))
|
|
Packit Service |
82fcde |
check_avx (void)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
if (avx == -1)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
unsigned int eax, ebx, ecx, edx;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)
|
|
Packit Service |
82fcde |
&& (ecx & bit_AVX))
|
|
Packit Service |
82fcde |
avx = 1;
|
|
Packit Service |
82fcde |
else
|
|
Packit Service |
82fcde |
avx = 0;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
return avx;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
#include <emmintrin.h>
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ElfW(Addr)
|
|
Packit Service |
82fcde |
pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit Service |
82fcde |
uintptr_t *defcook, La_regs *regs, unsigned int *flags,
|
|
Packit Service |
82fcde |
const char *symname, long int *framesizep)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
|
|
Packit Service |
82fcde |
symname, (long int) sym->st_value, ndx, *flags);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __AVX__
|
|
Packit Service |
82fcde |
if (check_avx () && strcmp (symname, "audit_test") == 0)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int i;
|
|
Packit Service |
82fcde |
__m128i xmm;
|
|
Packit Service |
82fcde |
__m256i ymm;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
for (i = 0; i < 8; i += 2)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
xmm = _mm_set1_epi32 (i + 1);
|
|
Packit Service |
82fcde |
if (memcmp (®s->lr_xmm[i], &xmm, sizeof (xmm))
|
|
Packit Service |
82fcde |
|| memcmp (®s->lr_vector[i], &xmm, sizeof (xmm)))
|
|
Packit Service |
82fcde |
abort ();
|
|
Packit Service |
82fcde |
regs->lr_xmm[i] = (La_x86_64_xmm) _mm_set1_epi32 (i + 0x100);
|
|
Packit Service |
82fcde |
regs->lr_vector[i].xmm[0] = regs->lr_xmm[i];
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ymm = _mm256_set1_epi32 (i + 2);
|
|
Packit Service |
82fcde |
if (memcmp (®s->lr_xmm[i + 1],
|
|
Packit Service |
82fcde |
®s->lr_vector[i + 1].xmm[0], sizeof (xmm))
|
|
Packit Service |
82fcde |
|| memcmp (®s->lr_vector[i + 1], &ymm, sizeof (ymm)))
|
|
Packit Service |
82fcde |
abort ();
|
|
Packit Service |
82fcde |
regs->lr_vector[i + 1].ymm[0]
|
|
Packit Service |
82fcde |
= (La_x86_64_ymm) _mm256_set1_epi32 (i + 0x101);
|
|
Packit Service |
82fcde |
regs->lr_xmm[i + 1] = regs->lr_vector[i + 1].xmm[0];
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ymm = _mm256_set1_epi32 (-1);
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm0" : : "x" (ymm) : "xmm0" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm1" : : "x" (ymm) : "xmm1" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm2" : : "x" (ymm) : "xmm2" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm3" : : "x" (ymm) : "xmm3" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm4" : : "x" (ymm) : "xmm4" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm5" : : "x" (ymm) : "xmm5" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm6" : : "x" (ymm) : "xmm6" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm7" : : "x" (ymm) : "xmm7" );
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
*framesizep = 1024;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return sym->st_value;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
unsigned int
|
|
Packit Service |
82fcde |
pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
|
|
Packit Service |
82fcde |
uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
|
|
Packit Service |
82fcde |
const char *symname)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
|
|
Packit Service |
82fcde |
symname, (long int) sym->st_value, ndx,
|
|
Packit Service |
82fcde |
(ptrdiff_t) outregs->int_retval);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __AVX__
|
|
Packit Service |
82fcde |
if (check_avx () && strcmp (symname, "audit_test") == 0)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int i;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
__m256i ymm = _mm256_set1_epi32 (0x12349876);;
|
|
Packit Service |
82fcde |
if (memcmp (&outregs->lrv_vector0, &ymm, sizeof (ymm)))
|
|
Packit Service |
82fcde |
abort ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
__m128i xmm;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
for (i = 0; i < 8; i += 2)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
xmm = _mm_set1_epi32 (i + 0x100);
|
|
Packit Service |
82fcde |
if (memcmp (&inregs->lr_xmm[i], &xmm, sizeof (xmm))
|
|
Packit Service |
82fcde |
|| memcmp (&inregs->lr_vector[i], &xmm, sizeof (xmm)))
|
|
Packit Service |
82fcde |
abort ();
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ymm = _mm256_set1_epi32 (i + 0x101);
|
|
Packit Service |
82fcde |
if (memcmp (&inregs->lr_xmm[i + 1],
|
|
Packit Service |
82fcde |
&inregs->lr_vector[i + 1].xmm[0], sizeof (xmm))
|
|
Packit Service |
82fcde |
|| memcmp (&inregs->lr_vector[i + 1], &ymm, sizeof (ymm)))
|
|
Packit Service |
82fcde |
abort ();
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
outregs->lrv_vector0.ymm[0]
|
|
Packit Service |
82fcde |
= (La_x86_64_ymm) _mm256_set1_epi32 (0x98abcdef);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
ymm = _mm256_set1_epi32 (-1);
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm0" : : "x" (ymm) : "xmm0" );
|
|
Packit Service |
82fcde |
asm volatile ("vmovdqa %0, %%ymm1" : : "x" (ymm) : "xmm1" );
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
return 0;
|
|
Packit Service |
82fcde |
}
|