Skip to contentSkip to conversation

ARM: imx: Enable kaslrseed command on DH i.MX8M Plus DHCOM

PATCH Applied Marek Vasut 3 participants 18 messages Jan 20, 2024 – Apr 30, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: imx: Enable kaslrseed command on DH i.MX8M Plus DHCOM

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

---
Cc: Fabio Estevam <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: [email protected]

---
 configs/imx8mp_dhcom_pdk2_defconfig | 2 ++
 configs/imx8mp_dhcom_pdk3_defconfig | 2 ++
 2 files changed, 4 insertions(+)
configs/imx8mp_dhcom_pdk2_defconfig +2 -0
index 4f907ce00d0..23fb6272ad5 100644
@@ -117,6 +117,7 @@ CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
 CONFIG_CMD_SYSBOOT=y
 CONFIG_CMD_UUID=y
 CONFIG_CMD_PMIC=y
@@ -223,6 +224,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
 CONFIG_SPL_DM_REGULATOR_PCA9450=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_M41T62=y
 CONFIG_CONS_INDEX=2
configs/imx8mp_dhcom_pdk3_defconfig +2 -0
index 9972e2d96b6..0d47c12b1f9 100644
@@ -119,6 +119,7 @@ CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
 CONFIG_CMD_SYSBOOT=y
 CONFIG_CMD_UUID=y
 CONFIG_CMD_PMIC=y
@@ -228,6 +229,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
 CONFIG_SPL_DM_REGULATOR_PCA9450=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_M41T62=y
 CONFIG_CONS_INDEX=2
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Marek Vasut

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

reviewer Applied
#2 lore raw
In reply to Marek Vasut
Quoted 10 lines · Marek Vasut

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

Applied, thanks.

reviewer Applied
#3 lore raw
In reply to Marek Vasut
Quoted 10 lines · Marek Vasut

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

Applied, thanks.

#4 lore raw
In reply to Marek Vasut
Quoted 60 lines · Marek Vasut

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

---
Cc: Fabio Estevam <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: [email protected]

---
 configs/imx8mp_dhcom_pdk2_defconfig | 2 ++
 configs/imx8mp_dhcom_pdk3_defconfig | 2 ++
 2 files changed, 4 insertions(+)
configs/imx8mp_dhcom_pdk2_defconfig +2 -0
index 4f907ce00d0..23fb6272ad5 100644
@@ -117,6 +117,7 @@ CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
 CONFIG_CMD_SYSBOOT=y
 CONFIG_CMD_UUID=y
 CONFIG_CMD_PMIC=y
@@ -223,6 +224,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
 CONFIG_SPL_DM_REGULATOR_PCA9450=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_M41T62=y
 CONFIG_CONS_INDEX=2
configs/imx8mp_dhcom_pdk3_defconfig +2 -1
index 9972e2d96b6..0d47c12b1f9 100644
@@ -119,6 +119,7 @@ CONFIG_CMD_BOOTCOUNT=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
 CONFIG_CMD_SYSBOOT=y
 CONFIG_CMD_UUID=y
 CONFIG_CMD_PMIC=y
@@ -228,6 +229,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
 CONFIG_SPL_DM_REGULATOR_PCA9450=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
 CONFIG_DM_RTC=y
 CONFIG_RTC_M41T62=y
 CONFIG_CONS_INDEX=2
--
Quoted 2 lines

2.43.0

Hi Marek,

Sorry to respond to an old thread but I ran across this when enabling KALSR on my boards.

I have noticed when you enable DM_RNG on IMX8M that SPL fails to bind the driver:
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Didn't you encounter this as well? It seems to me that we may need to add the ability to disable DM_RNG in the SPL unless I'm missing something.

Best Regards,

Tim

#5 lore raw
Quoted 69 lines · Tim Harvey
Quoted 60 lines · Marek Vasut

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

---
Cc: Fabio Estevam <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: [email protected]

