2 * Ptrace test for VMX/VSX registers in the TM context
4 * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
13 #include "ptrace-vsx.h"
16 unsigned long *cptr, *pptr;
18 unsigned long fp_load[VEC_MAX];
19 unsigned long fp_store[VEC_MAX];
20 unsigned long fp_load_ckpt[VEC_MAX];
21 unsigned long fp_load_ckpt_new[VEC_MAX];
23 __attribute__((used)) void load_vsx(void)
28 __attribute__((used)) void load_vsx_ckpt(void)
30 loadvsx(fp_load_ckpt, 0);
35 unsigned long result, texasr;
38 cptr = (unsigned long *)shmat(shm_id, NULL, 0);
64 "mfspr %[texasr], %[sprn_texasr];"
67 : [res] "=r" (result), [texasr] "=r" (texasr)
68 : [sprn_texasr] "i" (SPRN_TEXASR), [cptr1] "b" (&cptr[1])
69 : "memory", "r0", "r1", "r3", "r4",
70 "r7", "r8", "r9", "r10", "r11"
78 storevsx(fp_store, 0);
79 ret = compare_vsx_vmx(fp_store, fp_load_ckpt_new);
88 int trace_tm_vsx(pid_t child)
90 unsigned long vsx[VSX_MAX];
91 unsigned long vmx[VMX_MAX + 2][2];
93 FAIL_IF(start_trace(child));
94 FAIL_IF(show_vsx(child, vsx));
95 FAIL_IF(validate_vsx(vsx, fp_load));
96 FAIL_IF(show_vmx(child, vmx));
97 FAIL_IF(validate_vmx(vmx, fp_load));
98 FAIL_IF(show_vsx_ckpt(child, vsx));
99 FAIL_IF(validate_vsx(vsx, fp_load_ckpt));
100 FAIL_IF(show_vmx_ckpt(child, vmx));
101 FAIL_IF(validate_vmx(vmx, fp_load_ckpt));
102 memset(vsx, 0, sizeof(vsx));
103 memset(vmx, 0, sizeof(vmx));
105 load_vsx_vmx(fp_load_ckpt_new, vsx, vmx);
107 FAIL_IF(write_vsx_ckpt(child, vsx));
108 FAIL_IF(write_vmx_ckpt(child, vmx));
110 FAIL_IF(stop_trace(child));
114 int ptrace_tm_vsx(void)
119 SKIP_IF(!have_htm());
120 shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
122 for (i = 0; i < 128; i++) {
123 fp_load[i] = 1 + rand();
124 fp_load_ckpt[i] = 1 + 2 * rand();
125 fp_load_ckpt_new[i] = 1 + 3 * rand();
130 perror("fork() failed");
138 pptr = (unsigned long *)shmat(shm_id, NULL, 0);
140 asm volatile("" : : : "memory");
142 ret = trace_tm_vsx(pid);
146 shmctl(shm_id, IPC_RMID, NULL);
152 shmctl(shm_id, IPC_RMID, NULL);
154 printf("Child's exit status not captured\n");
158 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
164 int main(int argc, char *argv[])
166 return test_harness(ptrace_tm_vsx, "ptrace_tm_vsx");