1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Ptrace test for VMX/VSX registers
5 * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
8 #include "ptrace-vsx.h"
10 /* Tracer and Tracee Shared Data */
14 unsigned long fp_load[VEC_MAX];
15 unsigned long fp_load_new[VEC_MAX];
16 unsigned long fp_store[VEC_MAX];
22 cptr = (int *)shmat(shm_id, NULL, 0);
27 asm volatile("" : : : "memory");
30 storevsx(fp_store, 0);
31 ret = compare_vsx_vmx(fp_store, fp_load_new);
37 int trace_vsx(pid_t child)
39 unsigned long vsx[VSX_MAX];
40 unsigned long vmx[VMX_MAX + 2][2];
42 FAIL_IF(start_trace(child));
43 FAIL_IF(show_vsx(child, vsx));
44 FAIL_IF(validate_vsx(vsx, fp_load));
45 FAIL_IF(show_vmx(child, vmx));
46 FAIL_IF(validate_vmx(vmx, fp_load));
48 memset(vsx, 0, sizeof(vsx));
49 memset(vmx, 0, sizeof(vmx));
50 load_vsx_vmx(fp_load_new, vsx, vmx);
52 FAIL_IF(write_vsx(child, vsx));
53 FAIL_IF(write_vmx(child, vmx));
54 FAIL_IF(stop_trace(child));
64 shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT);
66 for (i = 0; i < VEC_MAX; i++)
67 fp_load[i] = i + rand();
69 for (i = 0; i < VEC_MAX; i++)
70 fp_load_new[i] = i + 2 * rand();
74 perror("fork() failed");
82 pptr = (int *)shmat(shm_id, NULL, 0);
84 asm volatile("" : : : "memory");
90 shmctl(shm_id, IPC_RMID, NULL);
98 shmctl(shm_id, IPC_RMID, NULL);
100 printf("Child's exit status not captured\n");
104 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
110 int main(int argc, char *argv[])
112 return test_harness(ptrace_vsx, "ptrace_vsx");