Skip to contentSkip to conversation

RFD: ARM: enable HYP mode on OMAP5

U-Boot New Ian Molton 2 participants 2 messages Nov 27, 2012 – Feb 19, 2013 Arm (32-bit)

lore
Share & tools
lore

Ian Molton

author
#0 lore raw

Hi folks,

My colleague Clemens Fischer, and I were able to bring up the OMAP5 CPU in HYP mode with the following patch to u-boot.

Obviously the patch is not production grade yet, but we feel that it would be of use to discuss how best to integrate the code into u-boot.

The code wakes up CPU1 before putting CPU0 into HYP mode, and CPU1 goes back to sleep once it has entered HYP mode itself.

With this patch, a near-unmodified mainline linux kernel (patched for ARM KVM only) will boot up with HYP mode enabled.

Many thanks to Marc and Christoffer for their help getting KVM up and running!

Comments are welcome.

-Ian

#1 lore raw

PATCH 1/1 Fix omap5 hyp mode for second cpu

Make it work on PandaBoard 5 with 5432 ES2 and Linux.

---

Hi,

Here are some necessary adaptations for OMAP5 ES2, as magic value has changed. In the mean time, we make the secondary cpu routine a bit closer to what romcode does.

Best regards,

V.

 arch/arm/lib/bootm.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
arch/arm/lib/bootm.c +12 -7
index 02852d6..dd8f42e 100644
@@ -56,16 +56,21 @@ asm (
 		"ldr r12, =0x102\n"
 		"mov r0, pc\n"
 		"smc 0x1\n"
-		"ldr r1, =0x48281804\n" // AUX_CORE_BOOT_1
+		"ldr r1, =0x48281800\n" /* AUX_CORE_BOOT_0 */
 		"mov r2, #0\n"
-		"str r2, [r1]\n"
+		"str r2, [r1]\n"	/* AUX_CORE_BOOT_0 */
+		"str r2, [r1, #4]\n"	/* AUX_CORE_BOOT_1 */
 		"isb\n"
 		"dsb\n"
+		"mov r3, #0xf0\n"
 		"1: wfe\n"
-		"ldr r2, [r1]\n"
-		"cmp r2, #0\n"
-		"movne pc, r2\n"
-		"b 1b\n"
+		"ldr  r2, [r1]\n"	/* AUX_CORE_BOOT_0 */
+		"ands r2, r2, r3\n"
+		"beq  1b\n"
+		"ldr  r2, [r1, #4]\n"	/* AUX_CORE_BOOT_1 */
+		"cmp  r2, #0\n"
+		"beq  1b\n"
+		"bx   r2\n"
 	".popsection\n"
 );
 
@@ -378,7 +383,7 @@ void hyp_enable(void) {
 		"ldr r1, =0x48281800\n"     // AUX_CORE_BOOT_1
 		"ldr r2, =__hyp_init_sec\n"
 		"str r2, [r1, #4]\n"
-		"mov r2, #0x200\n"
+		"mov r2, #0x20\n"
 		"str r2, [r1]\n"            // AUX_CORE_BOOT_0
 		"isb\n"
 		"dmb\n"
Signature · 1 line
1.7.9.5