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 : [sprn_texasr] "i" (SPRN_TEXASR)
81 : "memory", "r0", "r1", "r3", "r4",
82 "r7", "r8", "r9", "r10", "r11"
90 storevsx(fp_store, 0);
91 ret = compare_vsx_vmx(fp_store, fp_load_ckpt_new);
100 int trace_tm_spd_vsx(pid_t child)
102 unsigned long vsx[VSX_MAX];
103 unsigned long vmx[VMX_MAX + 2][2];
105 FAIL_IF(start_trace(child));
106 FAIL_IF(show_vsx(child, vsx));
107 FAIL_IF(validate_vsx(vsx, fp_load));
108 FAIL_IF(show_vmx(child, vmx));
109 FAIL_IF(validate_vmx(vmx, fp_load));
110 FAIL_IF(show_vsx_ckpt(child, vsx));
111 FAIL_IF(validate_vsx(vsx, fp_load_ckpt));
112 FAIL_IF(show_vmx_ckpt(child, vmx));
113 FAIL_IF(validate_vmx(vmx, fp_load_ckpt));
115 memset(vsx, 0, sizeof(vsx));
116 memset(vmx, 0, sizeof(vmx));
118 load_vsx_vmx(fp_load_ckpt_new, vsx, vmx);
120 FAIL_IF(write_vsx_ckpt(child, vsx));
121 FAIL_IF(write_vmx_ckpt(child, vmx));
125 FAIL_IF(stop_trace(child));
130 int ptrace_tm_spd_vsx(void)
135 SKIP_IF(!have_htm());
136 shm_id = shmget(IPC_PRIVATE, sizeof(int) * 3, 0777|IPC_CREAT);
138 for (i = 0; i < 128; i++) {
139 fp_load[i] = 1 + rand();
140 fp_load_new[i] = 1 + 2 * rand();
141 fp_load_ckpt[i] = 1 + 3 * rand();
142 fp_load_ckpt_new[i] = 1 + 4 * rand();
147 perror("fork() failed");
155 pptr = (int *)shmat(shm_id, NULL, 0);
157 asm volatile("" : : : "memory");
159 ret = trace_tm_spd_vsx(pid);
163 shmctl(shm_id, IPC_RMID, NULL);
169 shmctl(shm_id, IPC_RMID, NULL);
171 printf("Child's exit status not captured\n");
175 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
181 int main(int argc, char *argv[])
183 return test_harness(ptrace_tm_spd_vsx, "ptrace_tm_spd_vsx");