Skip to contentSkip to conversation

colibri_imx7: boot kernel in secure mode

PATCH New Igor Opaniuk 6 participants 13 messages Jul 3, 2019 – Aug 1, 2019 Arm i.MX and Layerscape

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/colibri_imx7.h +2 -1
index 40173b18fa..5408577661 100644
@@ -164,7 +164,8 @@
 		"${board}/flash_blk.img && source ${loadaddr}\0" \
 	"setup=setenv setupargs " \
 		"console=tty1 console=${console}" \
-		",${baudrate}n8 ${memargs} consoleblank=0\0" \
+		",${baudrate}n8 ${memargs} consoleblank=0; " \
+		"setenv bootm_boot_mode sec\0" \
 	"setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
 	"setusbupdate=usb start && setenv interface usb && " \
 		"fatload ${interface} 0:1 ${loadaddr} " \
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Quoted 9 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

Quoted 19 lines

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/colibri_imx7.h +2 -1
index 40173b18fa..5408577661 100644
@@ -164,7 +164,8 @@
 		"${board}/flash_blk.img && source ${loadaddr}\0" \
 	"setup=setenv setupargs " \
 		"console=tty1 console=${console}" \
-		",${baudrate}n8 ${memargs} consoleblank=0\0" \
+		",${baudrate}n8 ${memargs} consoleblank=0; " \
+		"setenv bootm_boot_mode sec\0" \
 	"setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
 	"setusbupdate=usb start && setenv interface usb && " \
 		"fatload ${interface} 0:1 ${loadaddr} " \
#2 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Quoted 8 lines
Quoted 8 lines

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel
uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

How does enabling both cores work in upstream kernel? It looks like PSCI does not work in secure mode using mainline 4.19 LTS kernel. Any hints? Until this is resolved booting in secure mode per default IMHO is not a good option.

Best regards

Tobias

#3 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Quoted 9 lines · Tobias Junghans
Quoted 8 lines
Quoted 8 lines

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel
uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

Quoted 7 lines

How does enabling both cores work in upstream kernel? It looks like PSCI does not work in secure mode using mainline 4.19 LTS kernel. Any hints? Until this is resolved booting in secure mode per default IMHO is not a good option.

Best regards

Tobias

Hi Tobias,

I just tried it again and it works also with 4.19 LTS and 'bootm_boot_mode sec' on my side.

Quoted 2 lines
#4 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

In reply to Tobias Junghans

Hi Tobias,

Quoted 10 lines · Tobias Junghans
Quoted 9 lines
Quoted 9 lines

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel
uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

Quoted 9 lines

How does enabling both cores work in upstream kernel? It looks like PSCI does not work in secure mode using mainline 4.19 LTS kernel. Any hints? Until this is resolved booting in secure mode per default IMHO is not a good option.

Best regards

Tobias

I'm afraid you're right.
Just after a bit of time researching and discussing with Stefan, seems that we need to introduce two different wrappers for booting the mainline kernel and downstream NXP kernel.

* NXP kernel has legacy code to enable all cores, which works only when running in secure mode.
* Mainline kernel, as you said before, does use PSCI for this, which is provided by U-boot (which adds proper psci nodes to the linux dtb on-fly before transferring control to the linux kernel entry point). When we try to load it in secure mode, it continues running on the same Secure PL1, and communication using SMC calling convention doesn't make sense at this case.

Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#5 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Hi Igor,

thanks for your comments! Is there any solution, patch or workaround I can try to power on the 2nd CPU core in secure mode with mainline kernel?

Thanks and best regards

Tobias

Quoted 13 lines

I'm afraid you're right.
Just after a bit of time researching and discussing with Stefan, seems that we need to introduce two different wrappers for booting the mainline kernel and downstream NXP kernel.

* NXP kernel has legacy code to enable all cores, which works only when running in secure mode.
* Mainline kernel, as you said before, does use PSCI for this, which is provided by U-boot (which adds proper psci nodes to the linux dtb on-fly before transferring control to the linux kernel entry point). When we try to load it in secure mode, it continues running on the same Secure PL1, and communication using SMC calling convention doesn't make sense at this case.

#6 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Quoted 6 lines

Subject: Re: [U-Boot] [PATCH v1] colibri_imx7: boot kernel in secure mode

Hi Igor,

thanks for your comments! Is there any solution, patch or workaround I can try to power on the 2nd CPU core in secure mode with mainline kernel?

The upstream maintainer rejected the legacy method for i.MX7, so in upstream psci was used, with psci, the kernel is booted in non-secure mode.

Regards,
Peng.

Quoted 20 lines

Thanks and best regards

Tobias

Quoted 13 lines

I'm afraid you're right.
Just after a bit of time researching and discussing with Stefan, seems that we need to introduce two different wrappers for booting the mainline kernel and downstream NXP kernel.

* NXP kernel has legacy code to enable all cores, which works only when running in secure mode.
* Mainline kernel, as you said before, does use PSCI for this, which is provided by U-boot (which adds proper psci nodes to the linux dtb on-fly before transferring control to the linux kernel entry point). When we try to load it in secure mode, it continues running on the same Secure PL1, and communication using SMC calling convention doesn't make sense at this case.