---
  configs/imx8mp_dhcom_pdk2_defconfig | 2 ++
  configs/imx8mp_dhcom_pdk3_defconfig | 2 ++
  2 files changed, 4 insertions(+)
configs/imx8mp_dhcom_pdk2_defconfig +2 -0
index 4f907ce00d0..23fb6272ad5 100644
@@ -117,6 +117,7 @@ CONFIG_CMD_BOOTCOUNT=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_TIME=y
  CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
  CONFIG_CMD_SYSBOOT=y
  CONFIG_CMD_UUID=y
  CONFIG_CMD_PMIC=y
@@ -223,6 +224,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
  CONFIG_SPL_DM_REGULATOR_PCA9450=y
  CONFIG_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
  CONFIG_DM_RTC=y
  CONFIG_RTC_M41T62=y
  CONFIG_CONS_INDEX=2
configs/imx8mp_dhcom_pdk3_defconfig +2 -1
index 9972e2d96b6..0d47c12b1f9 100644
@@ -119,6 +119,7 @@ CONFIG_CMD_BOOTCOUNT=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_TIME=y
  CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
  CONFIG_CMD_SYSBOOT=y
  CONFIG_CMD_UUID=y
  CONFIG_CMD_PMIC=y
@@ -228,6 +229,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
  CONFIG_SPL_DM_REGULATOR_PCA9450=y
  CONFIG_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
  CONFIG_DM_RTC=y
  CONFIG_RTC_M41T62=y
  CONFIG_CONS_INDEX=2
--
Quoted 2 lines

2.43.0

Hi Marek,

Sorry to respond to an old thread but I ran across this when enabling KALSR on my boards.

Quoted 6 lines

I have noticed when you enable DM_RNG on IMX8M that SPL fails to bind the driver:
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Did you enable CAAM and ARCH_MISC_INIT on your machine, to initialize CAAM in SPL ?

Quoted 3 lines

Didn't you encounter this as well? It seems to me that we may need to add the ability to disable DM_RNG in the SPL unless I'm missing something.

No, but see above, I suspect that might be it, see also

1f908b1898bd ("ARM: imx8m: Deduplicate CAAM init with arch_misc_init() call")

#6 lore raw
Quoted 76 lines · Marek Vasut
Quoted 74 lines · Tim Harvey
Quoted 60 lines · Marek Vasut

Linux 6.6.y with KASLR enabled would print the following message on boot:
"
KASLR disabled due to lack of seed
"
Enable the 'kaslrseed' command so a random number seed can be pulled from CAAM and inserted into the /chosen node 'kaslr-seed' property of Linux kernel DT before boot, thus letting KASLR work properly.

---
Cc: Fabio Estevam <[email protected]>
Cc: Stefano Babic <[email protected]>
Cc: [email protected]

---
  configs/imx8mp_dhcom_pdk2_defconfig | 2 ++
  configs/imx8mp_dhcom_pdk3_defconfig | 2 ++
  2 files changed, 4 insertions(+)
configs/imx8mp_dhcom_pdk2_defconfig +2 -0
index 4f907ce00d0..23fb6272ad5 100644
@@ -117,6 +117,7 @@ CONFIG_CMD_BOOTCOUNT=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_TIME=y
  CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
  CONFIG_CMD_SYSBOOT=y
  CONFIG_CMD_UUID=y
  CONFIG_CMD_PMIC=y
@@ -223,6 +224,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
  CONFIG_SPL_DM_REGULATOR_PCA9450=y
  CONFIG_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
  CONFIG_DM_RTC=y
  CONFIG_RTC_M41T62=y
  CONFIG_CONS_INDEX=2
configs/imx8mp_dhcom_pdk3_defconfig +2 -1
index 9972e2d96b6..0d47c12b1f9 100644
@@ -119,6 +119,7 @@ CONFIG_CMD_BOOTCOUNT=y
  CONFIG_CMD_CACHE=y
  CONFIG_CMD_TIME=y
  CONFIG_CMD_GETTIME=y
