I am trying to port Linux for i.MX6Q (SabreSD with NXP/Freescale's kernel or SabreLite with Boundary Devices kernel, we have the same issue on both) from running in the secure world to the normal world. To make things simple at first:
- we configured the whole board (CSU/AIPSTZ/NSACR, ...) to allow access from secure and non secure world (especially, the SRC is accessible to Linux in the normal world)
- access to cp15/SCU which are impossible from the Normal World have been fixed by issuing smc to our monitor
In this setup:
- original kernel correctly boots Linux in the Secure World with 4 cores running
- patched kernel without SMP support correctly runs Linux in the Normal World with 1 core running
- patched kernel with SMP support runs Linux in the Normal World with only 1 core, the other 3 failed to start (CPUN: failed to come online)
From my experience with QoirQ boards, I realized that we failed at properly configuring the secondary cores, so I added the following configuration to the secure kernel to initialize secondary cores:
- the part of the GICC/GICD only available to the secondary cores are correctly initialized "per core" (SGI/PPI/SPI to non secure, using IRQ, not FIQ)
- NSACR "per core" is set to 0x43FFFF
- Cortex A9 Diagnostic register is set to the same value as core 0
Then the secondary cores enters a waiting loop (based on wfi) waiting for the relevant SRC_GPR register to be setup by Linux. Finally, Linux wakes up the core by sending a wakeup IPI.
With this modification, the secondary cores are coming online (CPUN: Booted secondary processor), but Linux fails (most of the time silently) to boot. The best situation I can reach is (CPU0: stopping is to relevant, it can be CPU1, CPU2, ...)
imx mcc test is registered. snvs_rtc 20cc034.snvs-rtc-lp: setting system clock to 1970-01-01 00:00:00 UTC (0) ALSA device list: #0: imx6q-sabrelite-sgtl5000 #1: imx-hdmi-soc Freeing unused kernel memory: 272K (80841000 - 80885000) *** Error in `/bin/sh': free(): invalid next size (normal): 0x003e8078 *** Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00 CPU0: stopping CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.14.28-gb821ffaf-dirty #15 Backtrace: [<80011ab4>] (dump_backtrace) from [<80011ccc>] (show_stack+0x18/0x1c) r6:808a1e04 r5:ffffffff r4:00000000 r3:00000000 [<80011cb4>] (show_stack) from [<80633598>] (dump_stack+0x84/0xc4) [<80633514>] (dump_stack) from [<800148bc>] (handle_IPI+0x178/0x18c) r6:80884e24 r5:00000005 r4:00000000 r3:80886000 [<80014744>] (handle_IPI) from [<800085a4>] (gic_handle_irq+0x60/0x64) r8:80886000 r7:f4a00100 r6:80887f30 r5:8088e948 r4:f4a0010c r3:8000f1ec [<80008544>] (gic_handle_irq) from [<80012840>] (__irq_svc+0x40/0x70) Exception stack(0x80887f30 to 0x80887f78) 7f20: 00000000 00000000 00000001 8001dfa0 7f40: 8088e570 8063b2bc 80886000 808c96eb 80886000 80886000 00000001 80887f84 7f60: 80887f88 80887f78 8000f1ec 8000f1f0 600c0013 ffffffff r7:80887f64 r6:ffffffff r5:600c0013 r4:8000f1f0 [<8000f1b0>] (arch_cpu_idle) from [<800695cc>] (cpu_startup_entry+0x10c/0x15c) [<800694c0>] (cpu_startup_entry) from [<8062f428>] (rest_init+0x8c/0x90) r7:8088e480 r3:80886000 [<8062f39c>] (rest_init) from [<80841bac>] (start_kernel+0x368/0x374) r4:8088e608 r3:80886000 [<80841844>] (start_kernel) from [<10008074>] (0x10008074)
One time, I got a login prompt, but every key input made the login reset and I could't log in.
I am waiting for Boundary Devices jtag adapter to try to understand what's happening, but if anyone has suggestions on things I might have missed, I would be grateful