[RFC PATCH 07/14] powerpc/tm: Do not reclaim on ptrace

Breno Leitao leitao at debian.org
Tue Nov 6 23:40:21 AEDT 2018


Make sure that we are not suspended on ptrace and that the registers were
already reclaimed.

Since the data was already reclaimed, there is nothing to be done here
except to restore the SPRs.

Signed-off-by: Breno Leitao <leitao at debian.org>
---
 arch/powerpc/kernel/ptrace.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index afb819f4ca68..4faf0612d58c 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -136,9 +136,19 @@ static void flush_tmregs_to_thread(struct task_struct *tsk)
 	if ((!cpu_has_feature(CPU_FTR_TM)) || (tsk != current))
 		return;
 
-	if (MSR_TM_SUSPENDED(mfmsr())) {
-		tm_reclaim_current(TM_CAUSE_SIGNAL);
-	} else {
+	if (WARN_ON(MSR_TM_SUSPENDED(mfmsr()))) {
+		/*
+		 * We should never be here in suspended state. This is a
+		 * bug!
+		 */
+		tm_reclaim_current(0x99);
+	}
+	if (tsk->thread.regs->msr & MSR_TM) {
+		/*
+		 * Only flush TM SPRs to the thread if TM was enabled,
+		 * otherwise (TM lazily disabled), the thread already
+		 * contains the latest SPR value
+		 */
 		tm_enable();
 		tm_save_sprs(&(tsk->thread));
 	}
-- 
2.19.0



More information about the Linuxppc-dev mailing list