1 // SPDX-License-Identifier: GPL-2.0
2 /* Test context switching to see if the DSCR SPR is correctly preserved
3 * when within a transaction.
5 * Note: We assume that the DSCR has been left at the default value (0)
10 * Set a value into the DSCR.
12 * Start a transaction, and suspend it (*).
14 * Hard loop checking to see if the transaction has become doomed.
16 * Now that we *may* have been preempted, record the DSCR and TEXASR SPRS.
18 * If the abort was because of a context switch, check the DSCR value.
19 * Otherwise, try again.
21 * (*) If the transaction is not suspended we can't see the problem because
22 * the transaction abort handler will restore the DSCR to it's checkpointed
23 * value before we regain control.
34 #include "../pmu/lib.h"
36 #define SPRN_DSCR 0x03
40 uint64_t rv
, dscr1
= 1, dscr2
, texasr
;
44 printf("Check DSCR TM context switch: ");
48 /* set a known value into the DSCR */
50 "mtspr %[sprn_dscr], 3;"
53 /* start and suspend a transaction */
58 /* hard loop until the transaction becomes doomed */
63 /* record DSCR and TEXASR */
64 "mfspr 3, %[sprn_dscr];"
66 "mfspr 3, %[sprn_texasr];"
73 : [rv
]"=r"(rv
), [dscr2
]"=m"(dscr2
), [texasr
]"=m"(texasr
)
75 , [sprn_dscr
]"i"(SPRN_DSCR
), [sprn_texasr
]"i"(SPRN_TEXASR
)
78 assert(rv
); /* make sure the transaction aborted */
79 if ((texasr
>> 56) != TM_CAUSE_RESCHED
) {
92 static int tm_resched_dscr(void)
94 return eat_cpu(test_body
);
97 int main(int argc
, const char *argv
[])
99 return test_harness(tm_resched_dscr
, "tm_resched_dscr");