diff --git a/core/linux-kirkwood-dt/PKGBUILD b/core/linux-kirkwood-dt/PKGBUILD index d1ec7c7ac..a3870dd9a 100644 --- a/core/linux-kirkwood-dt/PKGBUILD +++ b/core/linux-kirkwood-dt/PKGBUILD @@ -8,7 +8,7 @@ _kernelname=${pkgbase#linux} _desc="Marvell Kirkwood DT" pkgver=4.7.1 srcver=${pkgver%.0} -pkgrel=1 +pkgrel=2 cryptodev_commit=7a3a9ee1329f7224b4fc564b80ef8160457caf76 bfqver=v8r2 @@ -38,7 +38,9 @@ source=("https://kernel.org/pub/linux/kernel/v4.x/linux-${srcver}.tar.xz" "ftp://teambelgium.net/bfq/patches/${bfqkern}.0-${bfqver}/0004-block-bfq-turn-BFQ-v7r11-for-4.7.0-into-BFQ-${bfqver}-for.patch" 'goflexhome_fdt.patch' 'linux.preset' - 'cryptodev_linux_4.6_fix.patch') + 'pageaccess_fix_for_4.6+.patch' + 'support_skcipher_and_ablkcipher.patch' + 'fix_test_compile_time_warnings.patch') md5sums=('764e9cc14e43bddef944381b1fe32574' '3bad68b8a29e154ebd4e0da7f613c3f2' 'c02d088db6c0b3d271526befc611c00c' @@ -47,16 +49,20 @@ md5sums=('764e9cc14e43bddef944381b1fe32574' 'ad56ca4e2a29a3b76f3526c262d9fec1' 'f2c3aabfbb8319134fc2f041bf239b50' '275d66e9de98296d689a3b17871defaf' - 'ebc1b89f720c84709b772ec2bf68f014' + 'a873c975acf24c3ef0225b9fcd3f3e1e' '1bb4a4a11135998454cce698fe373f3a' 'ce1975f40c48ec1b08dd09447ab043ca' '959e49540dac4c5e689ad9037150a360' - 'c7cf472186a62d3b972d65a36ea6be72') + 'b92624323adb5f874a06b9b05c1954a0' + '510d6cc1126153ccfbd33cda64a81d74' + '1a17740b0cbed752d3afa963cdb26ba0') prepare() { msg2 "Patching cryptodev" cd "${srcdir}/cryptodev-linux-${cryptodev_commit}" - patch -Np1 -i "${srcdir}/cryptodev_linux_4.6_fix.patch" + patch -Np1 -i "${srcdir}/pageaccess_fix_for_4.6+.patch" + patch -Np1 -i "${srcdir}/support_skcipher_and_ablkcipher.patch" + patch -Np1 -i "${srcdir}/fix_test_compile_time_warnings.patch" cd "${srcdir}/linux-${srcver}" diff --git a/core/linux-kirkwood-dt/cryptodev_linux_4.6_fix.patch b/core/linux-kirkwood-dt/cryptodev_linux_4.6_fix.patch deleted file mode 100644 index a28c4d8bd..000000000 --- a/core/linux-kirkwood-dt/cryptodev_linux_4.6_fix.patch +++ /dev/null @@ -1,40 +0,0 @@ -From cdbe7ee5978704c788e91170467fe0db064650fe Mon Sep 17 00:00:00 2001 -From: moonman -Date: Mon, 30 May 2016 03:23:17 -0600 -Subject: [PATCH] fix build error on linux >= 4.6.0 - ---- - zc.c | 12 ++++++++++-- - 1 file changed, 10 insertions(+), 2 deletions(-) - -diff --git a/zc.c b/zc.c -index 29b0501..eabfab7 100644 ---- a/zc.c -+++ b/zc.c -@@ -59,8 +59,12 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, - } - - down_read(&mm->mmap_sem); -- ret = get_user_pages(task, mm, -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) -+ ret = get_user_pages((unsigned long)addr, pgcount, write, 0, pg, NULL); -+#else -+ ret = get_user_pages(task, mm, - (unsigned long)addr, pgcount, write, 0, pg, NULL); -+#endif - up_read(&mm->mmap_sem); - if (ret != pgcount) - return -EINVAL; -@@ -119,7 +123,11 @@ void release_user_pages(struct csession *ses) - else - ses->readonly_pages--; - -- page_cache_release(ses->pages[i]); -+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) -+ put_page(ses->pages[i]); -+#else -+ page_cache_release(ses->pages[i]); -+#endif - } - ses->used_pages = 0; - } diff --git a/core/linux-kirkwood-dt/fix_test_compile_time_warnings.patch b/core/linux-kirkwood-dt/fix_test_compile_time_warnings.patch new file mode 100644 index 000000000..4c361a01d --- /dev/null +++ b/core/linux-kirkwood-dt/fix_test_compile_time_warnings.patch @@ -0,0 +1,62 @@ +From bbb72064b02b04c631b69d428af2dddb3342e769 Mon Sep 17 00:00:00 2001 +From: Michael Weiser +Date: Fri, 19 Aug 2016 10:24:40 +0100 +Subject: [PATCH] Fix test compile time warnings +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +A number of tests cause compiler warnings like this: + +hashcrypt_speed.c: In function ‘hash_data’: +hashcrypt_speed.c:101:2: warning: implicit declaration of function ‘alarm’ [-Wimplicit-function-declaration] + alarm(5); + ^~~~~ +hashcrypt_speed.c: In function ‘main’: +hashcrypt_speed.c:203:2: warning: implicit declaration of function ‘close’ [-Wimplicit-function-declaration] + close(fdc); + ^~~~~ + +Fix by including unistd.h. +--- + tests/hashcrypt_speed.c | 1 + + tests/sha_speed.c | 1 + + tests/speed.c | 1 + + 3 files changed, 3 insertions(+) + +diff --git a/tests/hashcrypt_speed.c b/tests/hashcrypt_speed.c +index e60b73d..2b49f2b 100644 +--- a/tests/hashcrypt_speed.c ++++ b/tests/hashcrypt_speed.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff --git a/tests/sha_speed.c b/tests/sha_speed.c +index e1dc54b..5034b58 100644 +--- a/tests/sha_speed.c ++++ b/tests/sha_speed.c +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff --git a/tests/speed.c b/tests/speed.c +index 81c5a65..7031fec 100644 +--- a/tests/speed.c ++++ b/tests/speed.c +@@ -20,6 +20,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/core/linux-kirkwood-dt/pageaccess_fix_for_4.6+.patch b/core/linux-kirkwood-dt/pageaccess_fix_for_4.6+.patch new file mode 100644 index 000000000..f59a3b6ec --- /dev/null +++ b/core/linux-kirkwood-dt/pageaccess_fix_for_4.6+.patch @@ -0,0 +1,52 @@ +From f14b4706b0d04988e7e5bc8c4d2aefef9f029d9d Mon Sep 17 00:00:00 2001 +From: Michael Weiser +Date: Fri, 5 Aug 2016 18:43:55 +0200 +Subject: [PATCH] Adjust to recent user page API changes + +4.6.0 basically renamed get_user_pages() to get_user_pages_remote() and +introduced a new get_user_pages() that always works on the current +task.[1] Distinguish the two APIs based on kernel version we're +compiling for. + +Also, there seems to have been a massive cleansing of +page_cache_release(page) in favour of put_page(page)[2] which was an +alias for put_page(page)[3] since 2.6.0. Before that beginning with +2.4.0 both page_cache_release(page) and put_page(page) have been aliases +for __free_page(page). So using put_page() instead of +page_cache_release(page) will produce identical code for anything after +2.4.0. + +[1] https://lkml.org/lkml/2016/2/10/555 +[2] https://www.spinics.net/lists/linux-fsdevel/msg95923.html +[3] https://www.spinics.net/lists/linux-fsdevel/msg95922.html +--- + zc.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/zc.c b/zc.c +index 29b0501..a97b49f 100644 +--- a/zc.c ++++ b/zc.c +@@ -59,7 +59,12 @@ int __get_userbuf(uint8_t __user *addr, uint32_t len, int write, + } + + down_read(&mm->mmap_sem); +- ret = get_user_pages(task, mm, ++#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) ++ ret = get_user_pages_remote( ++#else ++ ret = get_user_pages( ++#endif ++ task, mm, + (unsigned long)addr, pgcount, write, 0, pg, NULL); + up_read(&mm->mmap_sem); + if (ret != pgcount) +@@ -119,7 +124,7 @@ void release_user_pages(struct csession *ses) + else + ses->readonly_pages--; + +- page_cache_release(ses->pages[i]); ++ put_page(ses->pages[i]); + } + ses->used_pages = 0; + } diff --git a/core/linux-kirkwood-dt/support_skcipher_and_ablkcipher.patch b/core/linux-kirkwood-dt/support_skcipher_and_ablkcipher.patch new file mode 100644 index 000000000..3804c615f --- /dev/null +++ b/core/linux-kirkwood-dt/support_skcipher_and_ablkcipher.patch @@ -0,0 +1,278 @@ +From 129344162e62c31f0697a7c8405e18719588e478 Mon Sep 17 00:00:00 2001 +From: Michael Weiser +Date: Fri, 5 Aug 2016 17:26:27 +0200 +Subject: [PATCH] Support skcipher in addition to ablkcipher API + +The ablkcipher API is being phased out[1]. The unified skcipher API +seems to have made its entry with 4.3.[3, 4] By what can be seen from +migration patches[1.ff.], it's a drop-in replacement. + +Also, deallocators such as crypto_free_skcipher() are NULL-safe now[2]. + +Add a new header cipherapi.h to aid migration from ablkcipher to skcipher and +retain support for old kernels. Make it decide which API to use and provide +appropriate function calls and type definitions. Since the ablkcipher and +skcipher APIs are so similar, those are mainly defines for corresponding +pseudo-functions in namespace cryptodev_ derived directly from their API +counterparts. + +Compiles and works with Debian testing 4.6.4 kernel as well as 4.8-rc2+ +Linus git tree as of today. (Both require a fix for changed page +access API[5].) + +[1] https://www.spinics.net/lists/linux-crypto/msg18133.html +[2] https://www.spinics.net/lists/linux-crypto/msg18154.html, line 120 +[3] https://www.spinics.net/lists/linux-crypto/msg16373.html +[4] https://www.spinics.net/lists/linux-crypto/msg16294.html +[5] https://github.com/cryptodev-linux/cryptodev-linux/pull/14 +--- + cipherapi.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + cryptlib.c | 40 ++++++++++++++++++---------------------- + cryptlib.h | 6 ++++-- + ioctl.c | 4 ++-- + 4 files changed, 84 insertions(+), 26 deletions(-) + create mode 100644 cipherapi.h + +diff --git a/cipherapi.h b/cipherapi.h +new file mode 100644 +index 0000000..07d9923 +--- /dev/null ++++ b/cipherapi.h +@@ -0,0 +1,60 @@ ++#ifndef CIPHERAPI_H ++# define CIPHERAPI_H ++ ++#include ++ ++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)) ++# include ++ ++typedef struct ablkcipher_alg cryptodev_blkcipher_alg_t; ++typedef struct crypto_ablkcipher cryptodev_crypto_blkcipher_t; ++typedef struct ablkcipher_request cryptodev_blkcipher_request_t; ++ ++# define cryptodev_crypto_alloc_blkcipher crypto_alloc_ablkcipher ++# define cryptodev_crypto_blkcipher_alg crypto_ablkcipher_alg ++# define cryptodev_crypto_blkcipher_blocksize crypto_ablkcipher_blocksize ++# define cryptodev_crypto_blkcipher_ivsize crypto_ablkcipher_ivsize ++# define cryptodev_crypto_blkcipher_alignmask crypto_ablkcipher_alignmask ++# define cryptodev_crypto_blkcipher_setkey crypto_ablkcipher_setkey ++ ++static inline void cryptodev_crypto_free_blkcipher(cryptodev_crypto_blkcipher_t *c) { ++ if (c) ++ crypto_free_ablkcipher(c); ++} ++ ++# define cryptodev_blkcipher_request_alloc ablkcipher_request_alloc ++# define cryptodev_blkcipher_request_set_callback ablkcipher_request_set_callback ++ ++static inline void cryptodev_blkcipher_request_free(cryptodev_blkcipher_request_t *r) { ++ if (r) ++ ablkcipher_request_free(r); ++} ++ ++# define cryptodev_blkcipher_request_set_crypt ablkcipher_request_set_crypt ++# define cryptodev_crypto_blkcipher_encrypt crypto_ablkcipher_encrypt ++# define cryptodev_crypto_blkcipher_decrypt crypto_ablkcipher_decrypt ++# define cryptodev_crypto_blkcipher_tfm crypto_ablkcipher_tfm ++#else ++#include ++ ++typedef struct skcipher_alg cryptodev_blkcipher_alg_t; ++typedef struct crypto_skcipher cryptodev_crypto_blkcipher_t; ++typedef struct skcipher_request cryptodev_blkcipher_request_t; ++ ++# define cryptodev_crypto_alloc_blkcipher crypto_alloc_skcipher ++# define cryptodev_crypto_blkcipher_alg crypto_skcipher_alg ++# define cryptodev_crypto_blkcipher_blocksize crypto_skcipher_blocksize ++# define cryptodev_crypto_blkcipher_ivsize crypto_skcipher_ivsize ++# define cryptodev_crypto_blkcipher_alignmask crypto_skcipher_alignmask ++# define cryptodev_crypto_blkcipher_setkey crypto_skcipher_setkey ++# define cryptodev_crypto_free_blkcipher crypto_free_skcipher ++# define cryptodev_blkcipher_request_alloc skcipher_request_alloc ++# define cryptodev_blkcipher_request_set_callback skcipher_request_set_callback ++# define cryptodev_blkcipher_request_free skcipher_request_free ++# define cryptodev_blkcipher_request_set_crypt skcipher_request_set_crypt ++# define cryptodev_crypto_blkcipher_encrypt crypto_skcipher_encrypt ++# define cryptodev_crypto_blkcipher_decrypt crypto_skcipher_decrypt ++# define cryptodev_crypto_blkcipher_tfm crypto_skcipher_tfm ++#endif ++ ++#endif +diff --git a/cryptlib.c b/cryptlib.c +index a7b5c91..5a6e0ba 100644 +--- a/cryptlib.c ++++ b/cryptlib.c +@@ -23,7 +23,6 @@ + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +-#include + #include + #include + #include +@@ -37,6 +36,7 @@ + #include + #include + #include "cryptodev_int.h" ++#include "cipherapi.h" + + + static void cryptodev_complete(struct crypto_async_request *req, int err) +@@ -128,15 +128,15 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, + int ret; + + if (aead == 0) { +- struct ablkcipher_alg *alg; ++ cryptodev_blkcipher_alg_t *alg; + +- out->async.s = crypto_alloc_ablkcipher(alg_name, 0, 0); ++ out->async.s = cryptodev_crypto_alloc_blkcipher(alg_name, 0, 0); + if (unlikely(IS_ERR(out->async.s))) { + ddebug(1, "Failed to load cipher %s", alg_name); + return -EINVAL; + } + +- alg = crypto_ablkcipher_alg(out->async.s); ++ alg = cryptodev_crypto_blkcipher_alg(out->async.s); + if (alg != NULL) { + /* Was correct key length supplied? */ + if (alg->max_keysize > 0 && +@@ -149,11 +149,11 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, + } + } + +- out->blocksize = crypto_ablkcipher_blocksize(out->async.s); +- out->ivsize = crypto_ablkcipher_ivsize(out->async.s); +- out->alignmask = crypto_ablkcipher_alignmask(out->async.s); ++ out->blocksize = cryptodev_crypto_blkcipher_blocksize(out->async.s); ++ out->ivsize = cryptodev_crypto_blkcipher_ivsize(out->async.s); ++ out->alignmask = cryptodev_crypto_blkcipher_alignmask(out->async.s); + +- ret = crypto_ablkcipher_setkey(out->async.s, keyp, keylen); ++ ret = cryptodev_crypto_blkcipher_setkey(out->async.s, keyp, keylen); + } else { + out->async.as = crypto_alloc_aead(alg_name, 0, 0); + if (unlikely(IS_ERR(out->async.as))) { +@@ -180,14 +180,14 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, + init_completion(&out->async.result.completion); + + if (aead == 0) { +- out->async.request = ablkcipher_request_alloc(out->async.s, GFP_KERNEL); ++ out->async.request = cryptodev_blkcipher_request_alloc(out->async.s, GFP_KERNEL); + if (unlikely(!out->async.request)) { + derr(1, "error allocating async crypto request"); + ret = -ENOMEM; + goto error; + } + +- ablkcipher_request_set_callback(out->async.request, ++ cryptodev_blkcipher_request_set_callback(out->async.request, + CRYPTO_TFM_REQ_MAY_BACKLOG, + cryptodev_complete, &out->async.result); + } else { +@@ -207,10 +207,8 @@ int cryptodev_cipher_init(struct cipher_data *out, const char *alg_name, + return 0; + error: + if (aead == 0) { +- if (out->async.request) +- ablkcipher_request_free(out->async.request); +- if (out->async.s) +- crypto_free_ablkcipher(out->async.s); ++ cryptodev_blkcipher_request_free(out->async.request); ++ cryptodev_crypto_free_blkcipher(out->async.s); + } else { + if (out->async.arequest) + aead_request_free(out->async.arequest); +@@ -225,10 +223,8 @@ void cryptodev_cipher_deinit(struct cipher_data *cdata) + { + if (cdata->init) { + if (cdata->aead == 0) { +- if (cdata->async.request) +- ablkcipher_request_free(cdata->async.request); +- if (cdata->async.s) +- crypto_free_ablkcipher(cdata->async.s); ++ cryptodev_blkcipher_request_free(cdata->async.request); ++ cryptodev_crypto_free_blkcipher(cdata->async.s); + } else { + if (cdata->async.arequest) + aead_request_free(cdata->async.arequest); +@@ -276,10 +272,10 @@ ssize_t cryptodev_cipher_encrypt(struct cipher_data *cdata, + reinit_completion(&cdata->async.result.completion); + + if (cdata->aead == 0) { +- ablkcipher_request_set_crypt(cdata->async.request, ++ cryptodev_blkcipher_request_set_crypt(cdata->async.request, + (struct scatterlist *)src, dst, + len, cdata->async.iv); +- ret = crypto_ablkcipher_encrypt(cdata->async.request); ++ ret = cryptodev_crypto_blkcipher_encrypt(cdata->async.request); + } else { + aead_request_set_crypt(cdata->async.arequest, + (struct scatterlist *)src, dst, +@@ -298,10 +294,10 @@ ssize_t cryptodev_cipher_decrypt(struct cipher_data *cdata, + + reinit_completion(&cdata->async.result.completion); + if (cdata->aead == 0) { +- ablkcipher_request_set_crypt(cdata->async.request, ++ cryptodev_blkcipher_request_set_crypt(cdata->async.request, + (struct scatterlist *)src, dst, + len, cdata->async.iv); +- ret = crypto_ablkcipher_decrypt(cdata->async.request); ++ ret = cryptodev_crypto_blkcipher_decrypt(cdata->async.request); + } else { + aead_request_set_crypt(cdata->async.arequest, + (struct scatterlist *)src, dst, +diff --git a/cryptlib.h b/cryptlib.h +index 6a6e18f..8e8aa71 100644 +--- a/cryptlib.h ++++ b/cryptlib.h +@@ -8,6 +8,8 @@ struct cryptodev_result { + int err; + }; + ++#include "cipherapi.h" ++ + struct cipher_data { + int init; /* 0 uninitialized */ + int blocksize; +@@ -17,8 +19,8 @@ struct cipher_data { + int alignmask; + struct { + /* block ciphers */ +- struct crypto_ablkcipher *s; +- struct ablkcipher_request *request; ++ cryptodev_crypto_blkcipher_t *s; ++ cryptodev_blkcipher_request_t *request; + + /* AEAD ciphers */ + struct crypto_aead *as; +diff --git a/ioctl.c b/ioctl.c +index 8649e95..0385203 100644 +--- a/ioctl.c ++++ b/ioctl.c +@@ -34,7 +34,6 @@ + */ + + #include +-#include + #include + #include + #include +@@ -53,6 +52,7 @@ + #include "cryptodev_int.h" + #include "zc.h" + #include "version.h" ++#include "cipherapi.h" + + MODULE_AUTHOR("Nikos Mavrogiannopoulos "); + MODULE_DESCRIPTION("CryptoDev driver"); +@@ -772,7 +772,7 @@ static int get_session_info(struct fcrypt *fcr, struct session_info_op *siop) + + if (ses_ptr->cdata.init) { + if (ses_ptr->cdata.aead == 0) +- tfm = crypto_ablkcipher_tfm(ses_ptr->cdata.async.s); ++ tfm = cryptodev_crypto_blkcipher_tfm(ses_ptr->cdata.async.s); + else + tfm = crypto_aead_tfm(ses_ptr->cdata.async.as); + tfm_info_to_alg_info(&siop->cipher_info, tfm);