summaryrefslogtreecommitdiff
path: root/drivers/crypto/caam
AgeCommit message (Collapse)Author
2015-05-22crypto: caam/qi - tls10 support for 32bit platformsTudor Ambarus
Tested with tcrypt on p1023rdb platform. Change-Id: Ic19a8d2ed5ce3603d2d9f893736b68eea03d480b Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/36220 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-05-21crypto: caampkc - workaround for erratum A-006899Tudor Ambarus
The problem will occur only in T1040R1. A workaround has been verified; set a Scatter Gather (SG) flag on the Q or G Pointers on KPG, which will give the PKHA unload time to complete. It's sufficient to have the SG flag set for only one of these. Change-Id: I5a403576c6e995110227872c84de7e74da0144c5 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/36617 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-05-19crypto: caam - fix TLS processing for SEC in LE modeAlex Porosanu
In order to process TLS data that is received in network byte order, a swap is needed for a SEC block working in little endian mode. This is done by using the MOVEB command. Change-Id: I8290ad7348d9e66169c05eff8bda71e587beb0a9 Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/36369 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Tudor-Dan Ambarus <tudor.ambarus@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-05-19crypto: caam - add support for MOVEB commandAlex Porosanu
CHAs of SEC work natively in BE mode. When moving data to the alignment blocks, swapping is needed for LE platforms. This is done by means of the MOVEB command (introduced in ERA 7). This patch adds support to DCL for this command. Change-Id: Ie74f2d8a1cf101acd5a23686ff8eb835d1a1f047 Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/36365 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Tudor-Dan Ambarus <tudor.ambarus@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-05-19crypto: caam - tls10 support for 32bit ppc platformsTudor Ambarus
Tested with tcrypt on bsc9132qds platform. Change-Id: Ia8a58b786779e00b267ad3cd2fa05b30d5e17bfb Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/36219 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-05-19crypto: caam - fix warning in APPEND_MATH_IMM_u64Tudor Ambarus
An implicit truncation is done when using a variable of 64 bits in MATH command: warning: large integer implicitly truncated to unsigned type [-Woverflow] Silence the compiler by feeding it with an explicit truncated value. Change-Id: I95e3f397f62f9b850c0c7f26e7079b9d9688b87e Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/36218 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-04-30crypto: caam - don't emit ICV check failures to dmesgKim Phillips
ICV check failures are part of normal operation; leave user notification up to the higher levels, as is done in s/w algorithm implementations. Signed-off-by: Kim Phillips <kim.phillips@freescale.com> Tested-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 3f80be023900790d029a63e27440f1e33c048b73) Change-Id: I6b181dd09e915cf639691cb3d696ddc22ac5f195 Reviewed-on: http://git.am.freescale.net:8181/31647 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-04-16caam: remove dependencies on QI when it is disabledCristian Stoica
The dependency on CAAM-QI was incorrectly set on FSL_QMAN and resulted in an always-enabled CAAM-QI on DPAA platforms. This patch fixes the dependency and allows CAAM-QI interface to be freely disabled on DPAA platforms. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: Iaf752ae8774a7b03383244a6c9fbbadd9959f3d4 Reviewed-on: http://git.am.freescale.net:8181/34732 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-04-01crypto: caam - change QI memory allocation on hotpathAlex Porosanu
This patch changes the allocation of memory on the hotpath, by replacing the malloc allocation with a kmem_cache backed allocation. Change-Id: I55a21bb7cbd022f6b86bd784988491b551a0f81e Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/31371 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-04-01crypto: caam - cleanup caamalg_qiAlex Porosanu
This patch synchronizez the QI shared descriptors creation with the corresponding JR ones, as well as cleaning up the unused parameters of the *edesc_alloc() functions. While here, also fix a formatting error in cra_init(). Change-Id: Ic5bae734e4a6e6dcb329f7e9530422b9f8cc0377 Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/31370 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-03-31crypto: caam - add useful prints for debuggingAlex Porosanu
This patch adds some output from the CAAM QI driver so the engineer can gain some insight on some of the internals of the driver. Normally, this information should reside in debug fs, but for now it's guarded by the DEBUG define. Change-Id: Ic6b7e570bc8fcedd758fb4163e15c94544e47130 Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/31369 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-03-31crypto: caam - remove list lookup of requestsAlex Porosanu
This patch removes the per-packet lookup of a completed request by adding an opaque after the SG entries in the FD. While here, also the software congestion control is removed and replaced with a proper CGR with a sensible threshold. While here, some very likely branches are decorated. Change-Id: I48f2c71b6ac0d537843a44f8c0627c9b70c77592 Signed-off-by: Alex Porosanu <alexandru.porosanu@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/31368 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Alexandru Marginean <Alexandru.Marginean@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2015-03-20fsl: Use ccflags-y instead of deprecated EXTRA_CFLAGSWang Dongsheng
This allows users to pass in additional compiler flags through the environment variable EXTRA_CFLAGS, e.g. make EXTRA_CFLAGS=-Wno-error Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> Change-Id: I36513506ee1671c31bb076e9b73c2e8e2442cf4f Reviewed-on: http://git.am.freescale.net:8181/33146 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Honghua Yin <Hong-Hua.Yin@freescale.com>
2014-12-11crypto: caam - fix contiguous case for tls with gcmTudor Ambarus
GCM's expected input sequence is: IV, AAD, text. Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Change-Id: I35d03818ec559e607182470f0c78097fa6c63f78 Reviewed-on: http://git.am.freescale.net:8181/25434 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caam: fix encryption with null assoc dataCristian Stoica
This is a fix for caam gcm offloading failure through cryptodev. If assoc data is null, the driver crashes: Modules linked in: cryptodev CPU: 3 PID: 1930 Comm: openssl Not tainted 3.12.19-rt30-QorIQ-SDK-V1.7+gcebf692 #4 task: e9061070 ti: ebe72000 task.ti: ebe72000 NIP: c04ea360 LR: c04eed54 CTR: c04ef530 REGS: ebe73ba0 TRAP: 0300 Not tainted (3.12.19-rt30-QorIQ-SDK-V1.7+gcebf692) MSR: 00029002 <CE,EE,ME> CR: 44242484 XER: 00000000 DEAR: 00000000, ESR: 00000000 GPR00: c04eed54 ebe73c50 e9061070 eb41ea10 00000000 00000001 00000001 00000000 GPR08: 00000020 00000000 00000000 00000002 44242482 10089738 10081750 100633f8 GPR16: 100813fc 00000000 000000d1 ebe73cd8 0000000c bfc8e9c4 bfc8de54 eb41ea10 GPR24: eb896a00 c087dbe0 00000001 00000000 eb41ea10 00000001 00000000 00000000 NIP [c04ea360] dma_map_sg_chained+0x50/0x180 LR [c04eed54] aead_edesc_alloc.constprop.19+0x164/0x940 Call Trace: [ebe73c50] [84244482] 0x84244482 (unreliable) [ebe73c80] [c04eed54] aead_edesc_alloc.constprop.19+0x164/0x940 [ebe73cd0] [c04ef55c] aead_encrypt+0x2c/0xd0 [ebe73d00] [f9523c2c] cryptodev_cipher_encrypt+0xcc/0x140 [cryptodev] [ebe73d10] [f952561c] crypto_auth_run+0x2ec/0xbd0 [cryptodev] [ebe73d80] [f95227a0] cryptodev_ioctl+0x500/0xa10 [cryptodev] [ebe73eb0] [c0107a40] do_vfs_ioctl+0x4d0/0x780 [ebe73f10] [c0107d30] SyS_ioctl+0x40/0x80 [ebe73f40] [c000fbcc] ret_from_syscall+0x0/0x3c --- Exception: c01 at 0xfcc308c LR = 0xfd5f064 Instruction dump: 91810010 7cbd2b78 7cda3378 40de0098 2f830000 41de0138 832300b0 2f9d0000 7f7edb78 3be00000 40dd002c 60000000 <807e0000> 3bff0001 5463003a 4bbe2855 ---[ end trace 08c4f2b427249be6 ]--- Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I6554d83dbc9acb089f2dce5ff4f1044642262b03 Reviewed-on: http://git.am.freescale.net:8181/25433 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caam - add support for rfc4543(gcm(aes))Tudor Ambarus
Add AES-GMAC as an IPSec ESP mechanism to provide data origin authentication, but not confidentiality. This method is referred as ENCR_NULL_AUTH_AES_GMAC. Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 5d0429a30f06845af78a696de59e3e8d21252846) Specify the lowest (compatible) SEC Era on which the descriptors can run. Change-Id: If17a51a41c06dedf5b3589311d2677d522b4a209 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/23481 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam - fix output sequence contiguity checkTudor Ambarus
This patch fixes the assumption that output sequence is not contiguous when input sequence is not contiguous and in-place encryption is done. Output sequence does not need to be contiguous with associated data. Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 19167bfd8ae72ceeb41930343227bf8f5fb19a66) Change-Id: I55797558a79c8113c7e299198f94caea6a0d10b5 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/23480 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam - add support for rfc4106(gcm(aes))Tudor Ambarus
Add Advanced Encryption Standard (AES) in Galois/Counter Mode (GCM) as an IPsec Encapsulating Security Payload (ESP) mechanism to provide confidentiality and data origin authentication. Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit bac68f2c9a43e60a70e27c0c75aaca7128b6271d) Specify the lowest (compatible) SEC Era on which the descriptors can run. Change-Id: I9054cb203f3f3acad5853ba973bb549ff1d2e10c Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/23479 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam - add support for gcm(aes)Tudor Ambarus
Add support for AES working in Galois Counter Mode. There is a limitation related to IV size, similar to the one present in SW implementation (crypto/gcm.c): The only IV size allowed is 12 bytes. It will be padded by HW to the right with 0x0000_0001 (up to 16 bytes - AES block size), according to the GCM specification. Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 3ef8d945d0dafd272e77c01099bc4975c5297a5a) Conflicts: drivers/crypto/caam/caamalg.c Specify the lowest (compatible) SEC Era on which the descriptors can run. Change-Id: Ic6e0695192a4b9cfcc388e0ce31ec50741f5e339 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/23478 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11Revert "crypto: caam - add support for gcm(aes)"Tudor Ambarus
This reverts commit 8901a6c015c66cecd70b301f58bab9fc68a11d69. The upstream version of gcm support contains some fixes that current version does not include. The removal of gcm support from caam driver will be followed by the cherry-pick of upstream's gcm patch. Change-Id: Ic8de49a977beae9cd15eb860e9f6e18695886d98 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/23477 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11Revert "crypto: caam - fix key typo in gcm descriptors"Tudor Ambarus
This reverts commit 47a0ea3dc8b50056f8dd39afb438d362d5f5ea45. The upstream version of gcm support contains some fixes that current version does not include. The removal of gcm support from caam driver will be followed by the cherry-pick of upstream's gcm patch. Change-Id: I1fcd770e7f15326a18a2fb18bc8efb40abbe5246 Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Reviewed-on: http://git.am.freescale.net:8181/23476 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caampkc: remove inclusion of unused headerCristian Stoica
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I7983c1cdc0d19fd738b251de3c0374e9e67cf617 Reviewed-on: http://git.am.freescale.net:8181/19800 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam: remove dead codeCristian Stoica
- assoc_nents and src_nents are never zero when all_contig is false - iv_contig is zero on the else branch Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: Iccd420733cac736e92c1f9b0cb8fb83fd39b40e4 Reviewed-on: http://git.am.freescale.net:8181/19799 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam: remove unused local variablesCristian Stoica
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I7cd10343879e4b51c50b2c4058aad76374831e91 Reviewed-on: http://git.am.freescale.net:8181/19797 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11Merge remote-tracking branch 'b18196/fix_error_reporting'Rich Schmitt
2014-12-11crypto: caam - fix error reportingCristian Stoica
The error code returned by hardware is four bits wide with an expected zero MSB. A hardware error condition where the error code can get between 0x8 and 0xf will trigger an out of bound array access on the error message table. This patch fixes the invalid array access following such an error and reports the condition. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 49783d0f54219e1c68eac738fdd3244b7a6cbda7)
2014-12-11crypto: caam - Fix the 'quoted string split across lines'Marek Vasut
Fix the checkpatch warnings that the strings were split across multiple lines. Checkpatch now complains about lines over 80, but this is better, since we can actually grep the source code for these strings now. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit da37503d37bb6ae72cca0b4d729c153f04b9f0cc)
2014-12-11crypto: caam - Sweep the remnantsMarek Vasut
Clean up the remnants from the rework. Constify function arguments. Note that checkpatch again complains about this space before newline, but this is the original code behavior, so I'm keeping it. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit e397ee0f2242a5f316906e1ff05f8669791b4e2c)
2014-12-11crypto: caam - Kill SPRINTFCAT() with fireMarek Vasut
This macro is just like an encyclopedia of string handling done wrong. This must die. This is so wrong on so many levels. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit e22cdcfa13d9799ea46245946ae09b4a328ff27d)
2014-12-11crypto: caam - Clean up report_deco_status()Marek Vasut
Clean this function up and rework it into sensible shape. This function now contains one single dev_err() instead of the previous insanity full of memory allocation, chaotic string handling and use of SPRINTFCAT(). Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 4f0fa52a5d89d763423cb9b428e988ea824fd95a)
2014-12-11crypto: caam - Clean up report_ccb_status()Marek Vasut
Clean this function up and rework it into sensible shape. This function now contains one single dev_err() instead of the previous insanity full of memory allocation, possible stack overwriting, chaotic string handling and use of SPRINTFCAT(). Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 1e16322da45b747c753162e421b7a1b25259377a)
2014-12-11crypto: caam - Dissolve report_jump_idx()Marek Vasut
Just dissolve this function so it's not in the way of applying further white magic cleanup down the line. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 526243cc872398ed8139a52ee0bf7715a3abcf31)
2014-12-11crypto: caam - Kill the easy targetsMarek Vasut
Fix the functions which can be obviously done right with a simple dev_err() now. While at it, further press the on-stack allocation of buffer for sprintf() voodoo down into the abominated functions. This patch cleans up most of the functions and leaves just two remaining functions, report_ccb_status() and report_deco_status() ugly and unhappy. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit e75880dd9afb60ff59efe079ac50ccc16daffe54)
2014-12-11crypto: caam - Pass error type into the functionsMarek Vasut
Pass the error type string into the functions, so they can handle the printing of the string. This is now still using the very unsafe sprintf(), but we will fix that. While at this, pass the device pointer too, so we can dev_err() functions readily when we start fixing this proper. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 8a4758268292eb036a63f49746fbfe3fcdc0c51d)
2014-12-11crypto: caam - Implement fast-path for error codes with no handlerMarek Vasut
Implement fast-path error code printout for errors with no associated handler function. This reduces calls to this kmalloc() nonsense in SPRINTFCAT() already. Note that the format of output is compatible with the old code, even if -- exposed like this -- it looks a bit weird. Checkpatch complains on this one as well. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 867e1ee395d845f49ae280c3d8f5271b214fa7e4)
2014-12-11crypto: caam - Pull all the error codes outMarek Vasut
Pull the error code <-> error string mapping tables out of the function so the code becomes readable. This lets me see the real flesh of the functions, without all that flab clouding the view. Note: There is a checkpatch issue with quoted strings across multiple lines. I will fix that in a subsequent patch to keep the changes small and separate. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 9724d7adbb34b067b844b97599c1a5905229aa2b)
2014-12-11crypto: caam - Contain caam_jr_strstatus() uglinessMarek Vasut
The tentacles of this function were firmly attached to various places in the CAAM code. Just cut them, or this cthulhu function will sprout them anew. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit fa9659cd4d3f40cead6263986cc235f3e67ab872) Squash additional fixes to avoid broken builds in Freescale SDK crypto: caam: fix calls to caam_jr_strstatus This is a clean-up patch after changes made to caam_jr_strstatus API starting with fa9659cd4d3f40cead6263986cc235f3e67ab872. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
2014-12-11crypto: caam: change function definition to return voidCristian Stoica
The function definition is changed to match dma_unmap_sg which is a void function Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I6142f5a56127db1fa103a497489e88d04bbc28e1 Reviewed-on: http://git.am.freescale.net:8181/19809 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam: remove void pointer arithmeticCristian Stoica
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: Iff7b2f0929e6274fe9ffc54b4dddd0ef640314d7 Reviewed-on: http://git.am.freescale.net:8181/19798 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam: remove code duplicationCristian Stoica
Duplicated code has already been extracted into an independent function. Replace the code with a function call Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: If390831e03de17c0397d3ae11516fae4d1b39164 Reviewed-on: http://git.am.freescale.net:8181/24348 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11Revert "crypto: caam: remove code duplication"Richard Schmitt
This reverts commit d2dfa8c0cdf585008cdf6a15c337c30e264f045e. Change-Id: Ib5504c1600f99debc2654086781d9bf904e32f63 Reviewed-on: http://git.am.freescale.net:8181/24187 Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com> Tested-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caam: remove code duplicationCristian Stoica
Duplicated code has already been extracted into an independent function. Replace the code with a function call Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: Ieb70040fe4c13d27b7a5ab4450c7550b9b74f3b3 Reviewed-on: http://git.am.freescale.net:8181/19796 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Richard Schmitt <richard.schmitt@freescale.com>
2014-12-11crypto: caamalg_qi: remove redundant checks on fast pathCristian Stoica
The function is called with arguments known at compile time. Remove runtime checks for out of bound values. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I2fe2e3d4bd3c63b81f99065b0db159a009f217e6 Reviewed-on: http://git.am.freescale.net:8181/19806 Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caamhash: fix jr alloc leak on error pathCristian Stoica
Memory allocated for ctx->jrdev is freed in all error paths except when ahash_set_sh_desc(ahash) fails. Add a check for this case and free memory as appropriate. Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I1c4e45a8cfdc6d24d768e90a148bb398b3d09f52 Reviewed-on: http://git.am.freescale.net:8181/19803 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caam - fix memleak in caam_jr moduleCristian Stoica
This patch fixes a memory leak that appears when caam_jr module is unloaded. Cc: <stable@vger.kernel.org> # 3.13+ Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 0378c9a855bfa395f595fbfb049707093e270f69) Change-Id: I65f5e6d3611a007506d9c80c344e9467f6b20c84 Reviewed-on: http://git.am.freescale.net:8181/19794 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caam - fix mem leak in ahash_setkeyHoria Geanta
In case hash key is bigger than algorithm block size, it is hashed. In this case, memory is allocated to keep this hash in hashed_key. hashed_key has to be freed on the key_dma dma mapping error path. Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Reviewed-by: Marek Vasut <marex@denx.de> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 3d67be2761dc4b5b792037f296f3394a29581efc) Change-Id: Ied6b875209839897e144e93f09b77431136c9703 Reviewed-on: http://git.am.freescale.net:8181/19765 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caam - remove duplicated sg copy functionsCristian Stoica
Replace equivalent (and partially incorrect) scatter-gather functions with ones from crypto-API. The replacement is motivated by page-faults in sg_copy_part triggered by successive calls to crypto_hash_update. The following fault appears after calling crypto_ahash_update twice, first with 13 and then with 285 bytes: Unable to handle kernel paging request for data at address 0x00000008 Faulting instruction address: 0xf9bf9a8c Oops: Kernel access of bad area, sig: 11 [#1] SMP NR_CPUS=8 CoreNet Generic Modules linked in: tcrypt(+) caamhash caam_jr caam tls CPU: 6 PID: 1497 Comm: cryptomgr_test Not tainted 3.12.19-rt30-QorIQ-SDK-V1.6+g9fda9f2 #75 task: e9308530 ti: e700e000 task.ti: e700e000 NIP: f9bf9a8c LR: f9bfcf28 CTR: c0019ea0 REGS: e700fb80 TRAP: 0300 Not tainted (3.12.19-rt30-QorIQ-SDK-V1.6+g9fda9f2) MSR: 00029002 <CE,EE,ME> CR: 44f92024 XER: 20000000 DEAR: 00000008, ESR: 00000000 GPR00: f9bfcf28 e700fc30 e9308530 e70b1e55 00000000 ffffffdd e70b1e54 0bebf888 GPR08: 902c7ef5 c0e771e2 00000002 00000888 c0019ea0 00000000 00000000 c07a4154 GPR16: c08d0000 e91a8f9c 00000001 e98fb400 00000100 e9c83028 e70b1e08 e70b1d48 GPR24: e992ce10 e70b1dc8 f9bfe4f4 e70b1e55 ffffffdd e70b1ce0 00000000 00000000 NIP [f9bf9a8c] sg_copy+0x1c/0x100 [caamhash] LR [f9bfcf28] ahash_update_no_ctx+0x628/0x660 [caamhash] Call Trace: [e700fc30] [f9bf9c50] sg_copy_part+0xe0/0x160 [caamhash] (unreliable) [e700fc50] [f9bfcf28] ahash_update_no_ctx+0x628/0x660 [caamhash] [e700fcb0] [f954e19c] crypto_tls_genicv+0x13c/0x300 [tls] [e700fd10] [f954e65c] crypto_tls_encrypt+0x5c/0x260 [tls] [e700fd40] [c02250ec] __test_aead.constprop.9+0x2bc/0xb70 [e700fe40] [c02259f0] alg_test_aead+0x50/0xc0 [e700fe60] [c02241e4] alg_test+0x114/0x2e0 [e700fee0] [c022276c] cryptomgr_test+0x4c/0x60 [e700fef0] [c004f658] kthread+0x98/0xa0 [e700ff40] [c000fd04] ret_from_kernel_thread+0x5c/0x64 Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> (cherry picked from commit 307fd543f3d23f8f56850eca1b27b1be2fe71017) Change-Id: I6d5822563f2437231def72c8a6ac37932a5139b8 Reviewed-on: http://git.am.freescale.net:8181/19763 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Horia Ioan Geanta Neag <horia.geanta@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caamctrl: fix array out of bound accessCristian Stoica
desc_len(desc) returns a result masked by a seven bits mask representing a descriptor length. The maximum length is 64 u32 words but masking allows for larger but incorrect values. This fix adds a bound check to the index of deco.descbuf array (which is smaller than the maximum of 64 words), to avoid invalid memory accesses. (based on commit 05dbe2ed7da7d67cfd8915382c2559db684a0a29) Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Matthew Weigel <matthew.weigel@freescale.com> Change-Id: I05dbe2ed7da7d67cfd8915382c2559db684a0a29 Conflicts: drivers/crypto/caam/ctrl.c Reviewed-on: http://git.am.freescale.net:8181/19805 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caamctrl refactoring: remove code duplicationCristian Stoica
Both error and normal paths call clrbits32 before returning. Put this call in a single place to avoid code duplication Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> (cherry picked from commit c75e03a2d47583e39f46c2925abd0ca79a693086) Signed-off-by: Matthew Weigel <Matthew.Weigel@freescale.com> Conflicts: drivers/crypto/caam/ctrl.c Change-Id: I3c2ec1c34215b5d2a1ee036809beaeabf724ac48 Reviewed-on: http://git.am.freescale.net:8181/24179 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>
2014-12-11crypto: caam: fix sg_count searching out of boundCristian Stoica
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Change-Id: I0acac8a5fb22a0095ec1c347e4a100a277ac788f Reviewed-on: http://git.am.freescale.net:8181/19810 Tested-by: Review Code-CDREVIEW <CDREVIEW@freescale.com> Reviewed-by: Mircea Pop <mircea.pop@freescale.com> Reviewed-by: Matthew Weigel <Matthew.Weigel@freescale.com>