diff mbox

[1/3] selftests/powerpc: Standardise TM calls

Message ID 1448946504-11653-2-git-send-email-rashmicy@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Rashmica Gupta Dec. 1, 2015, 5:08 a.m. UTC
Currently tbegin, tend etc are written as opcodes or asm instructions. So
standardise these to asm instructions.

Signed-off-by: Rashmica Gupta <rashmicy@gmail.com>
---
 tools/testing/selftests/powerpc/tm/tm-resched-dscr.c | 16 ++++++----------
 tools/testing/selftests/powerpc/tm/tm-signal-stack.c |  4 ++--
 2 files changed, 8 insertions(+), 12 deletions(-)

Comments

Anshuman Khandual Dec. 1, 2015, 8:08 a.m. UTC | #1
On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
> Currently tbegin, tend etc are written as opcodes or asm instructions. So
> standardise these to asm instructions.

I think the asm instructions can be used with only newer versions of GCC.
But not sure, does it work with the older gcc as well ?
Michael Ellerman Dec. 2, 2015, 3:40 a.m. UTC | #2
On Tue, 2015-12-01 at 13:38 +0530, Anshuman Khandual wrote:
> On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
> > Currently tbegin, tend etc are written as opcodes or asm instructions. So
> > standardise these to asm instructions.
> 
> I think the asm instructions can be used with only newer versions of GCC.
> But not sure, does it work with the older gcc as well ?

No they don't work with all versions of GCC.

The HTM instructions were added in 4.9 AFAICS, but also backported to 4.8. That
seems old enough to me.

Also we have another test (tm-syscall) which is already using the tbegin
instruction, and no one has complained, so I don't think anyone is trying to
build the selftests with really old compilers.

cheers
Anshuman Khandual Dec. 2, 2015, 4:41 a.m. UTC | #3
On 12/02/2015 09:10 AM, Michael Ellerman wrote:
> On Tue, 2015-12-01 at 13:38 +0530, Anshuman Khandual wrote:
>> > On 12/01/2015 10:38 AM, Rashmica Gupta wrote:
>>> > > Currently tbegin, tend etc are written as opcodes or asm instructions. So
>>> > > standardise these to asm instructions.
>> > 
>> > I think the asm instructions can be used with only newer versions of GCC.
>> > But not sure, does it work with the older gcc as well ?
> No they don't work with all versions of GCC.
> 
> The HTM instructions were added in 4.9 AFAICS, but also backported to 4.8. That
> seems old enough to me.
> 
> Also we have another test (tm-syscall) which is already using the tbegin
> instruction, and no one has complained, so I don't think anyone is trying to
> build the selftests with really old compilers.

Its only a concern if you try to build these self tests on some older distro.
But then some other self tests dont build there because of lack of newer
compiler options. Its generic problem not something specific to this test.
diff mbox

Patch

diff --git a/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c b/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
index 42d4c8caad81..88c46481e59b 100644
--- a/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
+++ b/tools/testing/selftests/powerpc/tm/tm-resched-dscr.c
@@ -29,12 +29,8 @@ 
 #include <asm/tm.h>
 
 #include "utils.h"
+#include "tm.h"
 
-#define TBEGIN          ".long 0x7C00051D ;"
-#define TEND            ".long 0x7C00055D ;"
-#define TCHECK          ".long 0x7C00059C ;"
-#define TSUSPEND        ".long 0x7C0005DD ;"
-#define TRESUME         ".long 0x7C2005DD ;"
 #define SPRN_TEXASR     0x82
 #define SPRN_DSCR       0x03
 
@@ -52,13 +48,13 @@  int test_body(void)
 			"mtspr   %[sprn_dscr], 3;"
 
 			/* start and suspend a transaction */
-			TBEGIN
+			"tbegin.;"
 			"beq     1f;"
-			TSUSPEND
+			"tsuspend.;"
 
 			/* hard loop until the transaction becomes doomed */
 			"2: ;"
-			TCHECK
+			"tcheck 0;"
 			"bc      4, 0, 2b;"
 
 			/* record DSCR and TEXASR */
@@ -67,8 +63,8 @@  int test_body(void)
 			"mfspr   3, %[sprn_texasr];"
 			"std     3, %[texasr];"
 
-			TRESUME
-			TEND
+			"tresume.;"
+			"tend.;"
 			"li      %[rv], 0;"
 			"1: ;"
 			: [rv]"=r"(rv), [dscr2]"=m"(dscr2), [texasr]"=m"(texasr)
diff --git a/tools/testing/selftests/powerpc/tm/tm-signal-stack.c b/tools/testing/selftests/powerpc/tm/tm-signal-stack.c
index 82c29cb222dc..8ffd5cee7271 100644
--- a/tools/testing/selftests/powerpc/tm/tm-signal-stack.c
+++ b/tools/testing/selftests/powerpc/tm/tm-signal-stack.c
@@ -60,9 +60,9 @@  int tm_signal_stack()
 		exit(1);
 	asm volatile("li 1, 0 ;"		/* stack ptr == NULL */
 		     "1:"
-		     ".long 0x7C00051D ;"	/* tbegin */
+		     "tbegin.;"
 		     "beq 1b ;"			/* retry forever */
-		     ".long 0x7C0005DD ; ;"	/* tsuspend */
+		     "tsuspend.;"	
 		     "ld 2, 0(1) ;"		/* trigger segv" */
 		     : : : "memory");