Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

selftests/powerpc: Add scv versions of the basic TM syscall tests

The basic TM vs syscall test code hard codes an sc instruction for the
system call, which fails to cover scv even when the userspace libc has
support for it.

Duplicate the tests with hard coded scv variants so both are tested
when possible.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Fix build on old toolchains by using .long for scv]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210903125707.1601269-2-npiggin@gmail.com

authored by

Nicholas Piggin and committed by
Michael Ellerman
5379ef2a b871895b

+65 -8
+36 -1
tools/testing/selftests/powerpc/tm/tm-syscall-asm.S
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 - #include <ppc-asm.h> 2 + #include <basic_asm.h> 3 3 #include <asm/unistd.h> 4 4 5 5 .text ··· 25 25 blr 26 26 1: 27 27 li r3, -1 28 + blr 29 + 30 + 31 + .macro scv level 32 + .long (0x44000001 | (\level) << 5) 33 + .endm 34 + 35 + FUNC_START(getppid_scv_tm_active) 36 + PUSH_BASIC_STACK(0) 37 + tbegin. 38 + beq 1f 39 + li r0, __NR_getppid 40 + scv 0 41 + tend. 42 + POP_BASIC_STACK(0) 43 + blr 44 + 1: 45 + li r3, -1 46 + POP_BASIC_STACK(0) 47 + blr 48 + 49 + FUNC_START(getppid_scv_tm_suspended) 50 + PUSH_BASIC_STACK(0) 51 + tbegin. 52 + beq 1f 53 + li r0, __NR_getppid 54 + tsuspend. 55 + scv 0 56 + tresume. 57 + tend. 58 + POP_BASIC_STACK(0) 59 + blr 60 + 1: 61 + li r3, -1 62 + POP_BASIC_STACK(0) 28 63 blr
+29 -7
tools/testing/selftests/powerpc/tm/tm-syscall.c
··· 19 19 #include "utils.h" 20 20 #include "tm.h" 21 21 22 + #ifndef PPC_FEATURE2_SCV 23 + #define PPC_FEATURE2_SCV 0x00100000 /* scv syscall */ 24 + #endif 25 + 22 26 extern int getppid_tm_active(void); 23 27 extern int getppid_tm_suspended(void); 28 + extern int getppid_scv_tm_active(void); 29 + extern int getppid_scv_tm_suspended(void); 24 30 25 31 unsigned retries = 0; 26 32 27 33 #define TEST_DURATION 10 /* seconds */ 28 34 29 - pid_t getppid_tm(bool suspend) 35 + pid_t getppid_tm(bool scv, bool suspend) 30 36 { 31 37 int i; 32 38 pid_t pid; 33 39 34 40 for (i = 0; i < TM_RETRIES; i++) { 35 - if (suspend) 36 - pid = getppid_tm_suspended(); 37 - else 38 - pid = getppid_tm_active(); 41 + if (suspend) { 42 + if (scv) 43 + pid = getppid_scv_tm_suspended(); 44 + else 45 + pid = getppid_tm_suspended(); 46 + } else { 47 + if (scv) 48 + pid = getppid_scv_tm_active(); 49 + else 50 + pid = getppid_tm_active(); 51 + } 39 52 40 53 if (pid >= 0) 41 54 return pid; ··· 95 82 * Test a syscall within a suspended transaction and verify 96 83 * that it succeeds. 97 84 */ 98 - FAIL_IF(getppid_tm(true) == -1); /* Should succeed. */ 85 + FAIL_IF(getppid_tm(false, true) == -1); /* Should succeed. */ 99 86 100 87 /* 101 88 * Test a syscall within an active transaction and verify that 102 89 * it fails with the correct failure code. 103 90 */ 104 - FAIL_IF(getppid_tm(false) != -1); /* Should fail... */ 91 + FAIL_IF(getppid_tm(false, false) != -1); /* Should fail... */ 105 92 FAIL_IF(!failure_is_persistent()); /* ...persistently... */ 106 93 FAIL_IF(!failure_is_syscall()); /* ...with code syscall. */ 94 + 95 + /* Now do it all again with scv if it is available. */ 96 + if (have_hwcap2(PPC_FEATURE2_SCV)) { 97 + FAIL_IF(getppid_tm(true, true) == -1); /* Should succeed. */ 98 + FAIL_IF(getppid_tm(true, false) != -1); /* Should fail... */ 99 + FAIL_IF(!failure_is_persistent()); /* ...persistently... */ 100 + FAIL_IF(!failure_is_syscall()); /* ...with code syscall. */ 101 + } 102 + 107 103 gettimeofday(&now, 0); 108 104 } 109 105