summaryrefslogtreecommitdiffstats
path: root/crypto/tcrypt.c
diff options
context:
space:
mode:
authorHoria Geant? <horia.geanta@freescale.com>2015-08-27 11:38:36 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-09-21 10:00:36 -0400
commitf074f7b103a915edb1edf833f96a902adeb374cf (patch)
treeeed2c4e554ac99b35c964c000271af99d6fd855c /crypto/tcrypt.c
parent1f93e4a96c9109378204c147b3eec0d0e8100fde (diff)
crypto: tcrypt - avoid mapping from module image addresses
The output buffer in test_ahash_speed will point to an address located within the tcrypt module image. This causes problems when trying to DMA map the buffer. For e.g. on ARM-based LS1021A, a page fault occurs within the DMA API when trying to access the struct page returned by virt_to_page(output): insmod tcrypt.ko mode=403 testing speed of async sha1 (sha1-caam) test 0 ( 16 byte blocks, 16 bytes per update, 1 updates): Unable to handle kernel paging request at virtual address f07e9080 pgd = e58d0e00 [f07e9080] *pgd=80000080007003, *pmd=00000000 Internal error: Oops: 206 [#1] SMP THUMB2 Modules linked in: tcrypt(+) CPU: 1 PID: 1119 Comm: insmod Not tainted 4.2.0-rc1-256134-gbf433416e675 #1 Hardware name: Freescale LS1021A task: ea063900 ti: e5a34000 task.ti: e5a34000 PC is at dma_cache_maint_page+0x38/0xd0 LR is at __dma_page_cpu_to_dev+0x15/0x64 pc : [<800155a0>] lr : [<8001564d>] psr: 000f0033 sp : e5a35ca0 ip : 8063df00 fp : f07e9080 r10: 00000cd0 r9 : 8063df00 r8 : 805a2f04 r7 : 0017f804 r6 : 00000002 r5 : ee7f9000 r4 : 00000014 r3 : 80612d40 r2 : 01ff0080 r1 : 00000380 r0 : ee7f9000 Flags: nzcv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment user Control: 70c5387d Table: e58d0e00 DAC: 9b7ede70 Process insmod (pid: 1119, stack limit = 0xe5a34210) Stack: (0xe5a35ca0 to 0xe5a36000) [...] [<800155a0>] (dma_cache_maint_page) from [<8001564d>] (__dma_page_cpu_to_dev+0x15/0x64) [<8001564d>] (__dma_page_cpu_to_dev) from [<800156eb>] (arm_dma_map_page+0x1f/0x44) [<800156eb>] (arm_dma_map_page) from [<802935e3>] (ahash_digest+0x35f/0x510) [<802935e3>] (ahash_digest) from [<7f800d03>] (test_ahash_speed.constprop.6+0x24a/0x4e4 [tcrypt]) [<7f800d03>] (test_ahash_speed.constprop.6 [tcrypt]) from [<7f802fd5>] (do_test+0x1898/0x2058 [tcrypt]) [<7f802fd5>] (do_test [tcrypt]) from [<7f80802f>] (tcrypt_mod_init+0x2e/0x63 [tcrypt]) [<7f80802f>] (tcrypt_mod_init [tcrypt]) from [<80009517>] (do_one_initcall+0xb3/0x134) [<80009517>] (do_one_initcall) from [<80351ec7>] (do_init_module+0x3b/0x13c) [<80351ec7>] (do_init_module) from [<8005cc3f>] (load_module+0x97b/0x9dc) [<8005cc3f>] (load_module) from [<8005cd8d>] (SyS_finit_module+0x35/0x3e) [<8005cd8d>] (SyS_finit_module) from [<8000d101>] (ret_fast_syscall+0x1/0x4c) Code: 1aba 0152 eb00 0b02 (5882) 0f92 addr2line -f -i -e vmlinux 800155a0 page_zonenum include/linux/mm.h:728 page_zone include/linux/mm.h:881 dma_cache_maint_page arch/arm/mm/dma-mapping.c:822 Signed-off-by: Horia Geant? <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/tcrypt.c')
-rw-r--r--crypto/tcrypt.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 2b00b617daab..46a4a757d478 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -48,6 +48,8 @@
48#define ENCRYPT 1 48#define ENCRYPT 1
49#define DECRYPT 0 49#define DECRYPT 0
50 50
51#define MAX_DIGEST_SIZE 64
52
51/* 53/*
52 * return a string with the driver name 54 * return a string with the driver name
53 */ 55 */
@@ -950,7 +952,7 @@ static void test_ahash_speed(const char *algo, unsigned int secs,
950 struct tcrypt_result tresult; 952 struct tcrypt_result tresult;
951 struct ahash_request *req; 953 struct ahash_request *req;
952 struct crypto_ahash *tfm; 954 struct crypto_ahash *tfm;
953 static char output[1024]; 955 char *output;
954 int i, ret; 956 int i, ret;
955 957
956 tfm = crypto_alloc_ahash(algo, 0, 0); 958 tfm = crypto_alloc_ahash(algo, 0, 0);
@@ -963,9 +965,9 @@ static void test_ahash_speed(const char *algo, unsigned int secs,
963 printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo, 965 printk(KERN_INFO "\ntesting speed of async %s (%s)\n", algo,
964 get_driver_name(crypto_ahash, tfm)); 966 get_driver_name(crypto_ahash, tfm));
965 967
966 if (crypto_ahash_digestsize(tfm) > sizeof(output)) { 968 if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
967 pr_err("digestsize(%u) > outputbuffer(%zu)\n", 969 pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
968 crypto_ahash_digestsize(tfm), sizeof(output)); 970 MAX_DIGEST_SIZE);
969 goto out; 971 goto out;
970 } 972 }
971 973
@@ -980,6 +982,10 @@ static void test_ahash_speed(const char *algo, unsigned int secs,
980 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 982 ahash_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG,
981 tcrypt_complete, &tresult); 983 tcrypt_complete, &tresult);
982 984
985 output = kmalloc(MAX_DIGEST_SIZE, GFP_KERNEL);
986 if (!output)
987 goto out_nomem;
988
983 for (i = 0; speed[i].blen != 0; i++) { 989 for (i = 0; speed[i].blen != 0; i++) {
984 if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) { 990 if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
985 pr_err("template (%u) too big for tvmem (%lu)\n", 991 pr_err("template (%u) too big for tvmem (%lu)\n",
@@ -1006,6 +1012,9 @@ static void test_ahash_speed(const char *algo, unsigned int secs,
1006 } 1012 }
1007 } 1013 }
1008 1014
1015 kfree(output);
1016
1017out_nomem:
1009 ahash_request_free(req); 1018 ahash_request_free(req);
1010 1019
1011out: 1020out: