* [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes
@ 2019-09-03 21:43 Santosh Sivaraj
2019-09-03 21:43 ` [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe Santosh Sivaraj
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Santosh Sivaraj @ 2019-09-03 21:43 UTC (permalink / raw)
To: linuxppc-dev, Michael Ellerman; +Cc: Aneesh Kumar K.V
For sizes lesser than 128 bytes, the code branches out early without saving
the stack frame, which when restored later drops frame of the caller.
Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
arch/powerpc/lib/memcpy_mcsafe_64.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S
index 949976dc115d..cb882d9a6d8a 100644
--- a/arch/powerpc/lib/memcpy_mcsafe_64.S
+++ b/arch/powerpc/lib/memcpy_mcsafe_64.S
@@ -84,7 +84,6 @@ err1; stw r0,0(r3)
3: sub r5,r5,r6
cmpldi r5,128
- blt 5f
mflr r0
stdu r1,-STACKFRAMESIZE(r1)
@@ -99,6 +98,7 @@ err1; stw r0,0(r3)
std r22,STK_REG(R22)(r1)
std r0,STACKFRAMESIZE+16(r1)
+ blt 5f
srdi r6,r5,7
mtctr r6
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe
2019-09-03 21:43 [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Santosh Sivaraj
@ 2019-09-03 21:43 ` Santosh Sivaraj
2019-09-06 10:46 ` [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Christophe Leroy
2019-09-19 10:25 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Santosh Sivaraj @ 2019-09-03 21:43 UTC (permalink / raw)
To: linuxppc-dev, Michael Ellerman; +Cc: Aneesh Kumar K.V
Appropriate self tests for memcpy_mcsafe
Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
tools/testing/selftests/powerpc/copyloops/.gitignore | 1 +
tools/testing/selftests/powerpc/copyloops/Makefile | 7 ++++++-
tools/testing/selftests/powerpc/copyloops/asm/export.h | 1 +
.../testing/selftests/powerpc/copyloops/memcpy_mcsafe_64.S | 1 +
4 files changed, 9 insertions(+), 1 deletion(-)
create mode 120000 tools/testing/selftests/powerpc/copyloops/memcpy_mcsafe_64.S
diff --git a/tools/testing/selftests/powerpc/copyloops/.gitignore b/tools/testing/selftests/powerpc/copyloops/.gitignore
index de158104912a..12ef5b031974 100644
--- a/tools/testing/selftests/powerpc/copyloops/.gitignore
+++ b/tools/testing/selftests/powerpc/copyloops/.gitignore
@@ -11,3 +11,4 @@ memcpy_p7_t1
copyuser_64_exc_t0
copyuser_64_exc_t1
copyuser_64_exc_t2
+memcpy_mcsafe_64
diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
index 44574f3818b3..0917983a1c78 100644
--- a/tools/testing/selftests/powerpc/copyloops/Makefile
+++ b/tools/testing/selftests/powerpc/copyloops/Makefile
@@ -12,7 +12,7 @@ ASFLAGS = $(CFLAGS) -Wa,-mpower4
TEST_GEN_PROGS := copyuser_64_t0 copyuser_64_t1 copyuser_64_t2 \
copyuser_p7_t0 copyuser_p7_t1 \
memcpy_64_t0 memcpy_64_t1 memcpy_64_t2 \
- memcpy_p7_t0 memcpy_p7_t1 \
+ memcpy_p7_t0 memcpy_p7_t1 memcpy_mcsafe_64 \
copyuser_64_exc_t0 copyuser_64_exc_t1 copyuser_64_exc_t2
EXTRA_SOURCES := validate.c ../harness.c stubs.S
@@ -45,6 +45,11 @@ $(OUTPUT)/memcpy_p7_t%: memcpy_power7.S $(EXTRA_SOURCES)
-D SELFTEST_CASE=$(subst memcpy_p7_t,,$(notdir $@)) \
-o $@ $^
+$(OUTPUT)/memcpy_mcsafe_64: memcpy_mcsafe_64.S $(EXTRA_SOURCES)
+ $(CC) $(CPPFLAGS) $(CFLAGS) \
+ -D COPY_LOOP=test_memcpy_mcsafe \
+ -o $@ $^
+
$(OUTPUT)/copyuser_64_exc_t%: copyuser_64.S exc_validate.c ../harness.c \
copy_tofrom_user_reference.S stubs.S
$(CC) $(CPPFLAGS) $(CFLAGS) \
diff --git a/tools/testing/selftests/powerpc/copyloops/asm/export.h b/tools/testing/selftests/powerpc/copyloops/asm/export.h
index 05c1663c89b0..e6b80d5fbd14 100644
--- a/tools/testing/selftests/powerpc/copyloops/asm/export.h
+++ b/tools/testing/selftests/powerpc/copyloops/asm/export.h
@@ -1,3 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
#define EXPORT_SYMBOL(x)
+#define EXPORT_SYMBOL_GPL(x)
#define EXPORT_SYMBOL_KASAN(x)
diff --git a/tools/testing/selftests/powerpc/copyloops/memcpy_mcsafe_64.S b/tools/testing/selftests/powerpc/copyloops/memcpy_mcsafe_64.S
new file mode 120000
index 000000000000..f0feef3062f6
--- /dev/null
+++ b/tools/testing/selftests/powerpc/copyloops/memcpy_mcsafe_64.S
@@ -0,0 +1 @@
+../../../../../arch/powerpc/lib/memcpy_mcsafe_64.S
\ No newline at end of file
--
2.21.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes
2019-09-03 21:43 [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Santosh Sivaraj
2019-09-03 21:43 ` [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe Santosh Sivaraj
@ 2019-09-06 10:46 ` Christophe Leroy
2019-09-19 10:25 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Christophe Leroy @ 2019-09-06 10:46 UTC (permalink / raw)
To: Santosh Sivaraj, linuxppc-dev, Michael Ellerman; +Cc: Aneesh Kumar K.V
Hi,
The subjet is misleading. This isn't powerpc but only powerpc/64, and
this is not memcpy() but memcpy_mcsafe()
Christophe
Le 03/09/2019 à 23:43, Santosh Sivaraj a écrit :
> For sizes lesser than 128 bytes, the code branches out early without saving
> the stack frame, which when restored later drops frame of the caller.
>
> Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
> ---
> arch/powerpc/lib/memcpy_mcsafe_64.S | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/lib/memcpy_mcsafe_64.S b/arch/powerpc/lib/memcpy_mcsafe_64.S
> index 949976dc115d..cb882d9a6d8a 100644
> --- a/arch/powerpc/lib/memcpy_mcsafe_64.S
> +++ b/arch/powerpc/lib/memcpy_mcsafe_64.S
> @@ -84,7 +84,6 @@ err1; stw r0,0(r3)
>
> 3: sub r5,r5,r6
> cmpldi r5,128
> - blt 5f
>
> mflr r0
> stdu r1,-STACKFRAMESIZE(r1)
> @@ -99,6 +98,7 @@ err1; stw r0,0(r3)
> std r22,STK_REG(R22)(r1)
> std r0,STACKFRAMESIZE+16(r1)
>
> + blt 5f
> srdi r6,r5,7
> mtctr r6
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes
2019-09-03 21:43 [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Santosh Sivaraj
2019-09-03 21:43 ` [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe Santosh Sivaraj
2019-09-06 10:46 ` [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Christophe Leroy
@ 2019-09-19 10:25 ` Michael Ellerman
2 siblings, 0 replies; 4+ messages in thread
From: Michael Ellerman @ 2019-09-19 10:25 UTC (permalink / raw)
To: Santosh Sivaraj, linuxppc-dev; +Cc: Aneesh Kumar K.V
On Tue, 2019-09-03 at 21:43:58 UTC, Santosh Sivaraj wrote:
> For sizes lesser than 128 bytes, the code branches out early without saving
> the stack frame, which when restored later drops frame of the caller.
>
> Tested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
Series applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/20055a8bfaaa75f2cb9c23ecc8ab12b4abd8dc84
cheers
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-09-19 10:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-03 21:43 [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Santosh Sivaraj
2019-09-03 21:43 ` [PATCH 2/2] seltests/powerpc: Add a selftest for memcpy_mcsafe Santosh Sivaraj
2019-09-06 10:46 ` [PATCH 1/2] powerpc/memcpy: Fix stack corruption for smaller sizes Christophe Leroy
2019-09-19 10:25 ` Michael Ellerman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).