[U-Boot] CONFIG_ARMV7_NONSEC on altera soc (alignment issues ?)

Hi
I am currently trying to configure either Altera Soc and Xilinx Zynq to boot Linux in nonsecure-mode. This mail focusses on the Altera SOC.
As soon as the u-boot switched to normal mode it seems there is a problem with code alignment handling? At least it seems the code which is running beforehand stops working in normal mode and stops in either data_abort or prefetch handler. It stopps working when it hits the call to stdio_devices[file]->puts(s); in console_puts (console.c:255).
print *stdio_devices[file] $2 = {flags = 16978471, ext = 16978464, name = "$\022\003\001\202\022\003\001\360\031\003\001\020\060\220", <incomplete sequence \345>, start = 0xe92d4070, stop = 0xe2806010, putc = 0xe1530006, puts = 0xe1a04000, tstc = 0xe1a05001, getc = 0xe5810024, priv = 0x1a000007, list = { next = 0xe5831004, prev = 0xe5813000}}
As there are unaligned addresses (putc?) in these function calls i have the impression that this is not working in normal mode but in secure mode.
Unfortunatly i was not able to get the mainline u-boot to boot on the altera soc so i patched the altera release: git://git.rocketboards.org/u-boot-socfpga.git with the 1740999a39ea4217bf926002d10869c0d925a5dc aka socfpga_v2013.01.01-rel branch.
As the altera u-boot release socfpga_v2013.01.01-rel is to old to have the CONFIG_ARMV7_NONSEC patches i cherry-picked the following patches: d4296887544ddf95808bfb62f312008f519efb7b extend non-secure switch to also go into HYP mode ba6a1698116da272f14c53a3ae41467cb7fc4372 add SMP support for non-secure switch bb975455650b1f36681de31a93ffe54952ed3a6b trigger non-secure state switch during bootm execution 1ef923851ab8ffcc4265fd991815b88d9c1f12d7 add C function to switch to non-secure state 16212b594f385bd594d5d316bf11b13c1186e3d7 add assembly routine to switch to non-secure state 45b940d6f9a9d4989452ea67480e299bfa51ee19 add secure monitor handler to switch to non-secure state d75ba503a972df09784f1a332ba356ef8b42a0a6 ARM: prepare armv7.h to be included from assembly source
I also applied the attached hacked together patches to get the system running and fix up the stack pointer in normal mode as it pointed to 0.
Best regards Tim

Hi Tim,
On Wed, 26 Mar 2014 15:25:33 +0100, Tim Sander tim@krieglstein.org wrote:
Hi
I am currently trying to configure either Altera Soc and Xilinx Zynq to boot Linux in nonsecure-mode. This mail focusses on the Altera SOC.
As soon as the u-boot switched to normal mode it seems there is a problem with code alignment handling? At least it seems the code which is running beforehand stops working in normal mode and stops in either data_abort or prefetch handler. It stopps working when it hits the call to stdio_devices[file]->puts(s); in console_puts (console.c:255).
print *stdio_devices[file] $2 = {flags = 16978471, ext = 16978464, name = "$\022\003\001\202\022\003\001\360\031\003\001\020\060\220", <incomplete sequence \345>, start = 0xe92d4070, stop = 0xe2806010, putc = 0xe1530006, puts = 0xe1a04000, tstc = 0xe1a05001, getc = 0xe5810024, priv = 0x1a000007, list = { next = 0xe5831004, prev = 0xe5813000}}
As there are unaligned addresses (putc?) in these function calls i have the impression that this is not working in normal mode but in secure mode.
Unfortunatly i was not able to get the mainline u-boot to boot on the altera soc so i patched the altera release: git://git.rocketboards.org/u-boot-socfpga.git with the 1740999a39ea4217bf926002d10869c0d925a5dc aka socfpga_v2013.01.01-rel branch.
As the altera u-boot release socfpga_v2013.01.01-rel is to old to have the CONFIG_ARMV7_NONSEC patches i cherry-picked the following patches: d4296887544ddf95808bfb62f312008f519efb7b extend non-secure switch to also go into HYP mode ba6a1698116da272f14c53a3ae41467cb7fc4372 add SMP support for non-secure switch bb975455650b1f36681de31a93ffe54952ed3a6b trigger non-secure state switch during bootm execution 1ef923851ab8ffcc4265fd991815b88d9c1f12d7 add C function to switch to non-secure state 16212b594f385bd594d5d316bf11b13c1186e3d7 add assembly routine to switch to non-secure state 45b940d6f9a9d4989452ea67480e299bfa51ee19 add secure monitor handler to switch to non-secure state d75ba503a972df09784f1a332ba356ef8b42a0a6 ARM: prepare armv7.h to be included from assembly source
I also applied the attached hacked together patches to get the system running and fix up the stack pointer in normal mode as it pointed to 0.
Best regards Tim
So this is not a patch for mainline U-Boot, right?
Amicalement,

Hi Albert
I am currently trying to configure either Altera Soc and Xilinx Zynq to boot Linux in nonsecure-mode. This mail focusses on the Altera SOC.
As soon as the u-boot switched to normal mode it seems there is a problem with code alignment handling? At least it seems the code which is running beforehand stops working in normal mode and stops in either data_abort or prefetch handler. It stopps working when it hits the call to stdio_devices[file]->puts(s); in console_puts (console.c:255).
print *stdio_devices[file] $2 = {flags = 16978471, ext = 16978464, name = "$\022\003\001\202\022\003\001\360\031\003\001\020\060\220", <incomplete sequence \345>,> start = 0xe92d4070, stop = 0xe2806010, putc = 0xe1530006, puts = 0xe1a04000, tstc = 0xe1a05001, getc = 0xe5810024, priv = 0x1a000007, list = { next = 0xe5831004, prev = 0xe5813000}}> As there are unaligned addresses (putc?) in these function calls i have the impression that this is not working in normal mode but in secure mode.
Unfortunatly i was not able to get the mainline u-boot to boot on the altera soc so i patched the altera release: git://git.rocketboards.org/u-boot-socfpga.git with the 1740999a39ea4217bf926002d10869c0d925a5dc aka socfpga_v2013.01.01-rel branch.
As the altera u-boot release socfpga_v2013.01.01-rel is to old to have the CONFIG_ARMV7_NONSEC patches i cherry-picked the following patches: d4296887544ddf95808bfb62f312008f519efb7b extend non-secure switch to also go into HYP mode ba6a1698116da272f14c53a3ae41467cb7fc4372 add SMP support for non-secure switch bb975455650b1f36681de31a93ffe54952ed3a6b trigger non-secure state switch during bootm execution 1ef923851ab8ffcc4265fd991815b88d9c1f12d7 add C function to switch to non-secure state 16212b594f385bd594d5d316bf11b13c1186e3d7 add assembly routine to switch to non-secure state 45b940d6f9a9d4989452ea67480e299bfa51ee19 add secure monitor handler to switch to non-secure state d75ba503a972df09784f1a332ba356ef8b42a0a6
ARM:
prepare armv7.h to be included from assembly source
I also applied the attached hacked together patches to get the system running and fix up the stack pointer in normal mode as it pointed to 0.
Best regards Tim
So this is not a patch for mainline U-Boot, right?
Unfortunatly not. The altera branch is from an older version and i had problems booting mainline. So i went the other way round and used the altera git release and cherry picked the patches of which i thought that would be needed for switching to normal world. This works but as soon as i print out something in u-boot ("Booting linux") or if thats commented out, booting linux i get a access violation. So i either get in the prefetch or abort handler. As i don't know where the TrustZone registers are nor what they do, i have a hard time moving on with this. So these patches are just very experimental and got me as far as booting into early linux. I have the suscpicion that the serial port, and probably other hw is only writable from secure world so one would need a monitor running to have access to this hw (If it can not be switched to be accessible from normal world). Further with the stack pointer not set up in normal world i have no idea how the versatile express should work without setting the stack.
Best regards Tim
participants (2)
-
Albert ARIBAUD
-
Tim Sander