Skip to contentSkip to conversation

armv8: sec_firmware: drop unneeded ARMV8_SEC_FIRMWARE_SUPPORT check

PATCH In review Michael Walle 2 participants 4 messages Nov 26, 2021 – Apr 6, 2022 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 armv8: sec_firmware: drop unneeded ARMV8_SEC_FIRMWARE_SUPPORT check

This module will only be compiled if this symbol is set. Remove the useless check. While at it, invert the return code, to return 0 if the function succeeds. The only user of this function in arch/arm/cpu/armv8/fsl-layerscape/fdt.c doesn't check the return code anyway, so its safe change it.

---
 arch/arm/cpu/armv8/sec_firmware.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)
arch/arm/cpu/armv8/sec_firmware.c +9 -11
index 267894fbcb..e62e9dc380 100644
@@ -458,47 +458,45 @@ int sec_firmware_init(const void *sec_firmware_img,
 /*
  * fdt_fix_kaslr - Add kalsr-seed node in Device tree
  * @fdt:		Device tree
- * @eret:		0 in case of error, 1 for success
+ *
+ * Returns 0 on success and 1 in case of an error.
  */
 int fdt_fixup_kaslr(void *fdt)
 {
 	int nodeoffset;
-	int err, ret = 0;
+	int err;
 	u8 rand[8];
 
-#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT)
 	/* Check if random seed generation is  supported */
 	if (sec_firmware_support_hwrng() == false) {
 		printf("WARNING: SEC firmware not running, no kaslr-seed\n");
-		return 0;
+		return 1;
 	}
 
 	ret = sec_firmware_get_random(rand, 8);
 	if (ret < 0) {
 		printf("WARNING: No random number to set kaslr-seed\n");
-		return 0;
+		return 1;
 	}
 
 	err = fdt_check_header(fdt);
 	if (err < 0) {
 		printf("fdt_chosen: %s\n", fdt_strerror(err));
-		return 0;
+		return 1;
 	}
 
 	/* find or create "/chosen" node. */
 	nodeoffset = fdt_find_or_add_subnode(fdt, 0, "chosen");
 	if (nodeoffset < 0)
-		return 0;
+		return 1;
 
 	err = fdt_setprop(fdt, nodeoffset, "kaslr-seed", rand,
 				  sizeof(rand));
 	if (err < 0) {
 		printf("WARNING: can't set kaslr-seed %s.\n",
 		       fdt_strerror(err));
-		return 0;
+		return 1;
 	}
-	ret = 1;
-#endif
 
-	return ret;
+	return 0;
 }
Signature · 1 line
2.30.2
#1 lore raw

Am 2021-11-26 17:11, schrieb Michael Walle:

Quoted 7 lines

This module will only be compiled if this symbol is set. Remove the useless check. While at it, invert the return code, to return 0 if the function succeeds. The only user of this function in arch/arm/cpu/armv8/fsl-layerscape/fdt.c doesn't check the return code anyway, so its safe change it.

Ping? :)

Tom, this is assigned to you in patchwork.

-michael

#2 lore raw
In reply to Michael Walle
Quoted 10 lines · Michael Walle

This module will only be compiled if this symbol is set. Remove the useless check. While at it, invert the return code, to return 0 if the function succeeds. The only user of this function in arch/arm/cpu/armv8/fsl-layerscape/fdt.c doesn't check the return code anyway, so its safe change it.

---
 arch/arm/cpu/armv8/sec_firmware.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Currently this causes a large number of platforms to fail to build such as ls1012aqds_tfa_SECURE_BOOT, please fix and resubmit, thanks.

Signature · 1 line
Tom
#3 lore raw

Am 2022-04-06 15:09, schrieb Tom Rini:

Quoted 8 lines · Michael Walle
Quoted 7 lines

This module will only be compiled if this symbol is set. Remove the useless check. While at it, invert the return code, to return 0 if the function succeeds. The only user of this function in arch/arm/cpu/armv8/fsl-layerscape/fdt.c doesn't check the return code anyway, so its safe change it.

Quoted 7 lines
Quoted 4 lines
---
 arch/arm/cpu/armv8/sec_firmware.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

Currently this causes a large number of platforms to fail to build such as ls1012aqds_tfa_SECURE_BOOT, please fix and resubmit, thanks.

Ahh, right, I guess that is because that ifdeffery is needed to distiguish the SPL build. In this case, this can be dropped.

Sorry for the noise,
-michael