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.
34 #define SPRN_DSCR 0x03
38 uint64_t rv, dscr1 = 1, dscr2, texasr;
42 printf("Check DSCR TM context switch: ");
46 /* set a known value into the DSCR */
48 "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) {
94 return test_harness(test_body, "tm_resched_dscr");