summaryrefslogtreecommitdiffstats
path: root/drivers/crypto
Commit message (Collapse)AuthorAgeFilesLines
* crypto: caam - remove overly verbose debug printAhmad Fatoum2024-01-031-3/+0
| | | | | | | | | | | | | We can already read /dev/hwrng to get the randomness as generated by the device. Printing 32K bytes of randomness to the log (or even worse to console) is just not useful for debugging. There are debug prints for the job descriptors and Linux doesn't have this print too since commit 2c5e88dc90f5 ("crypto: caam - simplify RNG implementation"), so let's drop it in barebox too. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240102165537.1378708-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc-fixes-sandbox'Sascha Hauer2023-06-223-5/+5
|\
| * crypto: imx-scc: fix u32 to pointer castsAhmad Fatoum2023-06-131-3/+3
| | | | | | | | | | | | | | | | | | We don't deploy the driver to 64-bit systems, but fixing the lone warning we get while build testing is easy enough, so let's do that. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612130239.1087599-11-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * crypto: caam - fix pointer to u32 castsAhmad Fatoum2023-06-132-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | For 64-bit systems, we only have CAAM initialization support in PBL running as BL2 in EL3, but nothing for barebox proper. Understandably, trying to compile the CAAM code for 64-bit leads to warnings about casts between pointers and smaller integers. A sync with Linux to get 64-bit support is probably in-order for barebox proper CAAM drivers to actually work on i.MX8M, but for now, let's just fix the warnings. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612130239.1087599-10-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/dma-streaming-interface'Sascha Hauer2023-06-223-20/+20
|\ \ | |/ |/|
| * dma: rework dma_sync_single_for_*() interfaceDenis Orlov2023-06-063-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, a lot of code handles dma_addr_t values as if they actually hold CPU addresses. However, this is not always true. For example, MIPS architecture requires an explicit conversion from the physical address space to some virtual address space segment to get a valid CPU-side pointer. Another issue is that DMA ranges that may be specified in a device tree will not work this way. To get from a virtual address to a dma handle and vice versa we need to add/subtract some offset, which is calculated from "dma-ranges" property. Only dma_map_single() was doing this, but dma_sync_single_for_*() also should. Improve the interface by adding 'struct device' as the first argument to the dma_sync_single_for_*(). This allows to do cpu_to_dma/dma_to_cpu() conversions in common code and call into arch-specific code with proper cpu-side addresses. To make things more clear, make the virtual address argument of those arch-side functions be properly represented with a void* type. Apply the required changes in device drivers that use the affected functions, making them pass the appropriate device pointer. Signed-off-by: Denis Orlov <denorl2009@gmail.com> Link: https://lore.barebox.org/20230604215002.20240-2-denorl2009@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | treewide: add MODULE_DEVICE_TABLE markersAhmad Fatoum2023-06-132-0/+2
|/ | | | | | | | | | | | | | | | Syncing device trees with Linux upstream can lead to breakage, when the device trees are switched to newer bindings, which are not yet supported in barebox. To make it easier to spot such issues, we want to start applying some heuristics to flag possibly problematic DT changes. One step towards being able to do that is to know what nodes barebox actually consumes. Most of the nodes have a compatible entry, which is matched by an array of of_device_id, so let's have MODULE_DEVICE_TABLE point at it for future extraction. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230612125908.1087340-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: imx-scc: Kconfig: drop references to unknown symbolsAntony Pavlov2023-05-221-2/+0
| | | | | | | | barebox has neither CRYPTO_BLKCIPHER nor CRYPTO_DES. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Link: https://lore.barebox.org/20230512100825.1261808-1-antonynpavlov@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/arm' into nextSascha Hauer2023-03-161-5/+2
|\
| * drivers: drop unneeded CONFIG_CRYPTO_HW guardAhmad Fatoum2023-03-101-5/+2
| | | | | | | | | | | | | | | | | | | | | | CAAM and imx-scc both have their own Kconfig symbols, so CONFIG_CRYPTO_HW only serves the purpose of hiding a two entry menu behind it. Let's just get rid of it. This has the added benefit of being able to use imply on the drivers. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230307093426.1551193-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | crypto: caam - pbl-init: fix null pointer checkAhmad Fatoum2023-03-091-1/+1
|/ | | | | | | | | struct jr_data_st::desc is an array, so g_jrdata->desc will never be NULL. Fix the check to instead compare g_jrdata against NULL. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230307101446.2077676-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/caam'Sascha Hauer2023-01-208-75/+762
|\
| * ARM: i.MX8M: init CAAM when CONFIG_FSL_CAAM_RNG_PBL_INITAhmad Fatoum2023-01-121-1/+2
| | | | | | | | | | | | Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111075940.922817-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * crypto: caam - implement early PBL initAhmad Fatoum2023-01-127-3/+535
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the CAAM is TrustZone aware, Linux and OP-TEE drivers are not necessarily so: - Linux running in normal world will attempt to set up RNG via DECO, which can be restricted to secure world - OP-TEE may depend on RNG being set up by BL2 While the proper solution would be to teach their drivers how to instantiate the RNG via SHs, we'll want to support existing firmware, so take the easy way out and just set up RNG4 SH0 and SH1 in barebox. We already do that for the i.MX6, but the setup there happens in barebox proper. For security reasons, we want to install OP-TEE as early as possible while running the prebootloader, so we replicate the setup for PBL. This has been tested with the i.MX8MM and i.MX8MN. Note that barebox itself does not yet benefit from this setup and that the barebox proper driver for CAAM is unaffected by this change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111075940.922817-6-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * crypto: caam - make command constants unsignedAhmad Fatoum2023-01-121-20/+20
| | | | | | | | | | | | | | | | | | CMD_OPERATION is 0x10 << 27, which shifts a one into the sign bit. Make the constants unsigned to fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111075940.922817-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * crypto: caam - add job ring accessors from LinuxAhmad Fatoum2023-01-121-0/+60
| | | | | | | | | | | | | | | | | | | | | | Job ring entries differ in size depending on caam_ptr_sz. Fortunately, an entry is at most two elements big, so we can just provide accessors. Import them from Linux. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111075940.922817-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * crypto: caam - sync 64-bit accessors with LinuxAhmad Fatoum2023-01-122-52/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The barebox CAAM driver only ever ran on i.MX6 (32-bit little-endian i.MX). There are also CAAM units on Layerscape and i.MX8. Prepare for their support by syncing the current 64-bit accessors from Linux. In addition to the existing caam_little_end, these can also consult the caam_imx and caam_ptr_sz globals. They are for now initialized to maintain i.MX6 compatibility, but may be initialized dynamically in future. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230111075940.922817-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Rename struct driver_d to driverSascha Hauer2023-01-102-2/+2
| | | | | | | | | | | | | | | | | | | | | | The '_d' suffix was originally meant to distinguish barebox struct names from Linux struct names. struct driver doesn't exist in Linux, so we can rename it and remove the meaningless suffix. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Rename struct device_d to deviceSascha Hauer2023-01-1013-47/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Rename device_d::device_node to device_d::of_nodeSascha Hauer2023-01-101-1/+1
|/ | | | | | | | | | | | | | | | | | | | Linux struct device has the member of_node for the device_node pointer. Rename this in barebox accordingly to minimize the necessary changes when porting Linux code. This was done with the semantic patch: @@ struct device_d E; @@ - E.device_node + E.of_node @@ struct device_d *E; @@ - E->device_node + E->of_node Plus some manual adjustments. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* crypto: caam - delete unused variableAhmad Fatoum2022-09-121-2/+0
| | | | | | | | We don't use nprop anywhere, so drop it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220905095557.596891-20-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-2221-21/+21
| | | | | | | | | | "GPL-2.0-only" was introduced in SPDX 2.0, and the old identifier "GPL-2.0" is now considered deprecated; see <https://spdx.org/licenses>. Fixes: 28f4a6a4df76f0f1581d (2021-10-30, "drivers: add missing SPDX-License-Identifier") Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20211117113851.2022669-2-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: add missing SPDX-License-IdentifierAhmad Fatoum2021-11-0121-22/+22
| | | | | | | | | | | | | | | | | | | | This adds the suitable SPDX-License-Identifier to all files in drivers/ that previously lacked one. To aid manual inspection, following heuristics can be used: * No changes outside of comments/whitespace: git show -U0 HEAD | rg -v '^(@@|diff|index)|[-+]([-+]|//|#|[\s/]\*)' * -or-later come in pairs: git show --inter-hunk-context=19 HEAD | \ perl -0777 -F'/^@/gm' -ne 'for (@F) { @m = /later/g; print if @m & 1 }' Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: caam: remove license text covered by SPDX-License-IdentifierAhmad Fatoum2021-11-011-10/+0
| | | | | | | | There is already a SPDX-License-Identifier, so drop the boilerplate. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20211030175632.2276077-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* printk: port over Linux print_hex_dump_bytes/print_hex_dump_debugAhmad Fatoum2021-02-041-10/+6
| | | | | | | | | print_hex_dump in barebox always prints a hex dump. Most users use it for debugging though, so import Linux helpers to do so to cut down on the #ifdef DEBUG. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove stale instances of struct deviceAhmad Fatoum2020-08-032-7/+0
| | | | | | | | We call it struct device_d, any instances of struct device are likely left-over code after porting from Linux. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: mark first batch of compilable drivers for COMPILE_TESTAhmad Fatoum2020-05-082-3/+3
| | | | | | | | | All of these drivers have a runtime dependency on SoC peripherals, but can nevertheless be compile-tested. Add COMPILE_TEST as an alternate dependency. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>