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.
31 #define TBEGIN ".long 0x7C00051D ;"
32 #define TEND ".long 0x7C00055D ;"
33 #define TCHECK ".long 0x7C00059C ;"
34 #define TSUSPEND ".long 0x7C0005DD ;"
35 #define TRESUME ".long 0x7C2005DD ;"
36 #define SPRN_TEXASR 0x82
37 #define SPRN_DSCR 0x03
40 uint64_t rv, dscr1 = 1, dscr2, texasr;
42 printf("Check DSCR TM context switch: ");
47 /* set a known value into the DSCR */
49 "mtspr %[sprn_dscr], 3;"
51 /* start and suspend a transaction */
56 /* hard loop until the transaction becomes doomed */
61 /* record DSCR and TEXASR */
62 "mfspr 3, %[sprn_dscr];"
64 "mfspr 3, %[sprn_texasr];"
71 : [rv]"=r"(rv), [dscr2]"=m"(dscr2), [texasr]"=m"(texasr)
73 , [sprn_dscr]"i"(SPRN_DSCR), [sprn_texasr]"i"(SPRN_TEXASR)
76 assert(rv); /* make sure the transaction aborted */
77 if ((texasr >> 56) != TM_CAUSE_RESCHED) {