Now the transaction reclaims happens very earlier in the trap handler, and it is impossible to know precisely, at that early time, what should be set as the failure cause for some specific cases, as, if the task will be rescheduled, thus, the transaction abort case should be updated from TM_CAUSE_MISC to TM_CAUSE_RESCHED, for example.
This patch creates a function that will update TEXASR special purpose register in the task thread and set the failure code which will be moved to the live register afterward. Signed-off-by: Breno Leitao <lei...@debian.org> --- arch/powerpc/kernel/process.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c index 54fddf03b97a..fe063c0142e3 100644 --- a/arch/powerpc/kernel/process.c +++ b/arch/powerpc/kernel/process.c @@ -85,6 +85,7 @@ extern unsigned long _get_SP(void); * other paths that we should never reach with suspend disabled. */ bool tm_suspend_disabled __ro_after_init = false; +static void tm_fix_failure_cause(struct task_struct *task, uint8_t cause); static void check_if_tm_restore_required(struct task_struct *tsk) { @@ -988,6 +989,14 @@ void tm_recheckpoint(struct thread_struct *thread) local_irq_restore(flags); } +/* Change thread->tm.texasr failure code */ +static void tm_fix_failure_cause(struct task_struct *task, uint8_t cause) +{ + /* Clear the cause first */ + task->thread.tm_texasr &= ~TEXASR_FC; + task->thread.tm_texasr |= (unsigned long) cause << 56; +} + static inline void tm_recheckpoint_new_task(struct task_struct *new) { if (!cpu_has_feature(CPU_FTR_TM)) -- 2.19.0