* [PATCH v4 2/2] powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx
2026-03-04 12:22 [PATCH v4 1/2] powerpc: fix KUAP warning in VMX usercopy path Sayali Patil
@ 2026-03-04 12:22 ` Sayali Patil
2026-03-05 4:39 ` Venkat Rao Bagalkote
0 siblings, 1 reply; 3+ messages in thread
From: Sayali Patil @ 2026-03-04 12:22 UTC (permalink / raw)
To: linuxppc-dev, maddy
Cc: aboorvad, sshegde, chleroy, riteshh, hbathini, ming.lei, csander,
czhong, venkat88
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>
---
v3->v4
No changes in the patch.
v3: https://lore.kernel.org/all/20260304053506.118632-2-sayalip@linux.ibm.com/
---
.../selftests/powerpc/copyloops/.gitignore | 4 ++--
.../testing/selftests/powerpc/copyloops/Makefile | 11 ++++++++---
tools/testing/selftests/powerpc/copyloops/stubs.S | 8 --------
.../selftests/powerpc/copyloops/validate.c | 15 ++++++++++++++-
4 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/powerpc/copyloops/.gitignore b/tools/testing/selftests/powerpc/copyloops/.gitignore
index 7283e8b07b75..80d4270a71ac 100644
--- a/tools/testing/selftests/powerpc/copyloops/.gitignore
+++ b/tools/testing/selftests/powerpc/copyloops/.gitignore
@@ -2,8 +2,8 @@
copyuser_64_t0
copyuser_64_t1
copyuser_64_t2
-copyuser_p7_t0
-copyuser_p7_t1
+copyuser_p7
+copyuser_p7_vmx
memcpy_64_t0
memcpy_64_t1
memcpy_64_t2
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index 42940f92d832..0c8efb0bddeb 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-2.0
TEST_GEN_PROGS := copyuser_64_t0 copyuser_64_t1 copyuser_64_t2 \
- copyuser_p7_t0 copyuser_p7_t1 \
+ copyuser_p7 copyuser_p7_vmx \
memcpy_64_t0 memcpy_64_t1 memcpy_64_t2 \
memcpy_p7_t0 memcpy_p7_t1 copy_mc_64 \
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)
-D SELFTEST_CASE=$(subst copyuser_64_t,,$(notdir $@)) \
-o $@ $^
-$(OUTPUT)/copyuser_p7_t%: copyuser_power7.S $(EXTRA_SOURCES)
+$(OUTPUT)/copyuser_p7: copyuser_power7.S $(EXTRA_SOURCES)
$(CC) $(CPPFLAGS) $(CFLAGS) \
-D COPY_LOOP=test___copy_tofrom_user_power7 \
- -D SELFTEST_CASE=$(subst copyuser_p7_t,,$(notdir $@)) \
+ -o $@ $^
+
+$(OUTPUT)/copyuser_p7_vmx: copyuser_power7.S $(EXTRA_SOURCES) ../utils.c
+ $(CC) $(CPPFLAGS) $(CFLAGS) \
+ -D COPY_LOOP=test___copy_tofrom_user_power7_vmx \
+ -D VMX_TEST \
-o $@ $^
# Strictly speaking, we only need the memcpy_64 test cases for big-endian
diff --git a/tools/testing/selftests/powerpc/copyloops/stubs.S b/tools/testing/selftests/powerpc/copyloops/stubs.S
index ec8bcf2bf1c2..3a9cb8c9a3ee 100644
--- a/tools/testing/selftests/powerpc/copyloops/stubs.S
+++ b/tools/testing/selftests/powerpc/copyloops/stubs.S
@@ -1,13 +1,5 @@
#include <asm/ppc_asm.h>
-FUNC_START(enter_vmx_usercopy)
- li r3,1
- blr
-
-FUNC_START(exit_vmx_usercopy)
- li r3,0
- blr
-
FUNC_START(enter_vmx_ops)
li r3,1
blr
diff --git a/tools/testing/selftests/powerpc/copyloops/validate.c b/tools/testing/selftests/powerpc/copyloops/validate.c
index 0f6873618552..fb822534fbe9 100644
--- a/tools/testing/selftests/powerpc/copyloops/validate.c
+++ b/tools/testing/selftests/powerpc/copyloops/validate.c
@@ -12,6 +12,10 @@
#define BUFLEN (MAX_LEN+MAX_OFFSET+2*MIN_REDZONE)
#define POISON 0xa5
+#ifdef VMX_TEST
+#define VMX_COPY_THRESHOLD 3328
+#endif
+
unsigned long COPY_LOOP(void *to, const void *from, unsigned long size);
static void do_one(char *src, char *dst, unsigned long src_off,
@@ -81,8 +85,12 @@ int test_copy_loop(void)
/* Fill with sequential bytes */
for (i = 0; i < BUFLEN; i++)
fill[i] = i & 0xff;
-
+#ifdef VMX_TEST
+ /* Force sizes above kernel VMX threshold (3328) */
+ for (len = VMX_COPY_THRESHOLD + 1; len < MAX_LEN; len++) {
+#else
for (len = 1; len < MAX_LEN; len++) {
+#endif
for (src_off = 0; src_off < MAX_OFFSET; src_off++) {
for (dst_off = 0; dst_off < MAX_OFFSET; dst_off++) {
do_one(src, dst, src_off, dst_off, len,
@@ -96,5 +104,10 @@ int test_copy_loop(void)
int main(void)
{
+#ifdef VMX_TEST
+ /* Skip if Altivec not present */
+ SKIP_IF_MSG(!have_hwcap(PPC_FEATURE_HAS_ALTIVEC), "ALTIVEC not supported");
+#endif
+
return test_harness(test_copy_loop, str(COPY_LOOP));
}
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4 2/2] powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx
2026-03-04 12:22 ` [PATCH v4 2/2] powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx Sayali Patil
@ 2026-03-05 4:39 ` Venkat Rao Bagalkote
0 siblings, 0 replies; 3+ messages in thread
From: Venkat Rao Bagalkote @ 2026-03-05 4:39 UTC (permalink / raw)
To: Sayali Patil, linuxppc-dev, maddy
Cc: aboorvad, sshegde, chleroy, riteshh, hbathini, ming.lei, csander,
czhong
On 04/03/26 5:52 pm, Sayali Patil wrote:
> 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>
# timeout set to 130
# selftests: powerpc/copyloops: copyuser_p7
# test: test___copy_tofrom_user_power7
# tags: git_version:v7.0-rc2-92-gb7b2ed2d96ea
# success: test___copy_tofrom_user_power7
ok 4 selftests: powerpc/copyloops: copyuser_p7
# timeout set to 130
# selftests: powerpc/copyloops: copyuser_p7_vmx
# test: test___copy_tofrom_user_power7_vmx
# tags: git_version:v7.0-rc2-92-gb7b2ed2d96ea
# success: test___copy_tofrom_user_power7_vmx
Regards,
Venkat.
>
> v3->v4
> No changes in the patch.
>
> v3: https://lore.kernel.org/all/20260304053506.118632-2-sayalip@linux.ibm.com/
>
> ---
> .../selftests/powerpc/copyloops/.gitignore | 4 ++--
> .../testing/selftests/powerpc/copyloops/Makefile | 11 ++++++++---
> tools/testing/selftests/powerpc/copyloops/stubs.S | 8 --------
> .../selftests/powerpc/copyloops/validate.c | 15 ++++++++++++++-
> 4 files changed, 24 insertions(+), 14 deletions(-)
>
> diff --git a/tools/testing/selftests/powerpc/copyloops/.gitignore b/tools/testing/selftests/powerpc/copyloops/.gitignore
> index 7283e8b07b75..80d4270a71ac 100644
> --- a/tools/testing/selftests/powerpc/copyloops/.gitignore
> +++ b/tools/testing/selftests/powerpc/copyloops/.gitignore
> @@ -2,8 +2,8 @@
> copyuser_64_t0
> copyuser_64_t1
> copyuser_64_t2
> -copyuser_p7_t0
> -copyuser_p7_t1
> +copyuser_p7
> +copyuser_p7_vmx
> memcpy_64_t0
> memcpy_64_t1
> memcpy_64_t2
> diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
> index 42940f92d832..0c8efb0bddeb 100644
> --- a/tools/testing/selftests/powerpc/copyloops/Makefile
> +++ b/tools/testing/selftests/powerpc/copyloops/Makefile
> @@ -1,6 +1,6 @@
> # SPDX-License-Identifier: GPL-2.0
> TEST_GEN_PROGS := copyuser_64_t0 copyuser_64_t1 copyuser_64_t2 \
> - copyuser_p7_t0 copyuser_p7_t1 \
> + copyuser_p7 copyuser_p7_vmx \
> memcpy_64_t0 memcpy_64_t1 memcpy_64_t2 \
> memcpy_p7_t0 memcpy_p7_t1 copy_mc_64 \
> 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)
> -D SELFTEST_CASE=$(subst copyuser_64_t,,$(notdir $@)) \
> -o $@ $^
>
> -$(OUTPUT)/copyuser_p7_t%: copyuser_power7.S $(EXTRA_SOURCES)
> +$(OUTPUT)/copyuser_p7: copyuser_power7.S $(EXTRA_SOURCES)
> $(CC) $(CPPFLAGS) $(CFLAGS) \
> -D COPY_LOOP=test___copy_tofrom_user_power7 \
> - -D SELFTEST_CASE=$(subst copyuser_p7_t,,$(notdir $@)) \
> + -o $@ $^
> +
> +$(OUTPUT)/copyuser_p7_vmx: copyuser_power7.S $(EXTRA_SOURCES) ../utils.c
> + $(CC) $(CPPFLAGS) $(CFLAGS) \
> + -D COPY_LOOP=test___copy_tofrom_user_power7_vmx \
> + -D VMX_TEST \
> -o $@ $^
>
> # Strictly speaking, we only need the memcpy_64 test cases for big-endian
> diff --git a/tools/testing/selftests/powerpc/copyloops/stubs.S b/tools/testing/selftests/powerpc/copyloops/stubs.S
> index ec8bcf2bf1c2..3a9cb8c9a3ee 100644
> --- a/tools/testing/selftests/powerpc/copyloops/stubs.S
> +++ b/tools/testing/selftests/powerpc/copyloops/stubs.S
> @@ -1,13 +1,5 @@
> #include <asm/ppc_asm.h>
>
> -FUNC_START(enter_vmx_usercopy)
> - li r3,1
> - blr
> -
> -FUNC_START(exit_vmx_usercopy)
> - li r3,0
> - blr
> -
> FUNC_START(enter_vmx_ops)
> li r3,1
> blr
> diff --git a/tools/testing/selftests/powerpc/copyloops/validate.c b/tools/testing/selftests/powerpc/copyloops/validate.c
> index 0f6873618552..fb822534fbe9 100644
> --- a/tools/testing/selftests/powerpc/copyloops/validate.c
> +++ b/tools/testing/selftests/powerpc/copyloops/validate.c
> @@ -12,6 +12,10 @@
> #define BUFLEN (MAX_LEN+MAX_OFFSET+2*MIN_REDZONE)
> #define POISON 0xa5
>
> +#ifdef VMX_TEST
> +#define VMX_COPY_THRESHOLD 3328
> +#endif
> +
> unsigned long COPY_LOOP(void *to, const void *from, unsigned long size);
>
> static void do_one(char *src, char *dst, unsigned long src_off,
> @@ -81,8 +85,12 @@ int test_copy_loop(void)
> /* Fill with sequential bytes */
> for (i = 0; i < BUFLEN; i++)
> fill[i] = i & 0xff;
> -
> +#ifdef VMX_TEST
> + /* Force sizes above kernel VMX threshold (3328) */
> + for (len = VMX_COPY_THRESHOLD + 1; len < MAX_LEN; len++) {
> +#else
> for (len = 1; len < MAX_LEN; len++) {
> +#endif
> for (src_off = 0; src_off < MAX_OFFSET; src_off++) {
> for (dst_off = 0; dst_off < MAX_OFFSET; dst_off++) {
> do_one(src, dst, src_off, dst_off, len,
> @@ -96,5 +104,10 @@ int test_copy_loop(void)
>
> int main(void)
> {
> +#ifdef VMX_TEST
> + /* Skip if Altivec not present */
> + SKIP_IF_MSG(!have_hwcap(PPC_FEATURE_HAS_ALTIVEC), "ALTIVEC not supported");
> +#endif
> +
> return test_harness(test_copy_loop, str(COPY_LOOP));
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4 2/2] powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx
@ 2026-03-09 5:01 Ritesh Harjani
0 siblings, 0 replies; 3+ messages in thread
From: Ritesh Harjani @ 2026-03-09 5:01 UTC (permalink / raw)
To: Sayali Patil, linuxppc-dev, maddy
Cc: aboorvad, sshegde, chleroy, riteshh, hbathini, ming.lei, csander,
czhong, venkat88
Sayali Patil <sayalip@linux.ibm.com> writes:
> 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>
> ---
>
The changes looks good to me. Please feel free to add:
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-09 5:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-09 5:01 [PATCH v4 2/2] powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx Ritesh Harjani
-- strict thread matches above, loose matches on Subject: below --
2026-03-04 12:22 [PATCH v4 1/2] powerpc: fix KUAP warning in VMX usercopy path Sayali Patil
2026-03-04 12:22 ` [PATCH v4 2/2] powerpc/selftests/copyloops: extend selftest to exercise __copy_tofrom_user_power7_vmx Sayali Patil
2026-03-05 4:39 ` Venkat Rao Bagalkote
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox