powerpc/tm: Abort syscalls in active transactions
[firefly-linux-kernel-4.4.55.git] / arch / powerpc / kernel / entry_64.S
index afbc20019c2efba2b81b7cd6298941753d9776b5..8ca9434c40e6a705e1eccb8e8ddcca727bf68044 100644 (file)
@@ -34,6 +34,7 @@
 #include <asm/ftrace.h>
 #include <asm/hw_irq.h>
 #include <asm/context_tracking.h>
+#include <asm/tm.h>
 
 /*
  * System calls.
@@ -145,6 +146,24 @@ END_FW_FTR_SECTION_IFSET(FW_FEATURE_SPLPAR)
        andi.   r11,r10,_TIF_SYSCALL_DOTRACE
        bne     syscall_dotrace
 .Lsyscall_dotrace_cont:
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+BEGIN_FTR_SECTION
+       b       1f
+END_FTR_SECTION_IFCLR(CPU_FTR_TM)
+       extrdi. r11, r12, 1, (63-MSR_TS_T_LG) /* transaction active? */
+       beq+    1f
+
+       /* Doom the transaction and don't perform the syscall: */
+       mfmsr   r11
+       li      r12, 1
+       rldimi  r11, r12, MSR_TM_LG, 63-MSR_TM_LG
+       mtmsrd  r11, 0
+       li      r11, (TM_CAUSE_SYSCALL|TM_CAUSE_PERSISTENT)
+       TABORT(R11)
+
+       b       .Lsyscall_exit
+1:
+#endif
        cmpldi  0,r0,NR_syscalls
        bge-    syscall_enosys