diff mbox

[U-Boot,5/6] ARM: Introduce function to switch to hypervisor mode

Message ID 1473830013-16480-6-git-send-email-j-keerthy@ti.com
State Accepted
Commit d31d4a2d7523c73b5da03a1697b6438e1fe1b027
Delegated to: Tom Rini
Headers show

Commit Message

Keerthy Sept. 14, 2016, 5:13 a.m. UTC
On some of the SoCs one cannot enable hypervisor mode directly from the
u-boot because the ROM code puts the chip to supervisor mode after it
jumps to boot loader. Hence introduce a weak function which can be
overridden based on the SoC type and switch to hypervisor mode in a
custom way.

Cc: beagleboard-x15@googlegroups.com
Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/cpu/armv7/start.S    | 21 +++++++++++++++++++++
 arch/arm/include/asm/system.h |  4 ++++
 2 files changed, 25 insertions(+)

Comments

Tom Rini Sept. 16, 2016, 11:17 a.m. UTC | #1
On Wed, Sep 14, 2016 at 10:43:32AM +0530, Keerthy wrote:

> On some of the SoCs one cannot enable hypervisor mode directly from the
> u-boot because the ROM code puts the chip to supervisor mode after it
> jumps to boot loader. Hence introduce a weak function which can be
> overridden based on the SoC type and switch to hypervisor mode in a
> custom way.
> 
> Cc: beagleboard-x15@googlegroups.com
> Signed-off-by: Keerthy <j-keerthy@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini Oct. 8, 2016, 5:05 p.m. UTC | #2
On Wed, Sep 14, 2016 at 10:43:32AM +0530, Keerthy wrote:

> On some of the SoCs one cannot enable hypervisor mode directly from the
> u-boot because the ROM code puts the chip to supervisor mode after it
> jumps to boot loader. Hence introduce a weak function which can be
> overridden based on the SoC type and switch to hypervisor mode in a
> custom way.
> 
> Cc: beagleboard-x15@googlegroups.com
> Signed-off-by: Keerthy <j-keerthy@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S
index 691e5d3..7eee54b 100644
--- a/arch/arm/cpu/armv7/start.S
+++ b/arch/arm/cpu/armv7/start.S
@@ -17,6 +17,7 @@ 
 #include <config.h>
 #include <asm/system.h>
 #include <linux/linkage.h>
+#include <asm/armv7.h>
 
 /*************************************************************************
  *
@@ -30,11 +31,24 @@ 
 
 	.globl	reset
 	.globl	save_boot_params_ret
+#ifdef CONFIG_ARMV7_LPAE
+	.global	switch_to_hypervisor_ret
+#endif
 
 reset:
 	/* Allow the board to save important registers */
 	b	save_boot_params
 save_boot_params_ret:
+#ifdef CONFIG_ARMV7_LPAE
+/*
+ * check for Hypervisor support
+ */
+	mrc	p15, 0, r0, c0, c1, 1		@ read ID_PFR1
+	and	r0, r0, #CPUID_ARM_VIRT_MASK	@ mask virtualization bits
+	cmp	r0, #(1 << CPUID_ARM_VIRT_SHIFT)
+	beq	switch_to_hypervisor
+switch_to_hypervisor_ret:
+#endif
 	/*
 	 * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode,
 	 * except if in HYP mode already
@@ -103,6 +117,13 @@  ENTRY(save_boot_params)
 ENDPROC(save_boot_params)
 	.weak	save_boot_params
 
+#ifdef CONFIG_ARMV7_LPAE
+ENTRY(switch_to_hypervisor)
+	b	switch_to_hypervisor_ret
+ENDPROC(switch_to_hypervisor)
+	.weak	switch_to_hypervisor
+#endif
+
 /*************************************************************************
  *
  * cpu_init_cp15
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 7b7b867..c18e1e3 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -223,6 +223,10 @@  void __noreturn psci_system_reset(bool smc);
  */
 void save_boot_params_ret(void);
 
+#ifdef CONFIG_ARMV7_LPAE
+void switch_to_hypervisor_ret(void);
+#endif
+
 #define nop() __asm__ __volatile__("mov\tr0,r0\t@ nop\n\t");
 
 #ifdef __ARM_ARCH_7A__