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 : [fp_load] "r" (fp_load), [fp_load_ckpt] "r" (fp_load_ckpt),
69 [sprn_texasr] "i" (SPRN_TEXASR), [cptr1] "r" (&cptr[1])
70 : "memory", "r0", "r1", "r2", "r3", "r4",
71 "r7", "r8", "r9", "r10", "r11"
79 storevsx(fp_store, 0);
80 ret = compare_vsx_vmx(fp_store, fp_load_ckpt_new);
89 int trace_tm_vsx(pid_t child)
91 unsigned long vsx[VSX_MAX];
92 unsigned long vmx[VMX_MAX + 2][2];
94 FAIL_IF(start_trace(child));
95 FAIL_IF(show_vsx(child, vsx));
96 FAIL_IF(validate_vsx(vsx, fp_load));
97 FAIL_IF(show_vmx(child, vmx));
98 FAIL_IF(validate_vmx(vmx, fp_load));
99 FAIL_IF(show_vsx_ckpt(child, vsx));
100 FAIL_IF(validate_vsx(vsx, fp_load_ckpt));
101 FAIL_IF(show_vmx_ckpt(child, vmx));
102 FAIL_IF(validate_vmx(vmx, fp_load_ckpt));
103 memset(vsx, 0, sizeof(vsx));
104 memset(vmx, 0, sizeof(vmx));
106 load_vsx_vmx(fp_load_ckpt_new, vsx, vmx);
108 FAIL_IF(write_vsx_ckpt(child, vsx));
109 FAIL_IF(write_vmx_ckpt(child, vmx));
111 FAIL_IF(stop_trace(child));
115 int ptrace_tm_vsx(void)
120 SKIP_IF(!have_htm());
121 shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
123 for (i = 0; i < 128; i++) {
124 fp_load[i] = 1 + rand();
125 fp_load_ckpt[i] = 1 + 2 * rand();
126 fp_load_ckpt_new[i] = 1 + 3 * rand();
131 perror("fork() failed");
139 pptr = (unsigned long *)shmat(shm_id, NULL, 0);
141 asm volatile("" : : : "memory");
143 ret = trace_tm_vsx(pid);
147 shmctl(shm_id, IPC_RMID, NULL);
153 shmctl(shm_id, IPC_RMID, NULL);
155 printf("Child's exit status not captured\n");
159 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
165 int main(int argc, char *argv[])
167 return test_harness(ptrace_tm_vsx, "ptrace_tm_vsx");