+CONFIG_CMD_KASLRSEED=y
  CONFIG_CMD_SYSBOOT=y
  CONFIG_CMD_UUID=y
  CONFIG_CMD_PMIC=y
@@ -228,6 +229,7 @@ CONFIG_DM_REGULATOR_PCA9450=y
  CONFIG_SPL_DM_REGULATOR_PCA9450=y
  CONFIG_DM_REGULATOR_FIXED=y
  CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_RNG=y
  CONFIG_DM_RTC=y
  CONFIG_RTC_M41T62=y
  CONFIG_CONS_INDEX=2
--
Quoted 2 lines

2.43.0

Hi Marek,

Sorry to respond to an old thread but I ran across this when enabling KALSR on my boards.

I have noticed when you enable DM_RNG on IMX8M that SPL fails to bind the driver:
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

Quoted 4 lines
Quoted 1 line

sec_init failed!

Did you enable CAAM and ARCH_MISC_INIT on your machine, to initialize CAAM in SPL ?

yes

Quoted 9 lines
Quoted 4 lines

Didn't you encounter this as well? It seems to me that we may need to add the ability to disable DM_RNG in the SPL unless I'm missing something.

No, but see above, I suspect that might be it, see also

1f908b1898bd ("ARM: imx8m: Deduplicate CAAM init with arch_misc_init() call")

yes, I have that same patch with
c8645e74113c6 ("configs: imx8m: Prepare imx8m-venice boards for HAB support")

Do you have an IMX8M board on hand to check against to see if you see the same error in the SPL?

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Best Regards,

Tim

reviewer
#7 lore raw

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

#8 lore raw
Quoted 11 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Quoted 8 lines

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

btw. 'no pmic' ? Is that expected ?

reviewer
#9 lore raw

Hi Marek,

Quoted 2 lines · Marek Vasut

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

I tested with mainline TFA 2.10 and also with NXP 2.8. The error happens in both cases.

Quoted 1 line

btw. 'no pmic' ? Is that expected ?

Yes, this is a separate issue. It happens because there are two PMIC variants on the imx8mm evk.

reviewer
#10 lore raw
Quoted 2 lines · Fabio Estevam

I tested with mainline TFA 2.10 and also with NXP 2.8. The error happens in both cases.

I don't get the error if I pass CONFIG_FSL_CAAM_JR_NTZ_ACCESS=y:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 21:46:06 -0300) No pmic

SEC0:  RNG instantiated
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from MMC1
NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.10.3(release):lts-v2.10.3
NOTICE:  BL31: Built : 21:04:50, Apr 15 2024
reviewer
#11 lore raw
Quoted 1 line · Fabio Estevam

I don't get the error if I pass CONFIG_FSL_CAAM_JR_NTZ_ACCESS=y:

Ops, sorry. This is not correct. CONFIG_DM_RNG was unselected. Please discard.

#12 lore raw
In reply to Marek Vasut
Quoted 20 lines · Marek Vasut
Quoted 18 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

Quoted 4 lines
Quoted 1 line

sec_init failed!

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

Marek,

Were you able to reproduce this as well with the board you enabled DM_RNG for? If it does work fine what dtb were you using... perhaps there is something in its u-boot.dtsi that we need?

The error -EPFNOSUPPORT is interesting and helps point to the only place it can be where the comment says the strange errno is to make this easier to find:
https://elixir.bootlin.com/u-boot/latest/source/drivers/core/uclass.c#L70:
if (!uc_drv) {
debug("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

                      id);
                /*
                 * Use a strange error to make this case easier to find. When
                 * a uclass is not available it can prevent driver model from
                 * starting up and this failure is otherwise hard to debug.
                 */
                return -EPFNOSUPPORT;
        }

I'm not very familiar with the dm driver binding - does the U-BOOT_DRIVER usage in drivers/crypto/fsl/rng.c need to be refactored to use UCLASS_DRIVER for it to be usable in both SPL and U-Boot?

Honestly I don't know why we need DM_RNG in SPL anyway and we could just add support for disabling it there to avoid unwanted bloat.

Tim

#13 lore raw
Quoted 23 lines · Tim Harvey
Quoted 22 lines · Marek Vasut
Quoted 19 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Quoted 8 lines
Quoted 2 lines

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

Marek,

Were you able to reproduce this as well with the board you enabled DM_RNG for? If it does work fine what dtb were you using... perhaps there is something in its u-boot.dtsi that we need?

This one arch/arm/dts/imx8mp-dhcom-pdk3.dts , see log below. The build has a few extra patches in it, but nothing which affects the KASLR:

$ export SOURCE_DATE_EPOCH=1672531200 ; echo tst > .scmversion
$ make imx8mp_dhcom_pdk3_defconfig ; make

U-Boot SPL 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

DDR:   4096 MiB [0x5]
DDR:   Inline ECC enabled
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: Primary boot
image offset 0x1000, pagesize 0x1, ivt offset 0x0
NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.10.0  (release):v2.10.0-5-gfb51ca229
NOTICE:  BL31: Built : 20:30:36, Apr 23 2024

U-Boot 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

CPU:   Freescale i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 70C
Reset cause: POR
Model: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3)
DRAM:  3.5 GiB
Core:  183 devices, 34 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected w25q128jw with page size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000

...

Quoted 16 lines

The error -EPFNOSUPPORT is interesting and helps point to the only place it can be where the comment says the strange errno is to make this easier to find:
https://elixir.bootlin.com/u-boot/latest/source/drivers/core/uclass.c#L70:
if (!uc_drv) {
debug("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

                       id);
                 /*
                  * Use a strange error to make this case easier to find. When
                  * a uclass is not available it can prevent driver model from
                  * starting up and this failure is otherwise hard to debug.
                  */
                 return -EPFNOSUPPORT;
         }
Quoted 3 lines

I'm not very familiar with the dm driver binding - does the U-BOOT_DRIVER usage in drivers/crypto/fsl/rng.c need to be refactored to use UCLASS_DRIVER for it to be usable in both SPL and U-Boot?

I don't think you need the CAAM RNG in SPL in the first place, or do you ?

Quoted 2 lines

Honestly I don't know why we need DM_RNG in SPL anyway and we could just add support for disabling it there to avoid unwanted bloat.

I think you can disable it , yes.

#14 lore raw
Quoted 92 lines · Marek Vasut
Quoted 23 lines · Tim Harvey
Quoted 22 lines · Marek Vasut
Quoted 19 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Quoted 8 lines
Quoted 2 lines

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

Marek,

Were you able to reproduce this as well with the board you enabled DM_RNG for? If it does work fine what dtb were you using... perhaps there is something in its u-boot.dtsi that we need?

This one arch/arm/dts/imx8mp-dhcom-pdk3.dts , see log below. The build has a few extra patches in it, but nothing which affects the KASLR:

$ export SOURCE_DATE_EPOCH=1672531200 ; echo tst > .scmversion
$ make imx8mp_dhcom_pdk3_defconfig ; make

U-Boot SPL 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

DDR:   4096 MiB [0x5]
DDR:   Inline ECC enabled
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: Primary boot
image offset 0x1000, pagesize 0x1, ivt offset 0x0
NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.10.0  (release):v2.10.0-5-gfb51ca229
NOTICE:  BL31: Built : 20:30:36, Apr 23 2024

U-Boot 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

CPU:   Freescale i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 70C
Reset cause: POR
Model: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3)
DRAM:  3.5 GiB
Core:  183 devices, 34 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected w25q128jw with page
size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000

...

Quoted 16 lines

The error -EPFNOSUPPORT is interesting and helps point to the only place it can be where the comment says the strange errno is to make this easier to find:
https://elixir.bootlin.com/u-boot/latest/source/drivers/core/uclass.c#L70:
if (!uc_drv) {
debug("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

                       id);
                 /*
                  * Use a strange error to make this case easier to find. When
                  * a uclass is not available it can prevent driver model from
                  * starting up and this failure is otherwise hard to debug.
                  */
                 return -EPFNOSUPPORT;
         }
Quoted 3 lines

I'm not very familiar with the dm driver binding - does the U-BOOT_DRIVER usage in drivers/crypto/fsl/rng.c need to be refactored to use UCLASS_DRIVER for it to be usable in both SPL and U-Boot?

Quoted 6 lines

I don't think you need the CAAM RNG in SPL in the first place, or do you ?

Quoted 2 lines

Honestly I don't know why we need DM_RNG in SPL anyway and we could just add support for disabling it there to avoid unwanted bloat.

I think you can disable it , yes.

Marek,

Would it be advantageous for the kaslr-seed to be added automatically from image_setup_libfdt?

I notice arch/arm/cpu/armv8/fsl-layerscape/fdt.c:ft_cpu_setup does this and board/raspberrypi/rpi/rpi.c looks like it copies kaslr-seed from the control fdt which I assume was added by an earlier layer for that target.

I'm not clear if there is a disadvantage to automatically adding this node if DM_RNG is enabled.

Best Regards,

Tim

#15 lore raw
Quoted 98 lines · Tim Harvey
Quoted 97 lines · Marek Vasut
Quoted 23 lines · Tim Harvey
Quoted 22 lines · Marek Vasut
Quoted 19 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Quoted 8 lines
Quoted 2 lines

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

Marek,

Were you able to reproduce this as well with the board you enabled DM_RNG for? If it does work fine what dtb were you using... perhaps there is something in its u-boot.dtsi that we need?

This one arch/arm/dts/imx8mp-dhcom-pdk3.dts , see log below. The build has a few extra patches in it, but nothing which affects the KASLR:

$ export SOURCE_DATE_EPOCH=1672531200 ; echo tst > .scmversion
$ make imx8mp_dhcom_pdk3_defconfig ; make

U-Boot SPL 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

DDR:   4096 MiB [0x5]
DDR:   Inline ECC enabled
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: Primary boot
image offset 0x1000, pagesize 0x1, ivt offset 0x0
NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.10.0  (release):v2.10.0-5-gfb51ca229
NOTICE:  BL31: Built : 20:30:36, Apr 23 2024

U-Boot 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

CPU:   Freescale i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 70C
Reset cause: POR
Model: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3)
DRAM:  3.5 GiB
Core:  183 devices, 34 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected w25q128jw with page
size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000

...

Quoted 16 lines

The error -EPFNOSUPPORT is interesting and helps point to the only place it can be where the comment says the strange errno is to make this easier to find:
https://elixir.bootlin.com/u-boot/latest/source/drivers/core/uclass.c#L70:
if (!uc_drv) {
debug("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

                        id);
                  /*
                   * Use a strange error to make this case easier to find. When
                   * a uclass is not available it can prevent driver model from
                   * starting up and this failure is otherwise hard to debug.
                   */
                  return -EPFNOSUPPORT;
          }
Quoted 3 lines

I'm not very familiar with the dm driver binding - does the U-BOOT_DRIVER usage in drivers/crypto/fsl/rng.c need to be refactored to use UCLASS_DRIVER for it to be usable in both SPL and U-Boot?

I don't think you need the CAAM RNG in SPL in the first place, or do you ?

Quoted 2 lines

Honestly I don't know why we need DM_RNG in SPL anyway and we could just add support for disabling it there to avoid unwanted bloat.

Quoted 6 lines
Quoted 1 line

I think you can disable it , yes.

Marek,

Would it be advantageous for the kaslr-seed to be added automatically from image_setup_libfdt?

Yes, can you prepare a patch ? (I wanted to do this, just haven't had the time)

Quoted 4 lines

I notice arch/arm/cpu/armv8/fsl-layerscape/fdt.c:ft_cpu_setup does this and board/raspberrypi/rpi/rpi.c looks like it copies kaslr-seed from the control fdt which I assume was added by an earlier layer for that target.

Right, exactly, this .

Quoted 2 lines

I'm not clear if there is a disadvantage to automatically adding this node if DM_RNG is enabled.

I would say, add it.

#16 lore raw
Quoted 115 lines · Marek Vasut
Quoted 98 lines · Tim Harvey
Quoted 97 lines · Marek Vasut
Quoted 23 lines · Tim Harvey
Quoted 22 lines · Marek Vasut
Quoted 19 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Quoted 8 lines
Quoted 2 lines

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

Marek,

Were you able to reproduce this as well with the board you enabled DM_RNG for? If it does work fine what dtb were you using... perhaps there is something in its u-boot.dtsi that we need?

This one arch/arm/dts/imx8mp-dhcom-pdk3.dts , see log below. The build has a few extra patches in it, but nothing which affects the KASLR:

$ export SOURCE_DATE_EPOCH=1672531200 ; echo tst > .scmversion
$ make imx8mp_dhcom_pdk3_defconfig ; make

U-Boot SPL 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

DDR:   4096 MiB [0x5]
DDR:   Inline ECC enabled
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: Primary boot
image offset 0x1000, pagesize 0x1, ivt offset 0x0
NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.10.0  (release):v2.10.0-5-gfb51ca229
NOTICE:  BL31: Built : 20:30:36, Apr 23 2024

U-Boot 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

CPU:   Freescale i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 70C
Reset cause: POR
Model: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3)
DRAM:  3.5 GiB
Core:  183 devices, 34 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected w25q128jw with page
size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000

...

Quoted 16 lines

The error -EPFNOSUPPORT is interesting and helps point to the only place it can be where the comment says the strange errno is to make this easier to find:
https://elixir.bootlin.com/u-boot/latest/source/drivers/core/uclass.c#L70:
if (!uc_drv) {
debug("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

                        id);
                  /*
                   * Use a strange error to make this case easier to find. When
                   * a uclass is not available it can prevent driver model from
                   * starting up and this failure is otherwise hard to debug.
                   */
                  return -EPFNOSUPPORT;
          }
Quoted 3 lines

I'm not very familiar with the dm driver binding - does the U-BOOT_DRIVER usage in drivers/crypto/fsl/rng.c need to be refactored to use UCLASS_DRIVER for it to be usable in both SPL and U-Boot?

I don't think you need the CAAM RNG in SPL in the first place, or do you ?

Quoted 2 lines

Honestly I don't know why we need DM_RNG in SPL anyway and we could just add support for disabling it there to avoid unwanted bloat.

Quoted 6 lines
Quoted 1 line

I think you can disable it , yes.

Marek,

Would it be advantageous for the kaslr-seed to be added automatically from image_setup_libfdt?

Yes, can you prepare a patch ? (I wanted to do this, just haven't had the time)

Quoted 4 lines

I notice arch/arm/cpu/armv8/fsl-layerscape/fdt.c:ft_cpu_setup does this and board/raspberrypi/rpi/rpi.c looks like it copies kaslr-seed from the control fdt which I assume was added by an earlier layer for that target.

Quoted 6 lines

Right, exactly, this .

Quoted 2 lines

I'm not clear if there is a disadvantage to automatically adding this node if DM_RNG is enabled.

I would say, add it.

Yes, I'll submit something this week.

Best Regards,

Tim

#17 lore raw
Quoted 116 lines · Tim Harvey
Quoted 115 lines · Marek Vasut
Quoted 98 lines · Tim Harvey
Quoted 97 lines · Marek Vasut
Quoted 23 lines · Tim Harvey
Quoted 22 lines · Marek Vasut
Quoted 19 lines · Fabio Estevam

Hi Tim,

Quoted 6 lines · Tim Harvey

Fabio, if you enable CONFIG_DM_RNG on an imx8m{m,p}_evk do you get the following in the SPL?
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Yes, if I add CONFIG_DM_RNG=y to imx8mm_evk_defconfig I get:

U-Boot SPL 2024.04-00793-g3434b88d2c2f-dirty (Apr 18 2024 - 14:58:57 -0300) No pmic
Couldn't bind rng driver (-96)
SEC0: RNG instantiated

sec_init failed!

Quoted 8 lines
Quoted 2 lines

Interesting. Which TFA blob version do you use ? I used the mainline 2.10 for my tests.

Marek,

Were you able to reproduce this as well with the board you enabled DM_RNG for? If it does work fine what dtb were you using... perhaps there is something in its u-boot.dtsi that we need?

This one arch/arm/dts/imx8mp-dhcom-pdk3.dts , see log below. The build has a few extra patches in it, but nothing which affects the KASLR:

$ export SOURCE_DATE_EPOCH=1672531200 ; echo tst > .scmversion
$ make imx8mp_dhcom_pdk3_defconfig ; make

U-Boot SPL 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

DDR:   4096 MiB [0x5]
DDR:   Inline ECC enabled
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
Trying to boot from BOOTROM
Boot Stage: Primary boot
image offset 0x1000, pagesize 0x1, ivt offset 0x0
NOTICE:  Do not release JR0 to NS as it can be used by HAB
NOTICE:  BL31: v2.10.0  (release):v2.10.0-5-gfb51ca229
NOTICE:  BL31: Built : 20:30:36, Apr 23 2024

U-Boot 2024.07-rc1tst (Jan 01 2023 - 00:00:00 +0000)

CPU:   Freescale i.MX8MP[8] rev1.1 1600 MHz (running at 1200 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 70C
Reset cause: POR
Model: DH electronics i.MX8M Plus DHCOM Premium Developer Kit (3)
DRAM:  3.5 GiB
Core:  183 devices, 34 uclasses, devicetree: separate
WDT:   Started watchdog@30280000 with servicing every 1000ms (60s timeout)
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
Loading Environment from SPIFlash... SF: Detected w25q128jw with page
size 256 Bytes, erase size 4 KiB, total 16 MiB
OK
In:    serial
Out:   serial
Err:   serial
SEC0:  RNG instantiated
Net:   eth1: ethernet@30be0000, eth0: ethernet@30bf0000

...

Quoted 16 lines

The error -EPFNOSUPPORT is interesting and helps point to the only place it can be where the comment says the strange errno is to make this easier to find:
https://elixir.bootlin.com/u-boot/latest/source/drivers/core/uclass.c#L70:
if (!uc_drv) {
debug("Cannot find uclass for id %d: please add the
UCLASS_DRIVER() declaration for this UCLASS_... id\n",

                         id);
                   /*
                    * Use a strange error to make this case easier to find. When
                    * a uclass is not available it can prevent driver model from
                    * starting up and this failure is otherwise hard to debug.
                    */
                   return -EPFNOSUPPORT;
           }
Quoted 3 lines

I'm not very familiar with the dm driver binding - does the U-BOOT_DRIVER usage in drivers/crypto/fsl/rng.c need to be refactored to use UCLASS_DRIVER for it to be usable in both SPL and U-Boot?

I don't think you need the CAAM RNG in SPL in the first place, or do you ?

Quoted 2 lines

Honestly I don't know why we need DM_RNG in SPL anyway and we could just add support for disabling it there to avoid unwanted bloat.

Quoted 6 lines
Quoted 1 line

I think you can disable it , yes.

Marek,

Would it be advantageous for the kaslr-seed to be added automatically from image_setup_libfdt?

Yes, can you prepare a patch ? (I wanted to do this, just haven't had the time)

Quoted 4 lines

I notice arch/arm/cpu/armv8/fsl-layerscape/fdt.c:ft_cpu_setup does this and board/raspberrypi/rpi/rpi.c looks like it copies kaslr-seed from the control fdt which I assume was added by an earlier layer for that target.

Quoted 8 lines
Quoted 6 lines

Right, exactly, this .

Quoted 2 lines

I'm not clear if there is a disadvantage to automatically adding this node if DM_RNG is enabled.

I would say, add it.

Yes, I'll submit something this week.

Thank you, much appreciated.