crypto/fsl: allow accessing Job Ring from non-TrustZone
Subsystems (2)
v2 cover crypto/fsl: allow accessing Job Ring from non-TrustZone
From: Emanuele Ghidoli <[email protected]>
This series allows using Freescale CAAM Job Ring from Linux without having OP-TEE, this is needed for example on Toradex Colibri iMX7 where we just have U-Boot + Linux kernel.
To achieve this add a new config option to allow the non-secure world to access job rings.
The functionality has been broken since U-Boot v2019.07, with commit 51f1357f3428 ("Revert "drivers/crypto/fsl: assign job-rings to non-TrustZone"")
---
v2:
* Kconfig: spelt "CAAM" instead of caam
* Kconfig: removed "default=n"
v1: https://lore.kernel.org/all/[email protected]/
Emanuele Ghidoli (3):
crypto/fsl: allow accessing Job Ring from non-TrustZone
configs: colibri-imx7: set non-secure boot mode as default
configs: colibri-imx7: allow accessing job-rings from non-TrustZone
configs/colibri_imx7_defconfig | 1 + configs/colibri_imx7_emmc_defconfig | 2 +- drivers/crypto/fsl/Kconfig | 6 ++++++ drivers/crypto/fsl/jr.c | 19 +++++++++++++++++++ drivers/crypto/fsl/jr.h | 2 ++ 5 files changed, 29 insertions(+), 1 deletion(-)
Signature · 1 line
2.34.1
PATCH v2 1/3 crypto/fsl: allow accessing Job Ring from non-TrustZone
From: Emanuele Ghidoli <[email protected]>
Add a new kconfig option to allow non-secure world access to the CAAM Job Ring.
This is needed, for example, when running linux without OP-TEE services, as it's done on Colibri iMX7.
--- drivers/crypto/fsl/Kconfig | 6 ++++++ drivers/crypto/fsl/jr.c | 19 +++++++++++++++++++ drivers/crypto/fsl/jr.h | 2 ++ 3 files changed, 27 insertions(+)
drivers/crypto/fsl/Kconfig +6 -0
@@ -62,6 +62,12 @@ config SYS_FSL_SEC_LE if FSL_CAAM +config FSL_CAAM_JR_NTZ_ACCESS + bool "Give CAAM Job Ring access to non-secure world" + help + It is needed when OP-TEE is not used and Freescale CAAM Job Ring linux + driver is used. + config FSL_CAAM_RNG bool "Enable Random Number Generator support" depends on DM_RNG
drivers/crypto/fsl/jr.c +19 -0
@@ -673,6 +673,21 @@ static int rng_init(uint8_t sec_idx, ccsr_sec_t *sec)return ret; } +#if CONFIG_IS_ENABLED (FSL_CAAM_JR_NTZ_ACCESS ) +static void jr_setown_non_trusted (ccsr_sec_t *sec) +{ +u32 jrown_ns; +int i; + +/* Set ownership of job rings to non-TrustZone mode */ +for (i =0 ; i <ARRAY_SIZE (sec->jrliodnr); i++) { + jrown_ns =sec_in32 (&sec->jrliodnr[i].ms); + jrown_ns |=JROWN_NS |JRMID_NS ; +sec_out32 (&sec->jrliodnr[i].ms, jrown_ns); + } +} +#endif +int sec_init_idx (uint8_t sec_idx) {int ret =0 ;
@@ -761,6 +776,10 @@ int sec_init_idx(uint8_t sec_idx)#if CONFIG_IS_ENABLED (OF_CONTROL ) init:#endif +#if CONFIG_IS_ENABLED (FSL_CAAM_JR_NTZ_ACCESS ) +jr_setown_non_trusted (sec); +#endif + ret =jr_init (sec_idx, caam);if (ret <0 ) {printf ("SEC%u: initialization failed\n" , sec_idx);
drivers/crypto/fsl/jr.h +2 -0
@@ -37,6 +37,8 @@#define JRNSLIODN_MASK 0x0fff0000#define JRSLIODN_SHIFT 0#define JRSLIODN_MASK 0x00000fff +#define JROWN_NS 0x00000008 +#define JRMID_NS 0x00000001#define JRDID_MS_PRIM_DID BIT(0)#define JRDID_MS_PRIM_TZ BIT(4)
Signature · 1 line
2.34.1
PATCH v2 2/3 configs: colibri-imx7: set non-secure boot mode as default
In reply to Emanuele GhidoliFrom: Emanuele Ghidoli <[email protected]>
Linux kernel is supposed to run in non-secure world, fix the defconfig accordingly.
--- configs/colibri_imx7_emmc_defconfig | 1 - 1 file changed, 1 deletion(-)
configs/colibri_imx7_emmc_defconfig +0 -1
@@ -8,7 +8,6 @@ CONFIG_DEFAULT_DEVICE_TREE="imx7d-colibri-emmc-eval-v3" CONFIG_TARGET_COLIBRI_IMX7=y CONFIG_TARGET_COLIBRI_IMX7_EMMC=y CONFIG_OF_LIBFDT_OVERLAY=y -CONFIG_ARMV7_BOOT_SEC_DEFAULT=y CONFIG_IMX_RDC=y CONFIG_IMX_BOOTAUX=y CONFIG_IMX_HAB=y
Signature · 1 line
2.34.1
PATCH v2 3/3 configs: colibri-imx7: allow accessing job-rings from non-TrustZone
In reply to Emanuele GhidoliFrom: Emanuele Ghidoli <[email protected]>
Set FSL_CAAM_JR_NTZ_ACCESS configuration since colibri-imx7 uses Freescale CAAM Job Ring linux driver
--- configs/colibri_imx7_defconfig | 1 + configs/colibri_imx7_emmc_defconfig | 1 + 2 files changed, 2 insertions(+)
configs/colibri_imx7_defconfig +1 -0
@@ -72,6 +72,7 @@ CONFIG_SERVERIP="192.168.10.1" CONFIG_BOUNCE_BUFFER=y CONFIG_BOOTCOUNT_LIMIT=y CONFIG_BOOTCOUNT_ENV=y +CONFIG_FSL_CAAM_JR_NTZ_ACCESS=y CONFIG_DFU_NAND=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_BUF_ADDR=0x81100000
configs/colibri_imx7_emmc_defconfig +1 -0
@@ -61,6 +61,7 @@ CONFIG_USE_SERVERIP=y CONFIG_SERVERIP="192.168.10.1" CONFIG_BOOTCOUNT_LIMIT=y CONFIG_BOOTCOUNT_ENV=y +CONFIG_FSL_CAAM_JR_NTZ_ACCESS=y CONFIG_USB_FUNCTION_FASTBOOT=y CONFIG_FASTBOOT_BUF_ADDR=0x81100000 CONFIG_FASTBOOT_FLASH=y
Signature · 1 line
2.34.1
Fabio Estevam
reviewerQuoted 11 lines · Emanuele Ghidoli
From: Emanuele Ghidoli <[email protected]>
This series allows using Freescale CAAM Job Ring from Linux without having OP-TEE, this is needed for example on Toradex Colibri iMX7 where we just have U-Boot + Linux kernel.
To achieve this add a new config option to allow the non-secure world to access job rings.
The functionality has been broken since U-Boot v2019.07, with commit
51f1357f3428("Revert "drivers/crypto/fsl: assign job-rings to non-TrustZone"")
Quoted 7 lines
---
v2:
*Kconfig: spelt "CAAM" instead of caam
*Kconfig: removed "default=n"
v1: https://lore.kernel.org/all/[email protected]/
Applied to u-boot-imx/next, thanks.