summaryrefslogtreecommitdiffstats
path: root/drivers/hab
Commit message (Collapse)AuthorAgeFilesLines
* hab: implement i.MX9 supportSascha Hauer2024-02-161-0/+101
| | | | | | | | | While the underlying architecture of AHAB is quite different than HAB, the user interface fits into the existing hab command quite well, so integrate it into the existing HAB infrastructure. Link: https://lore.barebox.org/20240213151744.307958-7-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab: pass flags to lockdown_device()Sascha Hauer2024-02-161-5/+5
| | | | | | | | | | On i.MX93 there is no way to write fuses temporarily, so we have to make sure the user really wants to write the fuses permanently. Do this by passing flags containing IMX_SRK_HASH_WRITE_PERMANENT to the lockdown_device hook. Link: https://lore.barebox.org/20240213151744.307958-5-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab: cleanup hab status printing during bootSascha Hauer2024-02-164-38/+41
| | | | | | | | | | So far we have an initcall per SoC to print the HAB status. Add a struct imx_hab_ops::print_status() hook to reduce this to a single initcall. This will also allow us to print the HAB status later, maybe from the hab command, and not only during boot. Link: https://lore.barebox.org/20240213151744.307958-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab: drop i.MX35Sascha Hauer2024-02-161-1/+1
| | | | | | | | In one place we handle i.MX35 in the HAB code, but i.MX35 HAB support is not fully implemented. Just drop it. Link: https://lore.barebox.org/20240213151744.307958-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab: drop incomplete i.MX28 supportSascha Hauer2024-02-161-23/+0
| | | | | | | | HAB for i.MX28 was introduced with the first commit adding HAB support, but was never fully implemented for i.MX28. Remove it. Link: https://lore.barebox.org/20240213151744.307958-2-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* habv4: convert comments to common coding styleMarc Kleine-Budde2024-02-131-6/+10
| | | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Link: https://lore.barebox.org/20240212132901.1641599-2-mkl@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx'Sascha Hauer2024-01-231-30/+72
|\
| * habv4: use hab rom implementation of report_eventStefan Kerkmann2024-01-171-10/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing habv4 rom vector table had some mismatches in the API of the function pointers which broke calling into the HAB rom - mainly observed with the `report_event` function. The suspected culprit here is the `bytes` pointer which was `uint32_t*` vs. the documented `size_t*`. When compiled using the ILP32 data model e.g. for 32-Bit systems both referrenced values have the same width, but once compiled for (I)LP64 they differ as `size_t` is 64-Bit wide there. This seems to trigger a memory corruption once that pointer is passed to the HAB boot rom code and dereferenced there, the root cause wasn't investigated further though. As this implementation has only been tested on imx8mm, imx8nm and imx8mp boards I'm beeing defensive and only enable it for these targets. Once all SOCs of the family have been verified to work correctly the OCRAM readout workaround can be removed. Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Link: https://lore.barebox.org/20240112-fix-habv4-event-report-v2-2-1c91bc857935@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * habv4: correct habv4 rom vector tableStefan Kerkmann2024-01-161-20/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | All function signatures have been taken from the NXP manual "High Assurance Boot Version 4 Application Programming Interface Reference Manual" revision 1.4 under section "4.5 ROM vector table". A copy can be obtained from the imx code signing tool (imx-cst). The HAB SIP enum was extended with FSL_SIP_HAB_AUTH_IMG_NO_DCD which is supported by the upstream TF-A release 2.10. Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de> Link: https://lore.barebox.org/20240112-fix-habv4-event-report-v2-1-1c91bc857935@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | hab: habv4: warn if more than 10 HAB events are foundAhmad Fatoum2024-01-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The function has space for up to 10 HAB events. On the off-chance that there are more found, it will scribble them over stack memory. Fix this by only collecting up to 10 events and printing a warning if that's exceeded. Once we have reports that this issue manifests, we can consider extending the array or dynamically allocating it. Reported-by: Christian Melki <christian.melki@t2data.com> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240111130015.1784217-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | hab: habv4: use explicitly unsigned types for pointers into SRAMAhmad Fatoum2024-01-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | char is generally unsigned on ARM, but we shouldn't rely on that. HAB code does though and compare a char against 0xdb, which would never succeed if chars were signed. Switch to an explicitly unsigned type to fix this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240111130015.1784217-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | habv4: Fix parsing of unresonable events.Christian Melki2024-01-111-2/+13
|/ | | | | | | | | | | | | | An unknown root cause made data look like events (0xdb) with very long event lengths. This was causing very long printouts of bogus stuff in the console. While the root cause needs to be found and fixed, there is no need of parsing events with abnormal lengths. Also stop parsing if length exceeds the end of scope. Signed-off-by: Christian Melki <christian.melki@t2data.com> Link: https://lore.barebox.org/20231218202544.3952838-1-christian.melki@t2data.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/regmap'Sascha Hauer2023-10-271-1/+1
|\
| * treewide: switch regmap.h include to linux/regmap.hAhmad Fatoum2023-10-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that there are no longer any users of regmap.h in headers, let's switch all users in the source files to linux/regmap.h. That way, the only users of regmap.h whether directly or indirectly will be out-of-tree code, which will fail with an error if they are dependent on the old semantics of regmap_bulk_read and regmap_bulk_write. After a transitory period, we can then drop regmap.h. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231020071853.2826528-12-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: HABv4: retrieve HAB ROM version for i.MX8MRouven Czerwinski2023-10-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | The HAB userguide mentions this additional API calls introduced in 2018 (which coincides with the introduction of i.MX8M SoCs). Call this API call unconditionally on i.MX8M SoCs to print the HAB version the ROM code supports. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20231017145131.3069283-7-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: HABv4: extend support to i.MX8M SoCsRouven Czerwinski2023-10-182-9/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of only supporting i.MX8MQ based boards, extend support to the whole i.MX8M family. OCRAM address values were taken from AN12263 Rev1 06/2020. While at it turn the OCRAM addresses into defines as well and remove the superfluous comment lines. The fuses do match with the i.MX8MQ except for the DIR_BT_DIS fuse. [m.felsch@pengutronix.de: integrate review feedback] Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> [m.felsch@pengutronix.de: adapt commit message] Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20231017145131.3069283-6-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: HAB: remove unused init() hookMarco Felsch2023-10-181-14/+4
| | | | | | | | | | | | | | | | | | The init() hook was never used so we can remove it to cleanup the code a bit. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20231017145131.3069283-5-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: HABv4: fix i.MX8MQ device lockdownRouven Czerwinski2023-10-181-7/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The i.MX8M family of processors moved the SEC_CONFIG_1 fuse to a different location. Fix this by adding dedicated imx8mq ops which uses the new hook. [m.felsch@pengutronix.de: integrate review feedback] [a.fatoum@pengutronix.de: fixup imx_hab_device_locked_down_ocotp logic for imx6 and imx8m] Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> [m.felsch@pengutronix.de: split commit into two] Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20231017145131.3069283-4-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: HABv4: fix event status comparisonRouven Czerwinski2023-10-181-1/+1
|/ | | | | | | | | | | | Instead of only printing events belonging to a certain level, print all events that have a higher status than the current event. This fixes event printing for i.MX8M based boards. Fixes: 8b35facbb971 ("i.MX: HABv4: Improve HAB event printing") Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20231017145131.3069283-3-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab: habv4: export function to query HAB stateAhmad Fatoum2023-07-281-16/+13
| | | | | | | | | Board code may want to base runtime decisions on whether the system is secure booting. Add a function to query that state. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230726192718.911735-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* HAB: guard against NULL imx_hab_ops in imx_hab_device_locked_down()Ahmad Fatoum2023-07-281-0/+3
| | | | | | | | | | All other exported functions guard against imx_get_hab_ops() returning NULL, before dereferencing the returned pointer. Do likewise in imx_hab_device_locked_down(). Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230726192718.911735-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: hab: work-around GCC -Wmaybe-uninitialized false-positiveAhmad Fatoum2023-07-261-1/+1
| | | | | | | | | | | imx_hab_read_srk_hash() always initializes the buffer that's passed in fully. Yet, gcc-13.1.1 warns that this is not always the case, but inlining imx_hab_read_srk_hash() makes the false-positive warning disappear. Pacify GCC by just zero-initializing the 256-bit srk buffer. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230725203438.1056307-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: HABv4: fix left-over old arch_remap_range prototype useAhmad Fatoum2023-05-261-1/+1
| | | | | | | | | | | The first arch_remap_range occurrence in the file was correctly changed to remap_range, but the second that was added for v3 wasn't adjusted. Fix that. Fixes: 9845563450b8 ("treewide: use remap_range instead of arch_remap_range") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230526124712.1558294-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: use remap_range instead of arch_remap_rangeAhmad Fatoum2023-05-231-1/+1
| | | | | | | | | | | The remapping in arch_remap_range is currently limited to attributes. In a later commit, we'll start supporting non-1:1 remappings. We'll keep remap_range as is for 1:1, so as preparation, let's switch all arch_remap_range users that want 1:1 remappings to remap_range. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230522052835.1039143-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: Drop HAB workaroundSascha Hauer2023-05-221-1/+9
| | | | | | | | | The i.MX HAB code on i.MX6 has to jump into ROM which happens to start at 0x0. To make that possible we used to map the ROM cached and jumped to it before the MMU is initialized. Instead, remap the ROM as needed in the HAB code so that we can safely jump into ROM with MMU enabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: HABv4: Hide NULL pointers from optimizerSascha Hauer2023-05-161-0/+3
| | | | | | | | | | | | | We are derefencing pointers which are in the zero page, consequently gcc warns us with: drivers/hab/habv4.c: In function 'imx6_hab_get_status': drivers/hab/habv4.c:580:16: warning: array subscript 0 is outside array bounds of 'const struct habv4_rvt[0]' [-Warray-bounds] Yes, we really want to derefence these pointers, so silence the warning with OPTIMIZER_HIDE_VAR(). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix includes missed by multiarch supportAhmad Fatoum2023-04-111-1/+1
| | | | | | | | | | | Found by manual inspection of the results of: rg '#include\s*<mach/[^/]+>' | rg -v 'arch/(powerpc|sandbox|mips|x86|kvx)' Fixes: 68b778c24314 ("ARM: Drop mach dir include path") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230411071436.1630752-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ARM: i.MX: Move mach header files to include/mach/imxSascha Hauer2023-03-063-7/+7
| | | | | | | | | | | Currently arch specific headers can be included with #include <mach/xxx.h>. With upcoming multi-arch support this is no longer possible as there won't be a single mach anymore. Move all i.MX specific header files to include/mach/imx/ to prepare for multi-arch support. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: migrate "GPL-2.0" license identifiers to SPDX 2.0Roland Hieber2021-11-223-3/+3
| | | | | | | | | | "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-014-29/+4
| | | | | | | | | | | | | | | | | | | | 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>
* habv4: habv4_get_status(): do not print HAB error event in case of known RNG ↵Marc Kleine-Budde2021-07-181-2/+1
| | | | | | | | | | | | | | | | | | | | self test failure In commit | 655e085e3a22 ("crypto: caam - Always do rng selftest") the kconfig option CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_SELF_TEST was removed, which resulted in the pr_debug() never being executed. Remove the IS_ENABLED() to restore the original behavior, i.e. to not print the HAB error Event if it is the known RNG self-test failure. Fixes: 655e085e3a22 ("crypto: caam - Always do rng selftest") Reported-by: Roland Hieber <rhi@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Reviewed-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210716122110.4022409-1-mkl@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: HABv4: Improve HAB event printingSascha Hauer2020-11-241-24/+31
| | | | | | | | | | | | | | | Instead of using a fixed sized buffer for the report_event function, let's call it two times, once with a NULL pointer to get the size of the event and a second time with a buffer of that size. Also, instead of separating the events into warning and error type, iterate over all events in one single loop. This helps to get the events in the order they occured which probably helps the reader to make more sense of them. This also gets rid of the "ERROR: Recompile with larger event data buffer" message which recently appeared everytime a warning or error was reported. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+0
| | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* HAB: i.MX8M: rename imx8_* functions to imx8m_*Sascha Hauer2020-02-191-6/+6
| | | | | | | The big i.MX8 does HAB through the SCU which will be different. To avoid confusion rename the functions to imx8m_* Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx8-hab'Sascha Hauer2019-08-152-14/+122
|\
| * i.MX: HABv4: implement interface for i.MX8MQRouven Czerwinski2019-08-072-1/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The HAB interface for i.MX8MQ only implements the retrieval of status and events. The SoC status is retrieved using the TF-A SIP API found in the downstream imx TF-A. After calling into the TF-A the passed data structures need to be invalidated, since otherwise the cached zero value is used. Currently the TF-A report event call only supports FAILURE events. Testing the TF-A with other event types resulted in a freeze in the bootrom code, which was not investigated further. We instead walk the memory containing the events and retrieve the events ourselves. They are exposed using the same API. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i.MX: HABv4: ignore return for i.MX28/6 initcallsRouven Czerwinski2019-08-071-13/+5
| | | | | | | | | | | | | | | | Move the status call below the explanations and return Null. No functional changes intended. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | crypto: caam - Always do rng selftestSascha Hauer2019-08-061-13/+0
|/ | | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/imx'Sascha Hauer2019-07-121-1/+1
|\
| * i.MX: HABv4: use min_t instead of minRouven Czerwinski2019-06-261-1/+1
| | | | | | | | | | | | | | | | This fixes a compiler warning because len is size_t and RNG_FAIL_EVENT_SIZE was cast to uint32_t. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: HABv4: Reset index variable after error typeRouven Czerwinski2019-06-271-0/+2
|/ | | | | | | | | The index variable is used for each error type, it should be reset to 0 before retrieving the next error status, otherwise error messages are skipped if the preceding error type incremented index. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hab/caam: Fix compilation of caam driver when hab is disabledSascha Hauer2019-04-111-2/+7
| | | | | | | | | 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>
* i.MX habv3: add missing includes and make locally used function staticMichael Olbrich2019-03-041-1/+3
| | | | | | | | | | | | | | | Without this building fails with: drivers/hab/habv3.c:80:12: error: static declaration of 'imx25_hab_get_status' follows non-static declaration In file included from drivers/hab/habv3.c:14: include/hab.h:39:5: note: previous declaration of 'imx25_hab_get_status' was here drivers/hab/habv3.c:87:1: warning: data definition has no type or storage class drivers/hab/habv3.c:87:1: warning: type defaults to 'int' in declaration of 'postmmu_initcall' [-Wimplicit-int] drivers/hab/habv3.c:87:1: warning: parameter names (without types) in function declaration drivers/hab/habv3.c:80:12: warning: 'imx25_hab_get_status' defined but not used [-Wunused-function] Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i.MX: HABv4: always print HAB status at boot timeRoland Hieber2018-12-052-0/+50
| | | | | | | | | | Currently, board code needs to call habv4_get_status() explicitely, but there is no reason that it cannot be called automatically at startup when HABv4 is enabled. This way the call cannot be forgotten and we can make sure to report all potentially occuring HAB warnings and errors. Signed-off-by: Roland Hieber <r.hieber@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: caam: add RNG software self-testRoland Hieber2018-12-051-3/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/imx-hab'Sascha Hauer2018-09-111-12/+235
|\
| * i.MX habv4: habv4_display_event_record(): Add function to decode event recordMarc Kleine-Budde2018-08-291-0/+211
| | | | | | | | | | | | | | | | | | | | | | The code was leveraged from u-boot commit: 29067abfaf39 iMX: adding parsing to hab_status command by: Ulises Cardenas <Ulises.Cardenas@freescale.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i.MX habv4: habv4_get_status(): display warning events, tooMarc Kleine-Budde2018-08-291-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | The current code only retrieves the HAB errors from the ROM. If there are HAB warnings during startup, the code throws this wrong error message. > HABv4: ERROR: Recompile with larger event data buffer (at least 36 bytes) The correct solution is to retrieve the warnings from the ROM, too. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i.MX habv4: convert habv4_get_status() and habv4_display_event() from printf ↵Marc Kleine-Budde2018-08-291-9/+9
| | | | | | | | | | | | | | | | | | to pr_err() This way the events will be printed into the dmesg buffer, Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i.MX habv4: properly indent defines and enumsMarc Kleine-Budde2018-08-291-2/+2
| | | | | | | | | | Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>