Skip to contentSkip to conversation

armv8: layerscape: don't remove crypto node if just partially disabled

PATCH Superseded Michael Walle 4 participants 4 messages Aug 10, 2020 – Oct 16, 2020 Arm (32-bit)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 armv8: layerscape: don't remove crypto node if just partially disabled

On all newer Layerscape SoCs, the crypto module is just partially disabled on non-E parts. Thus it doesn't make sense to completely remove the node. Linux will figure out what is there and what is not.

Just remove it for older SoCs, where the module is indeed completely disabled on non-E parts.

---
Changes since v1:
- properly filter on SoC. Thanks to Horia's mail. See
https://patchwork.ozlabs.org/project/uboot/patch/20200602150904.1997-1-michael at walle.cc/#2457448

 arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 37 ++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +36 -1
index 3b43afb25c..acd25d4825 100644
@@ -437,13 +437,48 @@ __weak void fdt_fixup_ecam(void *blob)
 }
 #endif
 
+/*
+ * If it is a non-E part the crypto is disabled on the following SoCs:
+ *  - LS1043A
+ *  - LS1088A
+ *  - LS2088A
+ * and their personalities.
+ *
+ * On all other SoC they are just partially disabled, that means that the
+ * following is still working:
+ *  - hashing (using MDHA - message digest hash accelerator)
+ *  - random number generation (using RNG4)
+ *  - cyclic redundancy checking (using CRCA)
+ *  - runtime integrity checker (RTIC)
+ *
+ * The linux driver will figure out what is available and what is not.
+ * Therefore, we just remove the crypto node on the SoCs which has no crypto
+ * support at all.
+ */
+static bool crypto_is_disabled(unsigned int svr)
+{
+	if (IS_E_PROCESSOR(svr))
+		return false;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1088A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS2088A)))
+		return true;
+
+	return false;
+}
+
 void ft_cpu_setup(void *blob, struct bd_info *bd)
 {
 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
 	unsigned int svr = gur_in32(&gur->svr);
 
 	/* delete crypto node if not on an E-processor */
-	if (!IS_E_PROCESSOR(svr))
+	if (crypto_is_disabled(svr))
 		fdt_fixup_crypto_node(blob, 0);
 #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
 	else {
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 armv8: layerscape: don't remove crypto node if just partially disabled

Michael Walle-2 wrote

Quoted 91 lines

On all newer Layerscape SoCs, the crypto module is just partially disabled on non-E parts. Thus it doesn't make sense to completely remove the node. Linux will figure out what is there and what is not.

Just remove it for older SoCs, where the module is indeed completely disabled on non-E parts.

Signed-off-by Michael Walle <

michael@

>
---
Changes since v1:
- properly filter on SoC. Thanks to Horia's mail. See
https://patchwork.ozlabs.org/project/uboot/patch/

20200602150904.1997-1-michael@

/#2457448

 arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 37 ++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +16 -0
index 3b43afb25c..acd25d4825 100644
@@ -437,13 +437,48 @@ __weak void fdt_fixup_ecam(void *blob)
 }
 #endif
 
+/*
+ * If it is a non-E part the crypto is disabled on the following SoCs:
+ *  - LS1043A
+ *  - LS1088A
+ *  - LS2088A
+ * and their personalities.
+ *
+ * On all other SoC they are just partially disabled, that means that the
+ * following is still working:
+ *  - hashing (using MDHA - message digest hash accelerator)
+ *  - random number generation (using RNG4)
+ *  - cyclic redundancy checking (using CRCA)
+ *  - runtime integrity checker (RTIC)
+ *
+ * The linux driver will figure out what is available and what is not.
+ * Therefore, we just remove the crypto node on the SoCs which has no

crypto
+ * support at all.
+ */

arch/arm/cpu/armv8/fsl-layerscape/fdt.c +14 -0
+static bool crypto_is_disabled(unsigned int svr)
+{
+	if (IS_E_PROCESSOR(svr))
+		return false;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1088A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS2088A)))
+		return true;
+

These ifs can be put into a switch like

	switch (SVR_SOC_VER(svr)) {
	case SVR_LS1043A:
	case SVR_LS1088A:
	case SVR_LS2088A:
		return true;
       }
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +4 -1
+	return false;
+}
+
 void ft_cpu_setup(void *blob, struct bd_info *bd)
 {
 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
 	unsigned int svr = gur_in32(&gur->svr);
 
 	/* delete crypto node if not on an E-processor */
-	if (!IS_E_PROCESSOR(svr))
+	if (crypto_is_disabled(svr))
 		fdt_fixup_crypto_node(blob, 0);
 #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
 	else {
Signature · 1 line
2.20.1

--
Sent from: http://u-boot.10912.n7.nabble.com/

#2 lore raw

PATCH v2 1/1 armv8: layerscape: don't remove crypto node if just partially disabled

In reply to Michael Walle
Quoted 81 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Michael Walle
Sent: Monday, August 10, 2020 8:24 PM
To: u-boot at lists.denx.de
Cc: Priyanka Jain <[email protected]>; Horia Geanta <[email protected]>; Michael Walle <[email protected]>
Subject: [PATCH v2] armv8: layerscape: don't remove crypto node if just partially disabled

On all newer Layerscape SoCs, the crypto module is just partially disabled on non-E parts. Thus it doesn't make sense to completely remove the node. Linux will figure out what is there and what is not.

Just remove it for older SoCs, where the module is indeed completely disabled on non-E parts.

---
Changes since v1:
- properly filter on SoC. Thanks to Horia's mail. See
https://patchwork.ozlabs.org/project/uboot/patch/20200602150904.1997-1-
michael at walle.cc/#2457448

arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 37 ++++++++++++++++++++++++-

1 file changed, 36 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +37 -2
index 3b43afb25c..acd25d4825 100644
@@ -437,13 +437,48 @@ __weak void fdt_fixup_ecam(void *blob)  }  #endif
 
+/*
+ * If it is a non-E part the crypto is disabled on the following SoCs:
+ *  - LS1043A
+ *  - LS1088A
+ *  - LS2088A
+ * and their personalities.
+ *
+ * On all other SoC they are just partially disabled, that means that
+the
+ * following is still working:
+ *  - hashing (using MDHA - message digest hash accelerator)
+ *  - random number generation (using RNG4)
+ *  - cyclic redundancy checking (using CRCA)
+ *  - runtime integrity checker (RTIC)
+ *
+ * The linux driver will figure out what is available and what is not.
+ * Therefore, we just remove the crypto node on the SoCs which has no
+crypto
+ * support at all.
+ */
+static bool crypto_is_disabled(unsigned int svr) {
+	if (IS_E_PROCESSOR(svr))
+		return false;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1088A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS2088A)))
+		return true;
+
+	return false;
+}
+
 void ft_cpu_setup(void *blob, struct bd_info *bd)  {
 	struct ccsr_gur __iomem *gur = (void
 *)(CONFIG_SYS_FSL_GUTS_ADDR);
 	unsigned int svr = gur_in32(&gur->svr);
 
 	/* delete crypto node if not on an E-processor */
-	if (!IS_E_PROCESSOR(svr))
+	if (crypto_is_disabled(svr))
 		fdt_fixup_crypto_node(blob, 0);
 #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
 	else {
--
Quoted 1 line

2.20.1

Horia,

Kindly help to review this patch.

Regards
Priyanka

#3 lore raw

PATCH v2 1/1 armv8: layerscape: don't remove crypto node if just partially disabled

In reply to Michael Walle
Quoted 4 lines · Michael Walle

On all newer Layerscape SoCs, the crypto module is just partially disabled on non-E parts. Thus it doesn't make sense to completely remove the node. Linux will figure out what is there and what is not.

Could add a clarification here, saying "partially disabled" means that only export-controlled ciphers are disabled.

Quoted 17 lines

Just remove it for older SoCs, where the module is indeed completely disabled on non-E parts.

---
Changes since v1:
- properly filter on SoC. Thanks to Horia's mail. See
https://patchwork.ozlabs.org/project/uboot/patch/20200602150904.1997-1-michael at walle.cc/#2457448

 arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 37 ++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +0 -0
index 3b43afb25c..acd25d4825 100644

arch/arm/cpu/armv8/fsl-layerscape/fdt.c __weak void fdt_fixup_ecam(void *blob) · line 444

Quoted 8 lines
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +5 -0
@@ -437,13 +437,48 @@ __weak void fdt_fixup_ecam(void *blob)
 }
 #endif
 
+/*
+ * If it is a non-E part the crypto is disabled on the following SoCs:
+ *  - LS1043A
+ *  - LS1088A
+ *  - LS2088A

I've missed LS2080A.

arch/arm/cpu/armv8/fsl-layerscape/fdt.c __weak void fdt_fixup_ecam(void *blob) · line 447

Quoted 3 lines
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +3 -0
+ * and their personalities.
+ *
+ * On all other SoC they are just partially disabled, that means that the

^ it is (assuming "crypto" is the subject)

arch/arm/cpu/armv8/fsl-layerscape/fdt.c __weak void fdt_fixup_ecam(void *blob) · line 455

Quoted 8 lines
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +8 -0
+ * following is still working:
+ *  - hashing (using MDHA - message digest hash accelerator)
+ *  - random number generation (using RNG4)
+ *  - cyclic redundancy checking (using CRCA)
+ *  - runtime integrity checker (RTIC)
+ *
+ * The linux driver will figure out what is available and what is not.
+ * Therefore, we just remove the crypto node on the SoCs which has no crypto

^ have

Quoted 31 lines
arch/arm/cpu/armv8/fsl-layerscape/fdt.c +20 -1
+ * support at all.
+ */
+static bool crypto_is_disabled(unsigned int svr)
+{
+	if (IS_E_PROCESSOR(svr))
+		return false;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1043A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS1088A)))
+		return true;
+
+	if (IS_SVR_DEV(svr, SVR_DEV(SVR_LS2088A)))
+		return true;
+
+	return false;
+}
+
 void ft_cpu_setup(void *blob, struct bd_info *bd)
 {
 	struct ccsr_gur __iomem *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
 	unsigned int svr = gur_in32(&gur->svr);
 
 	/* delete crypto node if not on an E-processor */
-	if (!IS_E_PROCESSOR(svr))
+	if (crypto_is_disabled(svr))
 		fdt_fixup_crypto_node(blob, 0);
 #if CONFIG_SYS_FSL_SEC_COMPAT >= 4
 	else {