#7 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

In reply to Tobias Junghans
Quoted 4 lines · Tobias Junghans

Hi Igor,

thanks for your comments! Is there any solution, patch or workaround I can try to power on the 2nd CPU core in secure mode with mainline kernel?

I am afraid that is not possible since without PSCI mainline simply lacks the code how to enable the secondary CPU. You cannot use PSCI and stay in secure mode.

Anyway, why would you want to boot in secure mode anyway? With non-secure mode your CPU has more features, e.g. you can actually use virtualization feature (HYP). You do not have that in secure mode.

Booting in non-secure mode is the proper way(tm) to boot on this CPU.

That CAAM issue is unfortunate. But I think it is possible to enable CAAM access in non-secure mode by making sure to write the proper registers while being still in secure mode.

--
Stefan

Quoted 25 lines

Thanks and best regards

Tobias

Quoted 5 lines

I'm afraid you're right.
Just after a bit of time researching and discussing with Stefan, seems that we need to introduce two different wrappers for booting the mainline kernel and downstream NXP kernel.

Quoted 8 lines

* NXP kernel has legacy code to enable all cores, which works only when running in secure mode.
* Mainline kernel, as you said before, does use PSCI for this, which is provided by U-boot (which adds proper psci nodes to the linux dtb on-fly before transferring control to the linux kernel entry point). When we try to load it in secure mode, it continues running on the same Secure PL1, and communication using SMC calling convention doesn't make sense at this case.

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#8 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

In reply to Philippe Schenker
Quoted 7 lines · Philippe Schenker
Quoted 6 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel uses PSCI for this).

Quoted 6 lines
Quoted 3 lines

As we're using NXP kernel in our BSPs, lets enable this by default.

Please ignore my Reviewed-by and Tested-by. I Tested it on downstream which works fine but on mainline only one core comes up by design. I wasn't aware of that.

Philippe

Quoted 24 lines
Quoted 11 lines

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/colibri_imx7.h +0 -0
index 40173b18fa..5408577661 100644

include/configs/colibri_imx7.h line 171

Quoted 9 lines
include/configs/colibri_imx7.h +2 -1
@@ -164,7 +164,8 @@
 		"${board}/flash_blk.img && source ${loadaddr}\0" \
 	"setup=setenv setupargs " \
 		"console=tty1 console=${console}" \
-		",${baudrate}n8 ${memargs} consoleblank=0\0" \
+		",${baudrate}n8 ${memargs} consoleblank=0; " \
+		"setenv bootm_boot_mode sec\0" \
 	"setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
 	"setusbupdate=usb start && setenv interface usb && " \
 		"fatload ${interface} 0:1 ${loadaddr} " \

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#9 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

In reply to Igor Opaniuk
Quoted 7 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

I think I mentioned it internally, but just to be clear: I do not agree with this patch.

Upstream U-Boot should be able to boot upstream Linux. I'd rather prefer to carry that patch in our downstream fork (or set the bootm_boot_mode environment in our boot script).

--
Stefan

Quoted 21 lines

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/colibri_imx7.h +2 -1
index 40173b18fa..5408577661 100644
@@ -164,7 +164,8 @@
 		"${board}/flash_blk.img && source ${loadaddr}\0" \
 	"setup=setenv setupargs " \
 		"console=tty1 console=${console}" \
-		",${baudrate}n8 ${memargs} consoleblank=0\0" \
+		",${baudrate}n8 ${memargs} consoleblank=0; " \
+		"setenv bootm_boot_mode sec\0" \
 	"setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
 	"setusbupdate=usb start && setenv interface usb && " \
 		"fatload ${interface} 0:1 ${loadaddr} " \
#10 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Hi Stefan

Quoted 8 lines · Stefan Agner
Quoted 6 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel uses PSCI for this).

Quoted 8 lines
Quoted 1 line

As we're using NXP kernel in our BSPs, lets enable this by default.

I think I mentioned it internally, but just to be clear: I do not agree with this patch.

Upstream U-Boot should be able to boot upstream Linux. I'd rather prefer to carry that patch in our downstream fork (or set the bootm_boot_mode environment in our boot script).

Totally agree with you here,
BTW, seems that Stefano has applied by mistake to u-boot-imx fcc79eee14("colibri_imx7_emmc: enable CONFIG_ARMV7_BOOT_SEC_DEFAULT"), although I've asked to ignore it.

Probably will send another patch that reverts this.

Quoted 25 lines

--
Stefan

Quoted 21 lines

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/colibri_imx7.h +2 -1
index 40173b18fa..5408577661 100644
@@ -164,7 +164,8 @@
              "${board}/flash_blk.img && source ${loadaddr}\0" \
      "setup=setenv setupargs " \
              "console=tty1 console=${console}" \
