2 * Ptrace test for VMX/VSX registers in the TM Suspend 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"
18 unsigned long fp_load[VEC_MAX];
19 unsigned long fp_load_new[VEC_MAX];
20 unsigned long fp_store[VEC_MAX];
21 unsigned long fp_load_ckpt[VEC_MAX];
22 unsigned long fp_load_ckpt_new[VEC_MAX];
24 __attribute__((used)) void load_vsx(void)
29 __attribute__((used)) void load_vsx_new(void)
31 loadvsx(fp_load_new, 0);
34 __attribute__((used)) void load_vsx_ckpt(void)
36 loadvsx(fp_load_ckpt, 0);
39 __attribute__((used)) void wait_parent(void)
43 asm volatile("" : : : "memory");
48 unsigned long result, texasr;
51 cptr = (int *)shmat(shm_id, NULL, 0);
76 "mfspr %[texasr], %[sprn_texasr];"
79 : [res] "=r" (result), [texasr] "=r" (texasr)
80 : [fp_load] "r" (fp_load), [fp_load_ckpt] "r" (fp_load_ckpt),
81 [sprn_texasr] "i" (SPRN_TEXASR)
82 : "memory", "r0", "r1", "r2", "r3", "r4",
83 "r8", "r9", "r10", "r11"
91 storevsx(fp_store, 0);
92 ret = compare_vsx_vmx(fp_store, fp_load_ckpt_new);
101 int trace_tm_spd_vsx(pid_t child)
103 unsigned long vsx[VSX_MAX];
104 unsigned long vmx[VMX_MAX + 2][2];
106 FAIL_IF(start_trace(child));
107 FAIL_IF(show_vsx(child, vsx));
108 FAIL_IF(validate_vsx(vsx, fp_load));
109 FAIL_IF(show_vmx(child, vmx));
110 FAIL_IF(validate_vmx(vmx, fp_load));
111 FAIL_IF(show_vsx_ckpt(child, vsx));
112 FAIL_IF(validate_vsx(vsx, fp_load_ckpt));
113 FAIL_IF(show_vmx_ckpt(child, vmx));
114 FAIL_IF(validate_vmx(vmx, fp_load_ckpt));
116 memset(vsx, 0, sizeof(vsx));
117 memset(vmx, 0, sizeof(vmx));
119 load_vsx_vmx(fp_load_ckpt_new, vsx, vmx);
121 FAIL_IF(write_vsx_ckpt(child, vsx));
122 FAIL_IF(write_vmx_ckpt(child, vmx));
126 FAIL_IF(stop_trace(child));
131 int ptrace_tm_spd_vsx(void)
136 SKIP_IF(!have_htm());
137 shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
139 for (i = 0; i < 128; i++) {
140 fp_load[i] = 1 + rand();
141 fp_load_new[i] = 1 + 2 * rand();
142 fp_load_ckpt[i] = 1 + 3 * rand();
143 fp_load_ckpt_new[i] = 1 + 4 * rand();
148 perror("fork() failed");
156 pptr = (int *)shmat(shm_id, NULL, 0);
158 asm volatile("" : : : "memory");
160 ret = trace_tm_spd_vsx(pid);
164 shmctl(shm_id, IPC_RMID, NULL);
170 shmctl(shm_id, IPC_RMID, NULL);
172 printf("Child's exit status not captured\n");
176 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
182 int main(int argc, char *argv[])
184 return test_harness(ptrace_tm_spd_vsx, "ptrace_tm_spd_vsx");