Skip to content

Commit fa036ea

Browse files
Lennart Sorensengregkh
authored andcommitted
ARM: omap5/dra7xx: Enable booting secondary CPU in HYP mode
commit 999f934 upstream. If the boot loader enables HYP mode on the boot CPU, the secondary CPU also needs to call into the ROM to switch to HYP mode before booting. The firmwares on the omap5 and dra7xx unfortunately do not take care of this, so it has to be handled by the kernel. This patch is based on "[PATCH 2/2] ARM: OMAP5: Add HYP mode entry support for secondary CPUs" by Santosh Shilimkar <santosh.shilimkar@ti.com>, except this version does not require a compile time CONFIG to control if it should enable HYP mode or not, it simply does it based on the mode of the boot CPU, so it works whether the CPU boots in SVC or HYP mode, and should even work as a guest kernel inside kvm if qemu decides to support emulating the omap5 or dra7xx. Signed-off-by: Len Sorensen <lsorense@csclub.uwaterloo.ca> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3af7a88 commit fa036ea

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

‎arch/arm/mach-omap2/common.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ extern void omap4_cpu_die(unsigned int cpu);
249249
extern struct smp_operations omap4_smp_ops;
250250

251251
extern void omap5_secondary_startup(void);
252+
extern void omap5_secondary_hyp_startup(void);
252253
#endif
253254

254255
#if defined(CONFIG_SMP) && defined(CONFIG_PM)

‎arch/arm/mach-omap2/omap-headsmp.S‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
/* Physical address needed since MMU not enabled yet on secondary core */
2424
#define AUX_CORE_BOOT0_PA 0x48281800
25+
#define API_HYP_ENTRY 0x102
2526

2627
/*
2728
* OMAP5 specific entry point for secondary CPU to jump from ROM
@@ -40,6 +41,26 @@ wait: ldr r2, =AUX_CORE_BOOT0_PA @ read from AuxCoreBoot0
4041
bne wait
4142
b secondary_startup
4243
ENDPROC(omap5_secondary_startup)
44+
/*
45+
* Same as omap5_secondary_startup except we call into the ROM to
46+
* enable HYP mode first. This is called instead of
47+
* omap5_secondary_startup if the primary CPU was put into HYP mode by
48+
* the boot loader.
49+
*/
50+
ENTRY(omap5_secondary_hyp_startup)
51+
wait_2: ldr r2, =AUX_CORE_BOOT0_PA @ read from AuxCoreBoot0
52+
ldr r0, [r2]
53+
mov r0, r0, lsr #5
54+
mrc p15, 0, r4, c0, c0, 5
55+
and r4, r4, #0x0f
56+
cmp r0, r4
57+
bne wait_2
58+
ldr r12, =API_HYP_ENTRY
59+
adr r0, hyp_boot
60+
smc #0
61+
hyp_boot:
62+
b secondary_startup
63+
ENDPROC(omap5_secondary_hyp_startup)
4364
/*
4465
* OMAP4 specific entry point for secondary CPU to jump from ROM
4566
* code. This routine also provides a holding flag into which

‎arch/arm/mach-omap2/omap-smp.c‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/irqchip/arm-gic.h>
2323

2424
#include <asm/smp_scu.h>
25+
#include <asm/virt.h>
2526

2627
#include "omap-secure.h"
2728
#include "omap-wakeupgen.h"
@@ -227,8 +228,16 @@ static void __init omap4_smp_prepare_cpus(unsigned int max_cpus)
227228
if (omap_secure_apis_support())
228229
omap_auxcoreboot_addr(virt_to_phys(startup_addr));
229230
else
230-
writel_relaxed(virt_to_phys(omap5_secondary_startup),
231-
base + OMAP_AUX_CORE_BOOT_1);
231+
/*
232+
* If the boot CPU is in HYP mode then start secondary
233+
* CPU in HYP mode as well.
234+
*/
235+
if ((__boot_cpu_mode & MODE_MASK) == HYP_MODE)
236+
writel_relaxed(virt_to_phys(omap5_secondary_hyp_startup),
237+
base + OMAP_AUX_CORE_BOOT_1);
238+
else
239+
writel_relaxed(virt_to_phys(omap5_secondary_startup),
240+
base + OMAP_AUX_CORE_BOOT_1);
232241

233242
}
234243

0 commit comments

Comments
 (0)