-             ",${baudrate}n8 ${memargs} consoleblank=0\0" \
+             ",${baudrate}n8 ${memargs} consoleblank=0; " \
+             "setenv bootm_boot_mode sec\0" \
      "setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
      "setusbupdate=usb start && setenv interface usb && " \
              "fatload ${interface} 0:1 ${loadaddr} " \
Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations

Igor Opaniuk

mailto: igor.opaniuk at gmail.com
skype: igor.opanyuk
+380 (93) 836 40 67
http://ua.linkedin.com/in/iopaniuk
#11 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Quoted 16 lines · Igor Opaniuk

Hi Stefan

Quoted 13 lines · Stefan Agner
Quoted 7 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream kernel uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

I think I mentioned it internally, but just to be clear: I do not agree with this patch.

Quoted 8 lines
Quoted 3 lines

Upstream U-Boot should be able to boot upstream Linux. I'd rather prefer to carry that patch in our downstream fork (or set the bootm_boot_mode environment in our boot script).

Totally agree with you here,
BTW, seems that Stefano has applied by mistake to u-boot-imx fcc79eee14("colibri_imx7_emmc: enable CONFIG_ARMV7_BOOT_SEC_DEFAULT"), although I've asked to ignore it.

Sorry for this - I have taken a look and I drop this one but I took fcc79eee14. Should I simply revert it on u-boot-imx (you do not need to send a patch, then)?

Regards,
Stefano

Quoted 31 lines

Probably will send another patch that reverts this.

Quoted 25 lines

--
Stefan

Quoted 21 lines

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/configs/colibri_imx7.h +2 -1
index 40173b18fa..5408577661 100644
@@ -164,7 +164,8 @@
              "${board}/flash_blk.img && source ${loadaddr}\0" \
      "setup=setenv setupargs " \
              "console=tty1 console=${console}" \
-             ",${baudrate}n8 ${memargs} consoleblank=0\0" \
+             ",${baudrate}n8 ${memargs} consoleblank=0; " \
+             "setenv bootm_boot_mode sec\0" \
      "setupdate=run setsdupdate || run setusbupdate || run setethupdate\0" \
      "setusbupdate=usb start && setenv interface usb && " \
              "fatload ${interface} 0:1 ${loadaddr} " \
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#12 lore raw

PATCH 1/1 colibri_imx7: boot kernel in secure mode

Hi Stefano,

Quoted 22 lines · On Thu, Aug 1, 2019, 16:19 Stefano Babic <[email protected]> wrote:
Quoted 9 lines · Igor Opaniuk

Hi Stefan

Quoted 6 lines · Stefan Agner
Quoted 4 lines · Igor Opaniuk

From: Igor Opaniuk <[email protected]>

NXP downstream kernel uses legacy method to enable other cores, which requires kernel to run in a security mode (althought upstream

kernel

Quoted 11 lines
Quoted 10 lines
Quoted 3 lines

uses PSCI for this).

As we're using NXP kernel in our BSPs, lets enable this by default.

I think I mentioned it internally, but just to be clear: I do not agree with this patch.

Upstream U-Boot should be able to boot upstream Linux. I'd rather prefer to carry that patch in our downstream fork (or set the bootm_boot_mode environment in our boot script).

Quoted 9 lines
Quoted 4 lines

Totally agree with you here,
BTW, seems that Stefano has applied by mistake to u-boot-imx fcc79eee14("colibri_imx7_emmc: enable CONFIG_ARMV7_BOOT_SEC_DEFAULT"), although I've asked to ignore it.

Sorry for this - I have taken a look and I drop this one but I took fcc79eee14. Should I simply revert it on u-boot-imx (you do not need to send a patch, then)?

Yes, please revert this patch, as it brakes boot of the mainline kernel. Thanks!

Quoted 45 lines

Regards,
Stefano

Quoted 8 lines

Probably will send another patch that reverts this.

Quoted 5 lines

--
Stefan

Quoted 1 line
Quoted 7 lines
Quoted 7 lines

Review

Quoted 7 lines

---

 include/configs/colibri_imx7.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/configs/colibri_imx7.h

Quoted 11 lines
Quoted 11 lines

include/configs/colibri_imx7.h line 169

Quoted 11 lines

index 40173b18fa..5408577661 100644

include/configs/colibri_imx7.h +2 -1
@@ -164,7 +164,8 @@
              "${board}/flash_blk.img && source ${loadaddr}\0" \
      "setup=setenv setupargs " \
              "console=tty1 console=${console}" \
-             ",${baudrate}n8 ${memargs} consoleblank=0\0" \
+             ",${baudrate}n8 ${memargs} consoleblank=0; " \
+             "setenv bootm_boot_mode sec\0" \
      "setupdate=run setsdupdate || run setusbupdate || run

setethupdate\0" \

Quoted 5 lines
Quoted 2 lines

include/configs/colibri_imx7.h line 171

Quoted 2 lines
include/configs/colibri_imx7.h +0 -0
      "setusbupdate=usb start && setenv interface usb && " \
              "fatload ${interface} 0:1 ${loadaddr} " \

--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================