summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch')
-rw-r--r--recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch58
1 files changed, 58 insertions, 0 deletions
diff --git a/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch b/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch
new file mode 100644
index 00000000..d98e5887
--- /dev/null
+++ b/recipes-kernel/cryptodev/sdk_patches/0056-fix-set-min-value-when-allocating-alligned-memory-bu.patch
@@ -0,0 +1,58 @@
1From ad7fee26da24fca57efee5ba10756e001769b2ce Mon Sep 17 00:00:00 2001
2From: Alexe Radu <radu.alexe@nxp.com>
3Date: Tue, 25 Oct 2016 16:46:11 +0300
4Subject: [PATCH 056/104] fix: set min value when allocating alligned memory
5 buffers
6
7The function "posix_memalign()" requires that the alignment be at least
8sizeof(void*). In some situations the alignmask for some crypto algorithms
9is smaller then the minimum required. For ex. on 64-bit platforms where
10the alignment may be 4 bytes.
11
12Signed-off-by: Alexe Radu <radu.alexe@nxp.com>
13Signed-off-by: Cristian Stoica <cristian.stoica@nxp.com>
14---
15 tests/async_speed.c | 4 ++++
16 tests/speed.c | 2 ++
17 2 files changed, 6 insertions(+)
18
19diff --git a/tests/async_speed.c b/tests/async_speed.c
20index 263ead7..b895a85 100644
21--- a/tests/async_speed.c
22+++ b/tests/async_speed.c
23@@ -232,6 +232,7 @@ int run_test(int id, struct test_params tp)
24 int get_alignmask(int fdc, struct session_op *sess)
25 {
26 int alignmask;
27+ int min_alignmask = sizeof(void*) - 1;
28
29 #ifdef CIOCGSESSINFO
30 struct session_info_op siop;
31@@ -242,6 +243,9 @@ int get_alignmask(int fdc, struct session_op *sess)
32 return -EINVAL;
33 }
34 alignmask = siop.alignmask;
35+ if (alignmask < min_alignmask) {
36+ alignmask = min_alignmask;
37+ }
38 #else
39 alignmask = 0;
40 #endif
41diff --git a/tests/speed.c b/tests/speed.c
42index bd6d2b2..0b14c88 100644
43--- a/tests/speed.c
44+++ b/tests/speed.c
45@@ -80,8 +80,10 @@ int encrypt_data(struct session_op *sess, int fdc, int chunksize, int alignmask)
46 double total = 0;
47 double secs, ddata, dspeed;
48 char metric[16];
49+ int min_alignmask = sizeof(void*) - 1;
50
51 if (alignmask) {
52+ alignmask = ((alignmask < min_alignmask) ? min_alignmask : alignmask);
53 if (posix_memalign((void **)&buffer, MAX(alignmask + 1, sizeof(void*)), chunksize)) {
54 printf("posix_memalign() failed! (mask %x, size: %d)\n", alignmask+1, chunksize);
55 return 1;
56--
572.10.2
58