All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH][v2] armv8: sec_firmware: Remove JR3 from device tree node in all cases
@ 2018-04-12 10:54 Ruchika Gupta
  2018-05-09 18:12 ` York Sun
  0 siblings, 1 reply; 2+ messages in thread
From: Ruchika Gupta @ 2018-04-12 10:54 UTC (permalink / raw)
  To: u-boot

JR3 was getting removed from device tree only if random number generation
was successful. However, if SEC firmware is present,JR3 should be removed
from device tree node irrespective of the random seed generation as
SEC firmware reserves it for it's use. Not removing it in case of random
number generation failure causes the kernel to crash.

Random number generation was being called twice. This is not required.
If SEC firmware is running, SIP call can be made to the SEC firmware to
get the random number. This call itself would return failure if function
is not supported. Duplicate calling of random number generation function
has been removed

Signed-off-by: Ruchika Gupta <ruchika.gupta@nxp.com>
---
Changes from v1:
Removed unused variable rand from the sec_firmware_support_hwrng function

 arch/arm/cpu/armv8/fsl-layerscape/fdt.c | 4 ++--
 arch/arm/cpu/armv8/sec_firmware.c       | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
index 99c5d13..955ef30 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
+++ b/arch/arm/cpu/armv8/fsl-layerscape/fdt.c
@@ -415,8 +415,8 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 		ccsr_sec_t __iomem *sec;
 
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
-		if (fdt_fixup_kaslr(blob))
-			fdt_fixup_remove_jr(blob);
+		fdt_fixup_remove_jr(blob);
+		fdt_fixup_kaslr(blob);
 #endif
 
 		sec = (void __iomem *)CONFIG_SYS_FSL_SEC_ADDR;
diff --git a/arch/arm/cpu/armv8/sec_firmware.c b/arch/arm/cpu/armv8/sec_firmware.c
index b56ea78..98d7be3 100644
--- a/arch/arm/cpu/armv8/sec_firmware.c
+++ b/arch/arm/cpu/armv8/sec_firmware.c
@@ -318,9 +318,7 @@ unsigned int sec_firmware_support_psci_version(void)
  */
 bool sec_firmware_support_hwrng(void)
 {
-	uint8_t rand[8];
 	if (sec_firmware_addr & SEC_FIRMWARE_RUNNING) {
-		if (!sec_firmware_get_random(rand, 8))
 			return true;
 	}
 
@@ -429,8 +427,10 @@ int fdt_fixup_kaslr(void *fdt)
 
 #if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT)
 	/* Check if random seed generation is  supported */
-	if (sec_firmware_support_hwrng() == false)
+	if (sec_firmware_support_hwrng() == false) {
+		printf("WARNING: SEC firmware not running, no kaslr-seed\n");
 		return 0;
+	}
 
 	ret = sec_firmware_get_random(rand, 8);
 	if (ret < 0) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH][v2] armv8: sec_firmware: Remove JR3 from device tree node in all cases
  2018-04-12 10:54 [U-Boot] [PATCH][v2] armv8: sec_firmware: Remove JR3 from device tree node in all cases Ruchika Gupta
@ 2018-05-09 18:12 ` York Sun
  0 siblings, 0 replies; 2+ messages in thread
From: York Sun @ 2018-05-09 18:12 UTC (permalink / raw)
  To: u-boot

On 04/12/2018 05:53 AM, Ruchika Gupta wrote:
> JR3 was getting removed from device tree only if random number generation
> was successful. However, if SEC firmware is present,JR3 should be removed
> from device tree node irrespective of the random seed generation as
> SEC firmware reserves it for it's use. Not removing it in case of random
> number generation failure causes the kernel to crash.
> 
> Random number generation was being called twice. This is not required.
> If SEC firmware is running, SIP call can be made to the SEC firmware to
> get the random number. This call itself would return failure if function
> is not supported. Duplicate calling of random number generation function
> has been removed
> 
> Signed-off-by: Ruchika Gupta <ruchika.gupta@nxp.com>
> ---
> Changes from v1:
> Removed unused variable rand from the sec_firmware_support_hwrng function
> 
Applied to fsl-qoriq master, awaiting upstream.
Thanks.

York

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-09 18:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-12 10:54 [U-Boot] [PATCH][v2] armv8: sec_firmware: Remove JR3 from device tree node in all cases Ruchika Gupta
2018-05-09 18:12 ` York Sun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.