This source file includes following definitions.
- test_body
- tm_resched_dscr
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 #include <inttypes.h>
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <assert.h>
30 #include <asm/tm.h>
31
32 #include "utils.h"
33 #include "tm.h"
34 #include "../pmu/lib.h"
35
36 #define SPRN_DSCR 0x03
37
38 int test_body(void)
39 {
40 uint64_t rv, dscr1 = 1, dscr2, texasr;
41
42 SKIP_IF(!have_htm());
43
44 printf("Check DSCR TM context switch: ");
45 fflush(stdout);
46 for (;;) {
47 asm __volatile__ (
48
49 "ld 3, %[dscr1];"
50 "mtspr %[sprn_dscr], 3;"
51
52 "li %[rv], 1;"
53
54 "tbegin.;"
55 "beq 1f;"
56 "tsuspend.;"
57
58
59 "2: ;"
60 "tcheck 0;"
61 "bc 4, 0, 2b;"
62
63
64 "mfspr 3, %[sprn_dscr];"
65 "std 3, %[dscr2];"
66 "mfspr 3, %[sprn_texasr];"
67 "std 3, %[texasr];"
68
69 "tresume.;"
70 "tend.;"
71 "li %[rv], 0;"
72 "1: ;"
73 : [rv]"=r"(rv), [dscr2]"=m"(dscr2), [texasr]"=m"(texasr)
74 : [dscr1]"m"(dscr1)
75 , [sprn_dscr]"i"(SPRN_DSCR), [sprn_texasr]"i"(SPRN_TEXASR)
76 : "memory", "r3"
77 );
78 assert(rv);
79 if ((texasr >> 56) != TM_CAUSE_RESCHED) {
80 continue;
81 }
82 if (dscr2 != dscr1) {
83 printf(" FAIL\n");
84 return 1;
85 } else {
86 printf(" OK\n");
87 return 0;
88 }
89 }
90 }
91
92 static int tm_resched_dscr(void)
93 {
94 return eat_cpu(test_body);
95 }
96
97 int main(int argc, const char *argv[])
98 {
99 return test_harness(tm_resched_dscr, "tm_resched_dscr");
100 }