-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/powerpc/copyloops: Add memmove_64 test
While debugging an issue, we wanted to check whether the arch specific kernel memmove implementation is correct. This selftest could help test that. Suggested-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Suggested-by: Vaibhav Jain <vaibhav@linux.ibm.com> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/57242c1fe7aba6b7f0fcd0490303bfd5f222ee00.1631512686.git.riteshh@linux.ibm.com
- Loading branch information
Ritesh Harjani
authored and
Michael Ellerman
committed
Feb 12, 2022
1 parent
92e6dc2
commit 2504e5b
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ copyuser_64_exc_t0 | |
copyuser_64_exc_t1 | ||
copyuser_64_exc_t2 | ||
copy_mc_64 | ||
memmove_64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../../arch/powerpc/lib/mem_64.S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#include <asm/ppc_asm.h> | ||
|
||
FUNC_START(memcpy) | ||
b test_memcpy | ||
|
||
FUNC_START(backwards_memcpy) | ||
b test_backwards_memcpy |
58 changes: 58 additions & 0 deletions
58
tools/testing/selftests/powerpc/copyloops/memmove_validate.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include <malloc.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
#include "utils.h" | ||
|
||
void *TEST_MEMMOVE(const void *s1, const void *s2, size_t n); | ||
|
||
#define BUF_LEN 65536 | ||
#define MAX_OFFSET 512 | ||
|
||
size_t max(size_t a, size_t b) | ||
{ | ||
if (a >= b) | ||
return a; | ||
return b; | ||
} | ||
|
||
static int testcase_run(void) | ||
{ | ||
size_t i, src_off, dst_off, len; | ||
|
||
char *usermap = memalign(BUF_LEN, BUF_LEN); | ||
char *kernelmap = memalign(BUF_LEN, BUF_LEN); | ||
|
||
assert(usermap != NULL); | ||
assert(kernelmap != NULL); | ||
|
||
memset(usermap, 0, BUF_LEN); | ||
memset(kernelmap, 0, BUF_LEN); | ||
|
||
for (i = 0; i < BUF_LEN; i++) { | ||
usermap[i] = i & 0xff; | ||
kernelmap[i] = i & 0xff; | ||
} | ||
|
||
for (src_off = 0; src_off < MAX_OFFSET; src_off++) { | ||
for (dst_off = 0; dst_off < MAX_OFFSET; dst_off++) { | ||
for (len = 1; len < MAX_OFFSET - max(src_off, dst_off); len++) { | ||
|
||
memmove(usermap + dst_off, usermap + src_off, len); | ||
TEST_MEMMOVE(kernelmap + dst_off, kernelmap + src_off, len); | ||
if (memcmp(usermap, kernelmap, MAX_OFFSET) != 0) { | ||
printf("memmove failed at %ld %ld %ld\n", | ||
src_off, dst_off, len); | ||
abort(); | ||
} | ||
} | ||
} | ||
} | ||
return 0; | ||
} | ||
|
||
int main(void) | ||
{ | ||
return test_harness(testcase_run, "memmove"); | ||
} |