summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-31 14:00:22 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-05 11:56:01 +0100
commit8078c5e11fd8b5bfaaaf4ee1a9dad2f3530e4714 (patch)
tree511072da5fba19acf84e42d36a8c9d2cb5f665f8 /meta
parent223eb651a693726e9517d45cb1a703d860efaea0 (diff)
downloadpoky-8078c5e11fd8b5bfaaaf4ee1a9dad2f3530e4714.tar.gz
cryptodev: Add backported patches for 4.6+ kernels
This allows 4.6 onward kernels to build, backported from upstream master. (From OE-Core rev: e0e073a8e60b965333b537436a3441fc1ec37372) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-kernel/cryptodev/cryptodev.inc4
-rw-r--r--meta/recipes-kernel/cryptodev/files/06d6b560c6e45dc317dae47c74706fa43f4a31d8.patch54
-rw-r--r--meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch279
3 files changed, 336 insertions, 1 deletions
diff --git a/meta/recipes-kernel/cryptodev/cryptodev.inc b/meta/recipes-kernel/cryptodev/cryptodev.inc
index ade7ef9cea..160ab30840 100644
--- a/meta/recipes-kernel/cryptodev/cryptodev.inc
+++ b/meta/recipes-kernel/cryptodev/cryptodev.inc
@@ -3,7 +3,9 @@ HOMEPAGE = "http://cryptodev-linux.org/"
3LICENSE = "GPLv2" 3LICENSE = "GPLv2"
4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263" 4LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
5 5
6SRC_URI = "http://download.gna.org/cryptodev-linux/cryptodev-linux-${PV}.tar.gz" 6SRC_URI = "http://download.gna.org/cryptodev-linux/cryptodev-linux-${PV}.tar.gz \
7 file://06d6b560c6e45dc317dae47c74706fa43f4a31d8.patch \
8 file://cb186f682679383e8b5806240927903730ce85d9.patch"
7 9
8SRC_URI[md5sum] = "02644cc4cd02301e0b503a332eb2f0b5" 10SRC_URI[md5sum] = "02644cc4cd02301e0b503a332eb2f0b5"
9SRC_URI[sha256sum] = "67fabde9fb67b286a96c4f45b594b0eccd0f761b495705c18f2ae9461b831376" 11SRC_URI[sha256sum] = "67fabde9fb67b286a96c4f45b594b0eccd0f761b495705c18f2ae9461b831376"
diff --git a/meta/recipes-kernel/cryptodev/files/06d6b560c6e45dc317dae47c74706fa43f4a31d8.patch b/meta/recipes-kernel/cryptodev/files/06d6b560c6e45dc317dae47c74706fa43f4a31d8.patch
new file mode 100644
index 0000000000..cb556e1e24
--- /dev/null
+++ b/meta/recipes-kernel/cryptodev/files/06d6b560c6e45dc317dae47c74706fa43f4a31d8.patch
@@ -0,0 +1,54 @@
1From f14b4706b0d04988e7e5bc8c4d2aefef9f029d9d Mon Sep 17 00:00:00 2001
2From: Michael Weiser <michael.weiser@gmx.de>
3Date: Fri, 5 Aug 2016 18:43:55 +0200
4Subject: [PATCH] Adjust to recent user page API changes
5
64.6.0 basically renamed get_user_pages() to get_user_pages_remote() and
7introduced a new get_user_pages() that always works on the current
8task.[1] Distinguish the two APIs based on kernel version we're
9compiling for.
10
11Also, there seems to have been a massive cleansing of
12page_cache_release(page) in favour of put_page(page)[2] which was an
13alias for put_page(page)[3] since 2.6.0. Before that beginning with
142.4.0 both page_cache_release(page) and put_page(page) have been aliases
15for __free_page(page). So using put_page() instead of
16page_cache_release(page) will produce identical code for anything after
172.4.0.
18
19[1] https://lkml.org/lkml/2016/2/10/555
20[2] https://www.spinics.net/lists/linux-fsdevel/msg95923.html
21[3] https://www.spinics.net/lists/linux-fsdevel/msg95922.html
22---
23 zc.c | 9 +++++++--
24 1 file changed, 7 insertions(+), 2 deletions(-)
25
26Upstream-Status: Backport [from master for 4.8 kernels]
27
28Index: cryptodev-linux-1.8/zc.c
29===================================================================
30--- cryptodev-linux-1.8.orig/zc.c
31+++ cryptodev-linux-1.8/zc.c
32@@ -59,7 +59,12 @@ int __get_userbuf(uint8_t __user *addr,
33 }
34
35 down_read(&mm->mmap_sem);
36- ret = get_user_pages(task, mm,
37+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0))
38+ ret = get_user_pages_remote(
39+#else
40+ ret = get_user_pages(
41+#endif
42+ task, mm,
43 (unsigned long)addr, pgcount, write, 0, pg, NULL);
44 up_read(&mm->mmap_sem);
45 if (ret != pgcount)
46@@ -119,7 +124,7 @@ void release_user_pages(struct csession
47 else
48 ses->readonly_pages--;
49
50- page_cache_release(ses->pages[i]);
51+ put_page(ses->pages[i]);
52 }
53 ses->used_pages = 0;
54 }
diff --git a/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch b/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch
new file mode 100644
index 0000000000..eb0eab63bd
--- /dev/null
+++ b/meta/recipes-kernel/cryptodev/files/cb186f682679383e8b5806240927903730ce85d9.patch
@@ -0,0 +1,279 @@
1From cb186f682679383e8b5806240927903730ce85d9 Mon Sep 17 00:00:00 2001
2From: Michael Weiser <michael.weiser@gmx.de>
3Date: Fri, 5 Aug 2016 17:26:27 +0200
4Subject: [PATCH] Support skcipher in addition to ablkcipher API
5
6The ablkcipher API is being phased out[1]. The unified skcipher API
7seems to have made its entry with 4.3.[3, 4] By what can be seen from
8migration patches[1.ff.], it's a drop-in replacement.
9
10Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2].
11
12Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and
13retain support for old kernels. Make it decide which API to use and provide
14appropriate function calls and type definitions. Since the ablkcipher and
15skcipher APIs are so similar, those are mainly defines for corresponding
16pseudo-functions in namespace cryptodev_ derived directly from their API
17counterparts.
18
19Compiles and works (i.e. checks pass) with Debian testing 4.6.4 kernel
20as well as 4.8-rc2+ Linus git tree as of today. (Both require a fix for
21changed page access API[5].)
22
23[1] https://www.spinics.net/lists/linux-crypto/msg18133.html
24[2] https://www.spinics.net/lists/linux-crypto/msg18154.html, line 120
25[3] https://www.spinics.net/lists/linux-crypto/msg16373.html
26[4] https://www.spinics.net/lists/linux-crypto/msg16294.html
27[5] https://github.com/cryptodev-linux/cryptodev-linux/pull/14
28---
29 cipherapi.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
30 cryptlib.c | 40 ++++++++++++++++++----------------------
31 cryptlib.h | 6 ++++--
32 ioctl.c | 4 ++--
33 4 files changed, 84 insertions(+), 26 deletions(-)
34 create mode 100644 cipherapi.h
35
36Upstream-Status: Backport [from master for 4.8 kernels]
37
38Index: cryptodev-linux-1.8/cipherapi.h
39===================================================================
40--- /dev/null
41+++ cryptodev-linux-1.8/cipherapi.h
42@@ -0,0 +1,60 @@
43+#ifndef CIPHERAPI_H
44+# define CIPHERAPI_H
45+
46+#include <linux/version.h>
47+
48+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
49+# include <linux/crypto.h>
50+
51+typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t;
52+typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t;
53+typedef struct ablkcipher_request cryptodev_blkcipher_request_t;
54+
55+# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher
56+# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg
57+# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize
58+# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize
59+# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask
60+# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey
61+
62+static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) {
63+ if (c)
64+ crypto_free_ablkcipher(c);
65+}
66+
67+# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc
68+# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback
69+
70+static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) {
71+ if (r)
72+ ablkcipher_request_free(r);
73+}
74+
75+# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt
76+# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt
77+# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt
78+# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm
79+#else
80+#include <crypto/skcipher.h>
81+
82+typedef struct skcipher_alg cryptodev_blkcipher_alg_t;
83+typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t;
84+typedef struct skcipher_request cryptodev_blkcipher_request_t;
85+
86+# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher
87+# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg
88+# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize
89+# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize
90+# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask
91+# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey
92+# define cryptodev_crypto_free_blkcipher crypto_free_skcipher
93+# define cryptodev_blkcipher_request_alloc skcipher_request_alloc
94+# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback
95+# define cryptodev_blkcipher_request_free skcipher_request_free
96+# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt
97+# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt
98+# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt
99+# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm
100+#endif
101+
102+#endif
103Index: cryptodev-linux-1.8/cryptlib.c
104===================================================================
105--- cryptodev-linux-1.8.orig/cryptlib.c
106+++ cryptodev-linux-1.8/cryptlib.c
107@@ -23,7 +23,6 @@
108 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
109 */
110
111-#include <linux/crypto.h>
112 #include <linux/mm.h>
113 #include <linux/highmem.h>
114 #include <linux/ioctl.h>
115@@ -37,6 +36,7 @@
116 #include <linux/rtnetlink.h>
117 #include <crypto/authenc.h>
118 #include "cryptodev_int.h"
119+#include "cipherapi.h"
120
121
122 struct cryptodev_result {
123@@ -133,15 +133,15 @@ int cryptodev_cipher_init(struct cipher_
124 int ret;
125
126 if (aead == 0) {
127- struct ablkcipher_alg *alg;
128+ cryptodev_blkcipher_alg_t *alg;
129
130- out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0);
131+ out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0);
132 if (unlikely(IS_ERR(out->async.s))) {
133 ddebug(1, "Failed to load cipher %s", alg_name);
134 return -EINVAL;
135 }
136
137- alg = crypto_ablkcipher_alg(out->async.s);
138+ alg = cryptodev_crypto_blkcipher_alg(out->async.s);
139 if (alg != NULL) {
140 /* Was correct key length supplied? */
141 if (alg->max_keysize > 0 &&
142@@ -154,11 +154,11 @@ int cryptodev_cipher_init(struct cipher_
143 }
144 }
145
146- out->blocksize = crypto_ablkcipher_blocksize(out->async.s);
147- out->ivsize = crypto_ablkcipher_ivsize(out->async.s);
148- out->alignmask = crypto_ablkcipher_alignmask(out->async.s);
149+ out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s);
150+ out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s);
151+ out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s);
152
153- ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen);
154+ ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen);
155 } else {
156 out->async.as = crypto_alloc_aead(alg_name, 0, 0);
157 if (unlikely(IS_ERR(out->async.as))) {
158@@ -191,14 +191,14 @@ int cryptodev_cipher_init(struct cipher_
159 init_completion(&out->async.result->completion);
160
161 if (aead == 0) {
162- out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL);
163+ out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL);
164 if (unlikely(!out->async.request)) {
165 derr(1, "error allocating async crypto request");
166 ret = -ENOMEM;
167 goto error;
168 }
169
170- ablkcipher_request_set_callback(out->async.request,
171+ cryptodev_blkcipher_request_set_callback(out->async.request,
172 CRYPTO_TFM_REQ_MAY_BACKLOG,
173 cryptodev_complete, out->async.result);
174 } else {
175@@ -218,10 +218,8 @@ int cryptodev_cipher_init(struct cipher_
176 return 0;
177 error:
178 if (aead == 0) {
179- if (out->async.request)
180- ablkcipher_request_free(out->async.request);
181- if (out->async.s)
182- crypto_free_ablkcipher(out->async.s);
183+ cryptodev_blkcipher_request_free(out->async.request);
184+ cryptodev_crypto_free_blkcipher(out->async.s);
185 } else {
186 if (out->async.arequest)
187 aead_request_free(out->async.arequest);
188@@ -237,10 +235,8 @@ void cryptodev_cipher_deinit(struct ciph
189 {
190 if (cdata->init) {
191 if (cdata->aead == 0) {
192- if (cdata->async.request)
193- ablkcipher_request_free(cdata->async.request);
194- if (cdata->async.s)
195- crypto_free_ablkcipher(cdata->async.s);
196+ cryptodev_blkcipher_request_free(cdata->async.request);
197+ cryptodev_crypto_free_blkcipher(cdata->async.s);
198 } else {
199 if (cdata->async.arequest)
200 aead_request_free(cdata->async.arequest);
201@@ -289,10 +285,10 @@ ssize_t cryptodev_cipher_encrypt(struct
202 reinit_completion(&cdata->async.result->completion);
203
204 if (cdata->aead == 0) {
205- ablkcipher_request_set_crypt(cdata->async.request,
206+ cryptodev_blkcipher_request_set_crypt(cdata->async.request,
207 (struct scatterlist *)src, dst,
208 len, cdata->async.iv);
209- ret = crypto_ablkcipher_encrypt(cdata->async.request);
210+ ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request);
211 } else {
212 aead_request_set_crypt(cdata->async.arequest,
213 (struct scatterlist *)src, dst,
214@@ -311,10 +307,10 @@ ssize_t cryptodev_cipher_decrypt(struct
215
216 reinit_completion(&cdata->async.result->completion);
217 if (cdata->aead == 0) {
218- ablkcipher_request_set_crypt(cdata->async.request,
219+ cryptodev_blkcipher_request_set_crypt(cdata->async.request,
220 (struct scatterlist *)src, dst,
221 len, cdata->async.iv);
222- ret = crypto_ablkcipher_decrypt(cdata->async.request);
223+ ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request);
224 } else {
225 aead_request_set_crypt(cdata->async.arequest,
226 (struct scatterlist *)src, dst,
227Index: cryptodev-linux-1.8/cryptlib.h
228===================================================================
229--- cryptodev-linux-1.8.orig/cryptlib.h
230+++ cryptodev-linux-1.8/cryptlib.h
231@@ -3,6 +3,8 @@
232
233 #include <linux/version.h>
234
235+#include "cipherapi.h"
236+
237 struct cipher_data {
238 int init; /* 0 uninitialized */
239 int blocksize;
240@@ -12,8 +14,8 @@ struct cipher_data {
241 int alignmask;
242 struct {
243 /* block ciphers */
244- struct crypto_ablkcipher *s;
245- struct ablkcipher_request *request;
246+ cryptodev_crypto_blkcipher_t *s;
247+ cryptodev_blkcipher_request_t *request;
248
249 /* AEAD ciphers */
250 struct crypto_aead *as;
251Index: cryptodev-linux-1.8/ioctl.c
252===================================================================
253--- cryptodev-linux-1.8.orig/ioctl.c
254+++ cryptodev-linux-1.8/ioctl.c
255@@ -34,7 +34,6 @@
256 */
257
258 #include <crypto/hash.h>
259-#include <linux/crypto.h>
260 #include <linux/mm.h>
261 #include <linux/highmem.h>
262 #include <linux/ioctl.h>
263@@ -53,6 +52,7 @@
264 #include "cryptodev_int.h"
265 #include "zc.h"
266 #include "version.h"
267+#include "cipherapi.h"
268
269 MODULE_AUTHOR("Nikos Mavrogiannopoulos <nmav@gnutls.org>");
270 MODULE_DESCRIPTION("CryptoDev driver");
271@@ -765,7 +765,7 @@ static int get_session_info(struct fcryp
272
273 if (ses_ptr->cdata.init) {
274 if (ses_ptr->cdata.aead == 0)
275- tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s);
276+ tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s);
277 else
278 tfm = crypto_aead_tfm(ses_ptr->cdata.async.as);
279 tfm_info_to_alg_info(&siop->cipher_info, tfm);