armv8: sec_firmware: Remove JR3 from device tree node in all cases
authorRuchika Gupta <ruchika.gupta@nxp.com>
Thu, 12 Apr 2018 10:54:35 +0000 (16:24 +0530)
committerYork Sun <york.sun@nxp.com>
Wed, 9 May 2018 14:17:51 +0000 (09:17 -0500)
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>
Reviewed-by: York Sun <york.sun@nxp.com>
arch/arm/cpu/armv8/fsl-layerscape/fdt.c
arch/arm/cpu/armv8/sec_firmware.c

index 4afc046eeaf968660ad003626f1add7fe059b3cc..fc9de73bcef4ce3ee58bdb18ead0f2f3113c9c3d 100644 (file)
@@ -414,8 +414,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;
index 6a04eaca3eb977fa01449d6796842ed41a8411d9..5d2d839feaa108f179cd5b9c434166b833a92522 100644 (file)
@@ -317,9 +317,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;
        }
 
@@ -428,8 +426,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) {