| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "tst-sme-skeleton.c" |
| 20 |
|
| 21 |
#include <support/xsignal.h> |
| 22 |
|
| 23 |
static struct _aarch64_ctx * |
| 24 |
extension (void *p) |
| 25 |
{ |
| 26 |
return p; |
| 27 |
} |
| 28 |
|
| 29 |
#ifndef TPIDR2_MAGIC |
| 30 |
#define TPIDR2_MAGIC 0x54504902 |
| 31 |
#endif |
| 32 |
|
| 33 |
#ifndef ZA_MAGIC |
| 34 |
#define ZA_MAGIC 0x54366345 |
| 35 |
#endif |
| 36 |
|
| 37 |
#ifndef ZT_MAGIC |
| 38 |
#define ZT_MAGIC 0x5a544e01 |
| 39 |
#endif |
| 40 |
|
| 41 |
#ifndef EXTRA_MAGIC |
| 42 |
#define EXTRA_MAGIC 0x45585401 |
| 43 |
#endif |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
static int pipefd[2]; |
| 48 |
|
| 49 |
#define WRITE(msg) xwrite (1, msg, sizeof (msg)); |
| 50 |
|
| 51 |
static void |
| 52 |
handler (int signo, siginfo_t *si, void *ctx) |
| 53 |
{ |
| 54 |
TEST_VERIFY (signo == SIGUSR1); |
| 55 |
WRITE ("in the handler\n"); |
| 56 |
check_sme_za_state ("during signal", true ); |
| 57 |
ucontext_t *uc = ctx; |
| 58 |
void *p = uc->uc_mcontext.__reserved; |
| 59 |
unsigned int found = 0; |
| 60 |
uint32_t m; |
| 61 |
while ((m = extension (p)->magic)) |
| 62 |
{ |
| 63 |
if (m == TPIDR2_MAGIC) |
| 64 |
{ |
| 65 |
WRITE ("found TPIDR2_MAGIC\n"); |
| 66 |
found += 1; |
| 67 |
} |
| 68 |
if (m == ZA_MAGIC) |
| 69 |
{ |
| 70 |
WRITE ("found ZA_MAGIC\n"); |
| 71 |
found += 1; |
| 72 |
} |
| 73 |
if (m == ZT_MAGIC) |
| 74 |
{ |
| 75 |
WRITE ("found ZT_MAGIC\n"); |
| 76 |
found += 1; |
| 77 |
} |
| 78 |
if (m == EXTRA_MAGIC) |
| 79 |
{ |
| 80 |
WRITE ("found EXTRA_MAGIC\n"); |
| 81 |
struct { struct _aarch64_ctx h; uint64_t data; } *e = p; |
| 82 |
p = (char *)e->data; |
| 83 |
continue; |
| 84 |
} |
| 85 |
p = (char *)p + extension (p)->size; |
| 86 |
} |
| 87 |
TEST_COMPARE (found, 3); |
| 88 |
|
| 89 |
|
| 90 |
char message = '\0'; |
| 91 |
xwrite (pipefd[1], &message, 1); |
| 92 |
} |
| 93 |
|
| 94 |
static void |
| 95 |
run (struct blk *blk) |
| 96 |
{ |
| 97 |
xpipe (pipefd); |
| 98 |
|
| 99 |
struct sigaction sigact; |
| 100 |
sigemptyset (&sigact.sa_mask); |
| 101 |
sigact.sa_flags = 0; |
| 102 |
sigact.sa_flags |= SA_SIGINFO; |
| 103 |
sigact.sa_sigaction = handler; |
| 104 |
xsigaction (SIGUSR1, &sigact, NULL); |
| 105 |
|
| 106 |
enable_sme_za_state (blk); |
| 107 |
check_sme_za_state ("before signal", false ); |
| 108 |
xraise (SIGUSR1); |
| 109 |
|
| 110 |
|
| 111 |
char response; |
| 112 |
xread (pipefd[0], &response, 1); |
| 113 |
|
| 114 |
check_sme_za_state ("after signal", false ); |
| 115 |
} |