]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c
2 * Ptrace test TM SPR registers
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.
14 /* Tracee and tracer shared data */
17 struct tm_spr_regs regs
;
22 struct shared
*cptr
, *pptr
;
27 #define TM_KVM_SCHED 0xe0000001ac000001
28 int validate_tm_spr(struct tm_spr_regs
*regs
)
30 FAIL_IF(regs
->tm_tfhar
!= tfhar
);
31 FAIL_IF((regs
->tm_texasr
== TM_KVM_SCHED
) && (regs
->tm_tfiar
!= 0));
38 unsigned long result
, texasr
;
41 cptr
= (struct shared
*)shmat(shm_id
, NULL
, 0);
42 cptr1
= (int *)shmat(shm_id1
, NULL
, 0);
48 /* TM failover handler should follow "tbegin.;" */
50 "bl 4f;" /* $ = TFHAR - 12 */
73 "mfspr %[texasr], %[sprn_texasr];"
76 : [tfhar
] "=r" (tfhar
), [res
] "=r" (result
),
77 [texasr
] "=r" (texasr
), [cptr1
] "=b" (cptr1
)
78 : [sprn_texasr
] "i" (SPRN_TEXASR
)
79 : "memory", "r0", "r8", "r31"
82 /* There are 2 32bit instructions before tbegin. */
89 ret
= validate_tm_spr((struct tm_spr_regs
*)&cptr
->regs
);
101 int trace_tm_spr(pid_t child
)
103 FAIL_IF(start_trace(child
));
104 FAIL_IF(show_tm_spr(child
, (struct tm_spr_regs
*)&pptr
->regs
));
106 printf("TFHAR: %lx TEXASR: %lx TFIAR: %lx\n", pptr
->regs
.tm_tfhar
,
107 pptr
->regs
.tm_texasr
, pptr
->regs
.tm_tfiar
);
110 FAIL_IF(stop_trace(child
));
115 int ptrace_tm_spr(void)
120 SKIP_IF(!have_htm());
121 shm_id
= shmget(IPC_PRIVATE
, sizeof(struct shared
), 0777|IPC_CREAT
);
122 shm_id1
= shmget(IPC_PRIVATE
, sizeof(int), 0777|IPC_CREAT
);
125 perror("fork() failed");
133 pptr
= (struct shared
*)shmat(shm_id
, NULL
, 0);
134 pptr1
= (int *)shmat(shm_id1
, NULL
, 0);
137 asm volatile("" : : : "memory");
138 ret
= trace_tm_spr(pid
);
142 shmdt((void *)pptr1
);
143 shmctl(shm_id
, IPC_RMID
, NULL
);
144 shmctl(shm_id1
, IPC_RMID
, NULL
);
149 shmdt((void *)pptr1
);
151 shmctl(shm_id
, IPC_RMID
, NULL
);
152 shmctl(shm_id1
, 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_spr
, "ptrace_tm_spr");