~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c

Version: ~ [ linux-5.5-rc1 ] ~ [ linux-5.4.2 ] ~ [ linux-5.3.15 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.88 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.158 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.206 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.206 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.78 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c (Version linux-4.11.12) and /tools/testing/selftests/powerpc/ptrace/ptrace-tm-spr.c (Version linux-5.0.21)


  1 /*                                                  1 /*
  2  * Ptrace test TM SPR registers                     2  * Ptrace test TM SPR registers
  3  *                                                  3  *
  4  * Copyright (C) 2015 Anshuman Khandual, IBM C      4  * Copyright (C) 2015 Anshuman Khandual, IBM Corporation.
  5  *                                                  5  *
  6  * This program is free software; you can redi      6  * This program is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Genera      7  * modify it under the terms of the GNU General Public License
  8  * as published by the Free Software Foundatio      8  * as published by the Free Software Foundation; either version
  9  * 2 of the License, or (at your option) any l      9  * 2 of the License, or (at your option) any later version.
 10  */                                                10  */
 11 #include "ptrace.h"                                11 #include "ptrace.h"
 12 #include "tm.h"                                    12 #include "tm.h"
 13                                                    13 
 14 /* Tracee and tracer shared data */                14 /* Tracee and tracer shared data */
 15 struct shared {                                    15 struct shared {
 16         int flag;                                  16         int flag;
 17         struct tm_spr_regs regs;                   17         struct tm_spr_regs regs;
 18 };                                                 18 };
 19 unsigned long tfhar;                               19 unsigned long tfhar;
 20                                                    20 
 21 int shm_id;                                        21 int shm_id;
 22 struct shared *cptr, *pptr;                        22 struct shared *cptr, *pptr;
 23                                                    23 
 24 int shm_id1;                                       24 int shm_id1;
 25 int *cptr1, *pptr1;                                25 int *cptr1, *pptr1;
 26                                                    26 
 27 #define TM_KVM_SCHED   0xe0000001ac000001          27 #define TM_KVM_SCHED   0xe0000001ac000001
 28 int validate_tm_spr(struct tm_spr_regs *regs)      28 int validate_tm_spr(struct tm_spr_regs *regs)
 29 {                                                  29 {
 30         FAIL_IF(regs->tm_tfhar != tfhar);          30         FAIL_IF(regs->tm_tfhar != tfhar);
 31         FAIL_IF((regs->tm_texasr == TM_KVM_SCH     31         FAIL_IF((regs->tm_texasr == TM_KVM_SCHED) && (regs->tm_tfiar != 0));
 32                                                    32 
 33         return TEST_PASS;                          33         return TEST_PASS;
 34 }                                                  34 }
 35                                                    35 
 36 void tm_spr(void)                                  36 void tm_spr(void)
 37 {                                                  37 {
 38         unsigned long result, texasr;              38         unsigned long result, texasr;
 39         int ret;                                   39         int ret;
 40                                                    40 
 41         cptr = (struct shared *)shmat(shm_id,      41         cptr = (struct shared *)shmat(shm_id, NULL, 0);
 42         cptr1 = (int *)shmat(shm_id1, NULL, 0)     42         cptr1 = (int *)shmat(shm_id1, NULL, 0);
 43                                                    43 
 44 trans:                                             44 trans:
 45         cptr1[0] = 0;                              45         cptr1[0] = 0;
 46         asm __volatile__(                          46         asm __volatile__(
 47                 "1: ;"                             47                 "1: ;"
 48                 /* TM failover handler should      48                 /* TM failover handler should follow "tbegin.;" */
 49                 "mflr 31;"                         49                 "mflr 31;"
 50                 "bl 4f;"        /* $ = TFHAR -     50                 "bl 4f;"        /* $ = TFHAR - 12 */
 51                 "4: ;"                             51                 "4: ;"
 52                 "mflr %[tfhar];"                   52                 "mflr %[tfhar];"
 53                 "mtlr 31;"                         53                 "mtlr 31;"
 54                                                    54 
 55                 "tbegin.;"                         55                 "tbegin.;"
 56                 "beq 2f;"                          56                 "beq 2f;"
 57                                                    57 
 58                 "tsuspend.;"                       58                 "tsuspend.;"
 59                 "li 8, 1;"                         59                 "li 8, 1;"
 60                 "sth 8, 0(%[cptr1]);"              60                 "sth 8, 0(%[cptr1]);"
 61                 "tresume.;"                        61                 "tresume.;"
 62                 "b .;"                             62                 "b .;"
 63                                                    63 
 64                 "tend.;"                           64                 "tend.;"
 65                 "li 0, 0;"                         65                 "li 0, 0;"
 66                 "ori %[res], 0, 0;"                66                 "ori %[res], 0, 0;"
 67                 "b 3f;"                            67                 "b 3f;"
 68                                                    68 
 69                 "2: ;"                             69                 "2: ;"
 70                                                    70 
 71                 "li 0, 1;"                         71                 "li 0, 1;"
 72                 "ori %[res], 0, 0;"                72                 "ori %[res], 0, 0;"
 73                 "mfspr %[texasr], %[sprn_texas     73                 "mfspr %[texasr], %[sprn_texasr];"
 74                                                    74 
 75                 "3: ;"                             75                 "3: ;"
 76                 : [tfhar] "=r" (tfhar), [res]      76                 : [tfhar] "=r" (tfhar), [res] "=r" (result),
 77                 [texasr] "=r" (texasr), [cptr1 !!  77                 [texasr] "=r" (texasr), [cptr1] "=b" (cptr1)
 78                 : [sprn_texasr] "i"  (SPRN_TEX     78                 : [sprn_texasr] "i"  (SPRN_TEXASR)
 79                 : "memory", "r0", "r1", "r2",  !!  79                 : "memory", "r0", "r8", "r31"
 80                 "r8", "r9", "r10", "r11", "r31 << 
 81                 );                                 80                 );
 82                                                    81 
 83         /* There are 2 32bit instructions befo     82         /* There are 2 32bit instructions before tbegin. */
 84         tfhar += 12;                               83         tfhar += 12;
 85                                                    84 
 86         if (result) {                              85         if (result) {
 87                 if (!cptr->flag)                   86                 if (!cptr->flag)
 88                         goto trans;                87                         goto trans;
 89                                                    88 
 90                 ret = validate_tm_spr((struct      89                 ret = validate_tm_spr((struct tm_spr_regs *)&cptr->regs);
 91                 shmdt((void *)cptr);               90                 shmdt((void *)cptr);
 92                 shmdt((void *)cptr1);              91                 shmdt((void *)cptr1);
 93                 if (ret)                           92                 if (ret)
 94                         exit(1);                   93                         exit(1);
 95                 exit(0);                           94                 exit(0);
 96         }                                          95         }
 97         shmdt((void *)cptr);                       96         shmdt((void *)cptr);
 98         shmdt((void *)cptr1);                      97         shmdt((void *)cptr1);
 99         exit(1);                                   98         exit(1);
100 }                                                  99 }
101                                                   100 
102 int trace_tm_spr(pid_t child)                     101 int trace_tm_spr(pid_t child)
103 {                                                 102 {
104         FAIL_IF(start_trace(child));              103         FAIL_IF(start_trace(child));
105         FAIL_IF(show_tm_spr(child, (struct tm_    104         FAIL_IF(show_tm_spr(child, (struct tm_spr_regs *)&pptr->regs));
106                                                   105 
107         printf("TFHAR: %lx TEXASR: %lx TFIAR:     106         printf("TFHAR: %lx TEXASR: %lx TFIAR: %lx\n", pptr->regs.tm_tfhar,
108                                 pptr->regs.tm_    107                                 pptr->regs.tm_texasr, pptr->regs.tm_tfiar);
109                                                   108 
110         pptr->flag = 1;                           109         pptr->flag = 1;
111         FAIL_IF(stop_trace(child));               110         FAIL_IF(stop_trace(child));
112                                                   111 
113         return TEST_PASS;                         112         return TEST_PASS;
114 }                                                 113 }
115                                                   114 
116 int ptrace_tm_spr(void)                           115 int ptrace_tm_spr(void)
117 {                                                 116 {
118         pid_t pid;                                117         pid_t pid;
119         int ret, status;                          118         int ret, status;
120                                                   119 
121         SKIP_IF(!have_htm());                     120         SKIP_IF(!have_htm());
122         shm_id = shmget(IPC_PRIVATE, sizeof(st    121         shm_id = shmget(IPC_PRIVATE, sizeof(struct shared), 0777|IPC_CREAT);
123         shm_id1 = shmget(IPC_PRIVATE, sizeof(i    122         shm_id1 = shmget(IPC_PRIVATE, sizeof(int), 0777|IPC_CREAT);
124         pid = fork();                             123         pid = fork();
125         if (pid < 0) {                            124         if (pid < 0) {
126                 perror("fork() failed");          125                 perror("fork() failed");
127                 return TEST_FAIL;                 126                 return TEST_FAIL;
128         }                                         127         }
129                                                   128 
130         if (pid == 0)                             129         if (pid == 0)
131                 tm_spr();                         130                 tm_spr();
132                                                   131 
133         if (pid) {                                132         if (pid) {
134                 pptr = (struct shared *)shmat(    133                 pptr = (struct shared *)shmat(shm_id, NULL, 0);
135                 pptr1 = (int *)shmat(shm_id1,     134                 pptr1 = (int *)shmat(shm_id1, NULL, 0);
136                                                   135 
137                 while (!pptr1[0])                 136                 while (!pptr1[0])
138                         asm volatile("" : : :     137                         asm volatile("" : : : "memory");
139                 ret = trace_tm_spr(pid);          138                 ret = trace_tm_spr(pid);
140                 if (ret) {                        139                 if (ret) {
141                         kill(pid, SIGKILL);       140                         kill(pid, SIGKILL);
142                         shmdt((void *)pptr);      141                         shmdt((void *)pptr);
143                         shmdt((void *)pptr1);     142                         shmdt((void *)pptr1);
144                         shmctl(shm_id, IPC_RMI    143                         shmctl(shm_id, IPC_RMID, NULL);
145                         shmctl(shm_id1, IPC_RM    144                         shmctl(shm_id1, IPC_RMID, NULL);
146                         return TEST_FAIL;         145                         return TEST_FAIL;
147                 }                                 146                 }
148                                                   147 
149                 shmdt((void *)pptr);              148                 shmdt((void *)pptr);
150                 shmdt((void *)pptr1);             149                 shmdt((void *)pptr1);
151                 ret = wait(&status);              150                 ret = wait(&status);
152                 shmctl(shm_id, IPC_RMID, NULL)    151                 shmctl(shm_id, IPC_RMID, NULL);
153                 shmctl(shm_id1, IPC_RMID, NULL    152                 shmctl(shm_id1, IPC_RMID, NULL);
154                 if (ret != pid) {                 153                 if (ret != pid) {
155                         printf("Child's exit s    154                         printf("Child's exit status not captured\n");
156                         return TEST_FAIL;         155                         return TEST_FAIL;
157                 }                                 156                 }
158                                                   157 
159                 return (WIFEXITED(status) && W    158                 return (WIFEXITED(status) && WEXITSTATUS(status)) ? TEST_FAIL :
160                         TEST_PASS;                159                         TEST_PASS;
161         }                                         160         }
162         return TEST_PASS;                         161         return TEST_PASS;
163 }                                                 162 }
164                                                   163 
165 int main(int argc, char *argv[])                  164 int main(int argc, char *argv[])
166 {                                                 165 {
167         return test_harness(ptrace_tm_spr, "pt    166         return test_harness(ptrace_tm_spr, "ptrace_tm_spr");
168 }                                                 167 }
169                                                   168 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp