1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright 2015, Michael Ellerman, IBM Corp.
6 #ifndef _SELFTESTS_POWERPC_TM_TM_H
7 #define _SELFTESTS_POWERPC_TM_TM_H
14 static inline bool have_htm(void)
16 #ifdef PPC_FEATURE2_HTM
17 return have_hwcap2(PPC_FEATURE2_HTM
);
19 printf("PPC_FEATURE2_HTM not defined, can't check AT_HWCAP2\n");
24 static inline bool have_htm_nosc(void)
26 #ifdef PPC_FEATURE2_HTM_NOSC
27 return have_hwcap2(PPC_FEATURE2_HTM_NOSC
);
29 printf("PPC_FEATURE2_HTM_NOSC not defined, can't check AT_HWCAP2\n");
34 static inline long failure_code(void)
36 return __builtin_get_texasru() >> 24;
39 static inline bool failure_is_persistent(void)
41 return (failure_code() & TM_CAUSE_PERSISTENT
) == TM_CAUSE_PERSISTENT
;
44 static inline bool failure_is_syscall(void)
46 return (failure_code() & TM_CAUSE_SYSCALL
) == TM_CAUSE_SYSCALL
;
49 static inline bool failure_is_unavailable(void)
51 return (failure_code() & TM_CAUSE_FAC_UNAV
) == TM_CAUSE_FAC_UNAV
;
54 static inline bool failure_is_reschedule(void)
56 if ((failure_code() & TM_CAUSE_RESCHED
) == TM_CAUSE_RESCHED
||
57 (failure_code() & TM_CAUSE_KVM_RESCHED
) == TM_CAUSE_KVM_RESCHED
||
58 (failure_code() & TM_CAUSE_KVM_FAC_UNAV
) == TM_CAUSE_KVM_FAC_UNAV
)
64 static inline bool failure_is_nesting(void)
66 return (__builtin_get_texasru() & 0x400000);
69 static inline int tcheck(void)
72 asm volatile ("tcheck 0" : "=r"(cr
) : : "cr0");
73 return (cr
>> 28) & 4;
76 static inline bool tcheck_doomed(void)
81 static inline bool tcheck_active(void)
86 static inline bool tcheck_suspended(void)
91 static inline bool tcheck_transactional(void)
96 #endif /* _SELFTESTS_POWERPC_TM_TM_H */