1 /* Test context switching to see if the DSCR SPR is correctly preserved
2 * when within a transaction.
4 * Note: We assume that the DSCR has been left at the default value (0)
9 * Set a value into the DSCR.
11 * Start a transaction, and suspend it (*).
13 * Hard loop checking to see if the transaction has become doomed.
15 * Now that we *may* have been preempted, record the DSCR and TEXASR SPRS.
17 * If the abort was because of a context switch, check the DSCR value.
18 * Otherwise, try again.
20 * (*) If the transaction is not suspended we can't see the problem because
21 * the transaction abort handler will restore the DSCR to it's checkpointed
22 * value before we regain control.
33 #define TBEGIN ".long 0x7C00051D ;"
34 #define TEND ".long 0x7C00055D ;"
35 #define TCHECK ".long 0x7C00059C ;"
36 #define TSUSPEND ".long 0x7C0005DD ;"
37 #define TRESUME ".long 0x7C2005DD ;"
38 #define SPRN_TEXASR 0x82
39 #define SPRN_DSCR 0x03
43 uint64_t rv
, dscr1
= 1, dscr2
, texasr
;
45 printf("Check DSCR TM context switch: ");
50 /* set a known value into the DSCR */
52 "mtspr %[sprn_dscr], 3;"
54 /* start and suspend a transaction */
59 /* hard loop until the transaction becomes doomed */
64 /* record DSCR and TEXASR */
65 "mfspr 3, %[sprn_dscr];"
67 "mfspr 3, %[sprn_texasr];"
74 : [rv
]"=r"(rv
), [dscr2
]"=m"(dscr2
), [texasr
]"=m"(texasr
)
76 , [sprn_dscr
]"i"(SPRN_DSCR
), [sprn_texasr
]"i"(SPRN_TEXASR
)
79 assert(rv
); /* make sure the transaction aborted */
80 if ((texasr
>> 56) != TM_CAUSE_RESCHED
) {
97 return test_harness(test_body
, "tm_resched_dscr");