Skip to content

Commit 146c9ab

Browse files
Sayali Patilmaddy-kerneldev
authored andcommitted
powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx
The new PowerPC VMX fast path (__copy_tofrom_user_power7_vmx) is not exercised by existing copyloops selftests. This patch updates the selftest to exercise the VMX variant, ensuring the VMX copy path is validated. Changes include: - COPY_LOOP=test___copy_tofrom_user_power7_vmx with -D VMX_TEST is used in existing selftest build targets. - Inclusion of ../utils.c to provide get_auxv_entry() for hardware feature detection. - At runtime, the test skips execution if Altivec is not available. - Copy sizes above VMX_COPY_THRESHOLD are used to ensure the VMX path is taken. This enables validation of the VMX fast path without affecting systems that do not support Altivec. Signed-off-by: Sayali Patil <sayalip@linux.ibm.com> Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260304122201.153049-2-sayalip@linux.ibm.com
1 parent 6bc9c0a commit 146c9ab

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

tools/testing/selftests/powerpc/copyloops/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
copyuser_64_t0
33
copyuser_64_t1
44
copyuser_64_t2
5-
copyuser_p7_t0
6-
copyuser_p7_t1
5+
copyuser_p7
6+
copyuser_p7_vmx
77
memcpy_64_t0
88
memcpy_64_t1
99
memcpy_64_t2

tools/testing/selftests/powerpc/copyloops/Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
TEST_GEN_PROGS := copyuser_64_t0 copyuser_64_t1 copyuser_64_t2 \
3-
copyuser_p7_t0 copyuser_p7_t1 \
3+
copyuser_p7 copyuser_p7_vmx \
44
memcpy_64_t0 memcpy_64_t1 memcpy_64_t2 \
55
memcpy_p7_t0 memcpy_p7_t1 copy_mc_64 \
66
copyuser_64_exc_t0 copyuser_64_exc_t1 copyuser_64_exc_t2 \
@@ -28,10 +28,15 @@ $(OUTPUT)/copyuser_64_t%: copyuser_64.S $(EXTRA_SOURCES)
2828
-D SELFTEST_CASE=$(subst copyuser_64_t,,$(notdir $@)) \
2929
-o $@ $^
3030

31-
$(OUTPUT)/copyuser_p7_t%: copyuser_power7.S $(EXTRA_SOURCES)
31+
$(OUTPUT)/copyuser_p7: copyuser_power7.S $(EXTRA_SOURCES)
3232
$(CC) $(CPPFLAGS) $(CFLAGS) \
3333
-D COPY_LOOP=test___copy_tofrom_user_power7 \
34-
-D SELFTEST_CASE=$(subst copyuser_p7_t,,$(notdir $@)) \
34+
-o $@ $^
35+
36+
$(OUTPUT)/copyuser_p7_vmx: copyuser_power7.S $(EXTRA_SOURCES) ../utils.c
37+
$(CC) $(CPPFLAGS) $(CFLAGS) \
38+
-D COPY_LOOP=test___copy_tofrom_user_power7_vmx \
39+
-D VMX_TEST \
3540
-o $@ $^
3641

3742
# Strictly speaking, we only need the memcpy_64 test cases for big-endian

tools/testing/selftests/powerpc/copyloops/stubs.S

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
#include <asm/ppc_asm.h>
22

3-
FUNC_START(enter_vmx_usercopy)
4-
li r3,1
5-
blr
6-
7-
FUNC_START(exit_vmx_usercopy)
8-
li r3,0
9-
blr
10-
113
FUNC_START(enter_vmx_ops)
124
li r3,1
135
blr

tools/testing/selftests/powerpc/copyloops/validate.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
#define BUFLEN (MAX_LEN+MAX_OFFSET+2*MIN_REDZONE)
1313
#define POISON 0xa5
1414

15+
#ifdef VMX_TEST
16+
#define VMX_COPY_THRESHOLD 3328
17+
#endif
18+
1519
unsigned long COPY_LOOP(void *to, const void *from, unsigned long size);
1620

1721
static void do_one(char *src, char *dst, unsigned long src_off,
@@ -81,8 +85,12 @@ int test_copy_loop(void)
8185
/* Fill with sequential bytes */
8286
for (i = 0; i < BUFLEN; i++)
8387
fill[i] = i & 0xff;
84-
88+
#ifdef VMX_TEST
89+
/* Force sizes above kernel VMX threshold (3328) */
90+
for (len = VMX_COPY_THRESHOLD + 1; len < MAX_LEN; len++) {
91+
#else
8592
for (len = 1; len < MAX_LEN; len++) {
93+
#endif
8694
for (src_off = 0; src_off < MAX_OFFSET; src_off++) {
8795
for (dst_off = 0; dst_off < MAX_OFFSET; dst_off++) {
8896
do_one(src, dst, src_off, dst_off, len,
@@ -96,5 +104,10 @@ int test_copy_loop(void)
96104

97105
int main(void)
98106
{
107+
#ifdef VMX_TEST
108+
/* Skip if Altivec not present */
109+
SKIP_IF_MSG(!have_hwcap(PPC_FEATURE_HAS_ALTIVEC), "ALTIVEC not supported");
110+
#endif
111+
99112
return test_harness(test_copy_loop, str(COPY_LOOP));
100113
}

0 commit comments

Comments
 (0)