summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
Commit message (Collapse)AuthorAgeFilesLines
* crypto: caam - Always do rng selftestSascha Hauer2019-08-064-26/+22
| | | | | | | | | | | | | | | | | The caam rng selftest is known to be broken in several i.MX incarnations. To be on the safe side just unconditionally execute it rather than trying to guess from HAB failure events if this is necessary. We can only do the selftest once per boot though, doing it a second time yields an error: rng_self_test: Job Error: 2101000.jr0@1000.of: 20001953: CCB: desc idx 25: RNG: Instantiate so only do the test when rng is not yet initialized as tested with the RDSTA_IFx status bits. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam: add blobgen driverSteffen Trumtrar2019-04-124-0/+240
| | | | | | | | | The blobgen driver allows generating and reading of red blobs on the i.MX6 CAAM crypto core. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: add new imx-scc driverSteffen Trumtrar2019-04-127-0/+694
| | | | | | | | | | | | | | | | | | | | | The Security Controller (SCC) is found on (at least) i.MX25 SoCs. It is not a crypto engine in the usual sense. The only supported algorithm in hardware is 3DES and the key is not configurable, but is fused in the hardware. The SCC can be handed some block of data in the red memory space and it will return the encrypted data in the black memory space and vice versa. The API for this driver are the functions - mxc_scc_cbc_des_encrypt - mxc_scc_cbc_des_decrypt Along with this driver a blobgen implementation is provided. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto/caam: Add missing includeSascha Hauer2019-04-121-0/+1
| | | | | | | rng_self_test.c doesn't include the header file providing the prototypes for the functions it implements. Add the missing include. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab/caam: Fix compilation of caam driver when hab is disabledSascha Hauer2019-04-111-2/+1
| | | | | | | | | The caam driver needs the variable habv4_need_rng_software_self_test, but this is only declared when HABV4 is enabled. Instead of exporting a variable rather provide a function to test if a software selftest of the random number generator is needed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: surround Kconfig file paths with double quotesMasahiro Yamada2019-03-211-1/+1
| | | | | | | | | Based on Linux commit 8636a1f9677db4f883f29a072f401303acfc2edd This will be needed when you sync Kconfig with Linux 5.0 or later. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove blank textsMasahiro Yamada2019-01-031-1/+0
| | | | | | | | | | | These should be fixed before the Kconfig resync because Linux 4.16 or later warns it. Refer to Linux commit 1b9eda2e4892 ("kconfig: Warn if help text is blank"). Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: caam: add RNG software self-testRoland Hieber2018-12-056-0/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is based on a vendor patch in U-Boot, taken from https://portland.source.codeaurora.org/patches/external/imxsupport/uboot-imx/imx_v2016.03_4.1.15_2.0.0_ga/HAB-238-Run-RNG-self-test-for-impacted-i.MX-chips.zip | HAB-238 Run RNG self test for impacted i.MX chips | | Patch is only applicable to imx_v2016.03_4.1.15_2.0.0_ga branch of u-boot. | Please adapt the patch for your respective release version. | | Background: | Few i.MX chips which have HAB 4.2.3 or beyond, have oberserved following | warning message generated by HAB due to incorrect implementation of drng | self test in boot ROM. | | Event |0xdb|0x0024|0x42| SRCE Field: 69 30 e1 1d | | | | | STS = HAB_WARNING (0x69) | | | | | RSN = HAB_ENG_FAIL (0x30) | | | | | CTX = HAB_CTX_ENTRY (0xE1) | | | | | ENG = HAB_ENG_CAAM (0x1D) | | | | | Evt Data (hex): | | | | | 00 08 00 02 40 00 36 06 55 55 00 03 00 00 00 00 | | | | | 00 00 00 00 00 00 00 00 00 00 00 01 | | It is recommended to run this rng self test before any RNG related crypto | implementations are done. | [...] | | Signed-off-by: Utkarsh Gupta <utkarsh.gupta@nxp.com> Currently known impacted chips, as determined by NXP, include: * i.MX6DQ+ silicon revision 1.1 * i.MX6DQ silicon revision 1.6 * i.MX6DLS silicon revision 1.4 * i.MX6SX silicon revision 1.4 * i.MX6UL silicon revision 1.2 * i.MX67SD silicon revision 1.3 Port the RNG software self-test from this patch to barebox. It can be enabled by selecting CRYPTO_DEV_FSL_CAAM_RNG_SELF_TEST in Kconfig. The original patch included a command line utility to run the self-test, but we choose a different approach here, and run the software self-test automatically when the respective HAB events indicating a RNG ROM self-test failure are found when running habv4_get_status(). Note that habv4_get_status() must be called by the board code before the CAAM device driver is probed for this mechanism to work. Until now there are at least two such known events. The first event was observed on an i.MX6Solo, silicon revision 1.4; the second event is mentioned in the original patch description given above. When an event occured, habv4_get_status() tests if it is one of those known events, and if so, indicates to the CAAM driver to run the software self-test. In this case, printing the respective HAB warning is suppressed to prevent confusion; the software self-test itself will error out in case of recurring RNG self-test failure. Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - allow retrieving 'era' from registerMarcin Niestroj2018-09-042-4/+58
| | | | | | | | | | | | | | | | | | | | | | | Pick commit 654f2b937b389295581bcb4aa26011a63db7bc8f from Linux upstream. crypto: caam - allow retrieving 'era' from register The 'era' information can be retrieved from CAAM registers, so introduce a caam_get_era_from_hw() function that gets it via register reads in case the 'fsl,sec-era' property is not passed in the device tree. This function is based on the U-Boot implementation from drivers/crypto/fsl/sec.c Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Horia Geantă <horia.geanta@nxp.com> Tested-by: Breno Lima <breno.lima@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - staticize caam_get_era()Marcin Niestroj2018-09-042-3/+1
| | | | | | | | | | | | | | | | | Pick commit b0039c00fbbbc3cb9c4b25852d81a2b4c193371d from Linux upstream. crypto: caam - staticize caam_get_era() caam_get_era() is only used locally, so do not export this function and make it static instead. Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - sync desc.h with LinuxMarcin Niestroj2018-09-041-23/+9
| | | | | | | | Get rid of all differences between our and Linux content of desc.h, so we prevent running into issues when porting new features in future. Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - do not use mem and emi_slow clock for imx7xMarcin Niestroj2018-09-041-12/+21
| | | | | | | | | | | | | | | | | | | | | | | Pick commit 699e491bac84a2069c7abeacf2f4367ecb19fa9c from Linux upstream. crypto: caam - do not use mem and emi_slow clock for imx7x I.MX7x only use two clocks for the CAAM module, so make sure we do not try to use the mem and the emi_slow clock when running in that imx7d and imx7s machine type. Cc: "Horia Geantă" <horia.geanta@nxp.com> Cc: Aymen Sghaier <aymen.sghaier@nxp.com> Cc: Fabio Estevam <fabio.estevam@nxp.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Lukas Auer <lukas.auer@aisec.fraunhofer.de> Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - fix endless loop when DECO acquire failsMarcin Niestroj2018-09-041-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pick commit 225ece3e7dad4cfc44cca38ce7a3a80f255ea8f1 from Linux upstream. crypto: caam - fix endless loop when DECO acquire fails In case DECO0 cannot be acquired - i.e. run_descriptor_deco0() fails with -ENODEV, caam_probe() enters an endless loop: run_descriptor_deco0 ret -ENODEV -> instantiate_rng -ENODEV, overwritten by -EAGAIN ret -EAGAIN -> caam_probe -EAGAIN results in endless loop It turns out the error path in instantiate_rng() is incorrect, the checks are done in the wrong order. Cc: <stable@vger.kernel.org> # 3.13+ Fixes: 1005bccd7a4a6 ("crypto: caam - enable instantiation of all RNG4 state handles") Reported-by: Bryan O'Donoghue <pure.logic@nexus-software.ie> Suggested-by: Auer Lukas <lukas.auer@aisec.fraunhofer.de> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - constify key dataMarcin Niestroj2018-09-041-4/+4
| | | | | | | | | | | | | | | Pick commit 6674a4fdc6c2e690b28b7f590cd20871aeee55ad from Linux upstream. crypto: caam - constify key data Key data is not modified, it is copied in the shared descriptor. Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - fix incorrect defineMarcin Niestroj2018-09-041-1/+1
| | | | | | | | | | | | | | | Pick commit cc2f8ab5334a736fa0e775cfccf06c1e268667f0 from Linux upstream. crypto: caam - fix incorrect define Fixes: 3ebfa92f49a6 ("crypto: caam - Add new macros for building extended SEC descriptors (> 64 words)") Signed-off-by: Radu Alexe <radu.alexe@nxp.com> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - clean-up in caam_init_rng()Marcin Niestroj2018-09-041-5/+1
| | | | | | | | | | | | | | | | Pick commit f366af462aef1dcaeab0f68b031e5c4c4eb860e1 from Linux upstream. crypto: caam - clean-up in caam_init_rng() Clean up the code, as indicated by Coccinelle. Cc: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - avoid double inclusion in desc_constr.hMarcin Niestroj2018-09-041-0/+5
| | | | | | | | | | | | | Pick commit cd373691d262afea523f4ae6ebf3dee3a204c8a7 from Linux upstream. crypto: caam - avoid double inclusion in desc_constr.h Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - constify pointer to descriptor bufferMarcin Niestroj2018-09-041-33/+36
| | | | | | | | | | | | | | | | | Pick commit 24a4f14f0a93f6fff7e6ade5d99b402c831bbd96 from Linux upstream. crypto: caam - constify pointer to descriptor buffer The pointer to the descriptor buffer is not touched, it always points to start of the descriptor buffer. Thus, make it const. Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - remove unreachable code in report_ccb_status()Marcin Niestroj2018-09-041-3/+2
| | | | | | | | | | | | | | | | | Pick commit 9305dff7ab8b5e1aef2c4c5c733ce7e1dc345433 from Linux upstream. crypto: caam - remove unreachable code in report_ccb_status() ERRID is a 4-bit field. Since err_id values are in [0..15] and err_id_list array size is 16, the condition "err_id < ARRAY_SIZE(err_id_list)" is always true. Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - trivial code clean-upMarcin Niestroj2018-09-041-2/+1
| | | | | | | | | | | | | | | | | | Pick commit 4ca7c7d8fea1ffdc36df33578c1e68d0d6367b0c from Linux upstream. crypto: caam - trivial code clean-up -replace offsetof with container_of -remove unused "assoc_nents", "iv_dma" from aead_edesc and fix comments -remove unused CAAM_MAX_IV_LENGTH #define Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - fix sparse warningsMarcin Niestroj2018-09-042-21/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pick commit 8439e94fceb3812989bae41922567123cffd1cf7 from Linux upstream. crypto: caam - fix sparse warnings Fix the following sparse warning (note that endianness issues are not not addressed in current patch): drivers/crypto/caam/ctrl.c:388:24: warning: incorrect type in argument 1 (different address spaces) drivers/crypto/caam/ctrl.c:388:24: expected void [noderef] <asn:2>*reg drivers/crypto/caam/ctrl.c:388:24: got unsigned int *<noident> drivers/crypto/caam/ctrl.c:390:24: warning: incorrect type in argument 1 (different address spaces) drivers/crypto/caam/ctrl.c:390:24: expected void [noderef] <asn:2>*reg drivers/crypto/caam/ctrl.c:390:24: got unsigned int *<noident> drivers/crypto/caam/ctrl.c:548:24: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:548:24: expected struct caam_ctrl [noderef] <asn:2>*ctrl drivers/crypto/caam/ctrl.c:548:24: got struct caam_ctrl *<noident> drivers/crypto/caam/ctrl.c:550:30: warning: cast removes address space of expression drivers/crypto/caam/ctrl.c:549:26: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:549:26: expected struct caam_assurance [noderef] <asn:2>*assure drivers/crypto/caam/ctrl.c:549:26: got struct caam_assurance *<noident> drivers/crypto/caam/ctrl.c:554:28: warning: cast removes address space of expression drivers/crypto/caam/ctrl.c:553:24: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:553:24: expected struct caam_deco [noderef] <asn:2>*deco drivers/crypto/caam/ctrl.c:553:24: got struct caam_deco *<noident> drivers/crypto/caam/ctrl.c:634:48: warning: cast removes address space of expression drivers/crypto/caam/ctrl.c:633:44: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:633:44: expected struct caam_job_ring [noderef] <asn:2>*<noident> drivers/crypto/caam/ctrl.c:633:44: got struct caam_job_ring *<noident> drivers/crypto/caam/ctrl.c:648:34: warning: cast removes address space of expression drivers/crypto/caam/ctrl.c:647:30: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:647:30: expected struct caam_queue_if [noderef] <asn:2>*qi drivers/crypto/caam/ctrl.c:647:30: got struct caam_queue_if *<noident> drivers/crypto/caam/ctrl.c:806:37: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:806:37: expected void *data drivers/crypto/caam/ctrl.c:806:37: got unsigned int [noderef] <asn:2>* drivers/crypto/caam/ctrl.c:814:38: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:814:38: expected void *data drivers/crypto/caam/ctrl.c:814:38: got unsigned int [noderef] <asn:2>* drivers/crypto/caam/ctrl.c:822:38: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/ctrl.c:822:38: expected void *data drivers/crypto/caam/ctrl.c:822:38: got unsigned int [noderef] <asn:2>* drivers/crypto/caam/jr.c:492:23: warning: incorrect type in assignment (different address spaces) drivers/crypto/caam/jr.c:492:23: expected struct caam_job_ring [noderef] <asn:2>*rregs drivers/crypto/caam/jr.c:492:23: got struct caam_job_ring *<noident> drivers/crypto/caam/caampkc.c:398:35: warning: Using plain integer as NULL pointer drivers/crypto/caam/caampkc.c:444:35: warning: Using plain integer as NULL pointer Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - add support for iMX6ULMarcin Niestroj2018-09-041-12/+17
| | | | | | | | | | | | | | | | | Pick commit 4e518816a938187b3bfe1b62fa291d4e38dca06e from Linux upstream. crypto: caam - add support for iMX6UL i.MX6UL does only require three clocks to enable CAAM module. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - handle core endianness != caam endiannessMarcin Niestroj2018-09-045-105/+206
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pick commit 261ea058f016bc04fa064348ad9bf39d94379381 from Linux upstream. crypto: caam - handle core endianness != caam endianness There are SoCs like LS1043A where CAAM endianness (BE) does not match the default endianness of the core (LE). Moreover, there are requirements for the driver to handle cases like CPU_BIG_ENDIAN=y on ARM-based SoCs. This requires for a complete rewrite of the I/O accessors. PPC-specific accessors - {in,out}_{le,be}XX - are replaced with generic ones - io{read,write}[be]XX. Endianness is detected dynamically (at runtime) to allow for multiplatform kernels, for e.g. running the same kernel image on LS1043A (BE CAAM) and LS2080A (LE CAAM) armv8-based SoCs. While here: debugfs entries need to take into consideration the endianness of the core when displaying data. Add the necessary glue code so the entries remain the same, but they are properly read, regardless of the core and/or SEC endianness. Note: pdb.h fixes only what is currently being used (IPsec). Reviewed-by: Tudor Ambarus <tudor-dan.ambarus@nxp.com> Signed-off-by: Horia Geantă <horia.geanta@nxp.com> Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> As part of this patch rd_reg[8,16,32,64]() and wr_reg[8,16,32,64]() helper functions are introduced. All readl() calls are replaced by rd_reg32() and all writel() calls are replaced by wr_reg32(). Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - fix writing to JQCR_MS when using service interfaceMarcin Niestroj2018-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pick commit 9f587fa29f7e8ed6b8885cff51a51ace3ad85152 from Linux upstream. crypto: caam - fix writing to JQCR_MS when using service interface Most significant part of JQCR (Job Queue Control Register) contains bits that control endianness: ILE - Immediate Little Endian, DWS - Double Word Swap. The bits are automatically set by the Job Queue Controller HW. Unfortunately these bits are cleared in SW when submitting descriptors via the register-based service interface. >From LS1021A: JQCR_MS = 08080100 - before writing: ILE | DWS | SRC (JR0) JQCR_MS = 30000100 - after writing: WHL | FOUR | SRC (JR0) This would cause problems on little endian caam for descriptors containing immediata data or double-word pointers. Currently there is no problem since the only descriptors ran through this interface are the ones that (un)instantiate RNG. Signed-off-by: Horia Geant? <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - fix warning in APPEND_MATH_IMM_u64Marcin Niestroj2018-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | Pick commit c1f2cd21ed5335bfcf5dd1d3a05a2a83bae14c3a from Linux upstream. crypto: caam - fix warning in APPEND_MATH_IMM_u64 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. Signed-off-by: Tudor Ambarus <tudor.ambarus@freescale.com> Signed-off-by: Horia Geant? <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - fix RNG init descriptor ret. code checkingMarcin Niestroj2018-09-041-2/+3
| | | | | | | | | | | | | | | | | Pick commit 62743a4145bb9c3fe090a48e10ddc0ebae85bfbf from Linux upstream. crypto: caam - fix RNG init descriptor ret. code checking When successful, the descriptor that performs RNG initialization is allowed to return a status code of 7000_0000h, since last command in the descriptor is a JUMP HALT. Signed-off-by: Horia Geant? <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam: use dma_alloc_coherent instead of dma_allocOleksij Rempel2017-07-121-3/+1
| | | | | | | | | | dma_alloc return non-coherent memory, but the driver does no cache maintenance on the buffer, causing memory corruption. Fix this by requesting coherent memory for the DMA transfer. Fixes: ef4144b4ab63 (crypto: caam - fix RNG buffer cache alignment) Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* crypto: caam - fix RNG buffer cache alignmentOleksij Rempel2017-03-301-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this is alternate version of linux fix: --------------------------------------------------------------------- | commit 412c98c1bef65fe7589f1300e93735d96130307c | Author: Steve Cornelius <steve.cornelius@freescale.com> | Date: Mon Jun 15 16:52:59 2015 -0700 | | crypto: caam - fix RNG buffer cache alignment | | The hwrng output buffers (2) are cast inside of a a struct (caam_rng_ctx) | allocated in one DMA-tagged region. While the kernel's heap allocator | should place the overall struct on a cacheline aligned boundary, the 2 | buffers contained within may not necessarily align. Consenquently, the | ends of unaligned buffers may not fully flush, and if so, stale data will be | left behind, resulting in small repeating patterns. | | This fix aligns the buffers inside the struct. | | Note that not all of the data inside caam_rng_ctx necessarily needs to | be DMA-tagged, only the buffers themselves require this. However, a fix | would incur the expense of error-handling bloat in the case of allocation | failure. | | Cc: stable@vger.kernel.org | Signed-off-by: Steve Cornelius <steve.cornelius@freescale.com> | Signed-off-by: Victoria Milhoan <vicki.milhoan@freescale.com> | Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> --------------------------------------------------------------------- instead we will use just dma_alloc() Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* caamrng: port to hwrng frameworkOleksij Rempel2017-03-302-28/+13
| | | | | Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: add i.MX6 CAAM supportSteffen Trumtrar2016-02-1215-0/+4636
Add the i.MX6 crypto core CAAM with support for the random number generator. The core itself works with jobrings in which descriptors can be queued/dequeued for processing. Depending on descriptor type the CAAM unit then either produces random numbers or decrypts/encrypts data. The code is based on the Linux v4.1 driver of the same name without all the crypto/hashing components. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>