ARM: Introduce function to switch to hypervisor mode and enable LPAE
Subsystems (2)
cover ARM: Introduce function to switch to hypervisor mode and enable LPAE
On SoCs like DRA7, OMAP5 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.
Patch 1-4 enable LPAE.
Patch 5: Introduces a weak function which can be overridden specific to SoCs to switch to hypervisor mode.
Patch 6: overrides weak function in patch 1 switch cpu to hypervisor mode using the available ROM code hook early in the boot phase before the boot loader checks for hypervisor mode on OMAP5 based SoCs.
Tested on AM57XX-EVM, DRA7XX-EVM.
Keerthy (6):
omap: Remove hardcoding of mmu section shift to 20
omap: Set appropriate cache configuration for LPAE and non-LAPE cases
configs: am57xx_evm_defconfig: Enable LPAE mode
configs: dra7xx_evm_defconfig: Enable LPAE mode
ARM: Introduce function to switch to hypervisor mode
ARM: OMAP5+: Override switch_to_hypervisor function
arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 24 +++++++++++++++++++++ arch/arm/cpu/armv7/omap-common/omap-cache.c | 29 ++++++++++++++++++++++---- arch/arm/cpu/armv7/start.S | 21 +++++++++++++++++++ arch/arm/include/asm/system.h | 4 ++++ configs/am57xx_evm_defconfig | 1 + configs/dra7xx_evm_defconfig | 1 + 6 files changed, 76 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/6 omap: Remove hardcoding of mmu section shift to 20
As of now the mmu section shift is hardcoded to 20 but with LPAE coming into picture this can be different. Hence replacing 20 with MMU_SECTION_SHIFT macro.
--- arch/arm/cpu/armv7/omap-common/omap-cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/omap-common/omap-cache.c +2 -2
@@ -32,8 +32,8 @@ void dram_bank_mmu_setup(int bank)bd_t *bd = gd->bd;int i; -u32 start = bd->bi_dram[bank].start >>20 ; -u32 size = bd->bi_dram[bank].size >>20 ; +u32 start = bd->bi_dram[bank].start >>MMU_SECTION_SHIFT ; +u32 size = bd->bi_dram[bank].size >>MMU_SECTION_SHIFT ;u32 end = start + size;debug ("%s: bank: %d\n" , __func__, bank);
Signature · 1 line
1.9.1
PATCH 1/6 omap: Remove hardcoding of mmu section shift to 20
Quoted 5 lines · Keerthy
As of now the mmu section shift is hardcoded to 20 but with LPAE coming into picture this can be different. Hence replacing 20 with
MMU_SECTION_SHIFTmacro.Signed-off-by Keerthy <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160916/585f8d18/attachment.sig>
PATCH 1/6 omap: Remove hardcoding of mmu section shift to 20
In reply to KeerthyQuoted 6 lines · Keerthy
As of now the mmu section shift is hardcoded to 20 but with LPAE coming into picture this can be different. Hence replacing 20 with
MMU_SECTION_SHIFTmacro.Signed-off-by Keerthy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/51b2477b/attachment.sig>
PATCH 2/6 omap: Set appropriate cache configuration for LPAE and non-LAPE cases
In reply to KeerthyCache configuration methods is different for LPAE and non-LPAE cases. Hence the bits and the interpretaion is different for two cases. In case of non-LPAE mode short descriptor format is used and we need to set Cache and Buffer bits.
In the case of LPAE the cache configuration happens via MAIR0 lookup.
--- arch/arm/cpu/armv7/omap-common/omap-cache.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/omap-common/omap-cache.c +23 -2
@@ -17,7 +17,28 @@DECLARE_GLOBAL_DATA_PTR ; -#define ARMV7_DCACHE_WRITEBACK 0xe +/* +* Without LPAE short descriptors are used +* Set C - Cache Bit3 +* Set B - Buffer Bit2 +* The last 2 bits set to 0b10 +* Do Not set XN bit4 +* So value is 0xe +* +* With LPAE cache configuration happens via MAIR0 register +* AttrIndx value is 0x3 for picking byte3 for MAIR0 which has 0xFF. +* 0xFF maps to Cache writeback with Read and Write Allocate set +* The bits[1:0] should have the value 0b01 for the first level +* descriptor. +* So the value is 0xd +*/ + +#ifdef CONFIG_ARMV7_LPAE +#define ARMV7_DCACHE_POLICY DCACHE_WRITEALLOC +#else +#define ARMV7_DCACHE_POLICY DCACHE_WRITEBACK & ~TTB_SECT_XN_MASK +#endif +#define ARMV7_DOMAIN_CLIENT 1#define ARMV7_DOMAIN_MASK (0x3 << 0)
@@ -38,7 +59,7 @@ void dram_bank_mmu_setup(int bank)debug ("%s: bank: %d\n" , __func__, bank);for (i = start; i < end; i++) -set_section_dcache (i,ARMV7_DCACHE_WRITEBACK ); +set_section_dcache (i,ARMV7_DCACHE_POLICY ); }void arm_init_domains (void )
Signature · 1 line
1.9.1
PATCH 2/6 omap: Set appropriate cache configuration for LPAE and non-LAPE cases
Quoted 8 lines · Keerthy
Cache configuration methods is different for LPAE and non-LPAE cases. Hence the bits and the interpretaion is different for two cases. In case of non-LPAE mode short descriptor format is used and we need to set Cache and Buffer bits.
In the case of LPAE the cache configuration happens via MAIR0 lookup.
Signed-off-by Keerthy <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160916/d53f0c79/attachment.sig>
PATCH 2/6 omap: Set appropriate cache configuration for LPAE and non-LAPE cases
In reply to KeerthyQuoted 9 lines · Keerthy
Cache configuration methods is different for LPAE and non-LPAE cases. Hence the bits and the interpretaion is different for two cases. In case of non-LPAE mode short descriptor format is used and we need to set Cache and Buffer bits.
In the case of LPAE the cache configuration happens via MAIR0 lookup.
Signed-off-by Keerthy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/e2877f8a/attachment.sig>
PATCH 3/6 configs: am57xx_evm_defconfig: Enable LPAE mode
In reply to KeerthyEnable Linear Physical Address Extension mode which is a prerequisite for hypervisor mode.
--- configs/am57xx_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/am57xx_evm_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_OMAP54XX=y CONFIG_TARGET_AM57XX_EVM=y +CONFIG_ARMV7_LPAE=y CONFIG_SPL_STACK_R_ADDR=0x82000000 CONFIG_DEFAULT_DEVICE_TREE="am57xx-beagle-x15" CONFIG_SPL=y
Signature · 1 line
1.9.1
PATCH 3/6 configs: am57xx_evm_defconfig: Enable LPAE mode
Quoted 4 lines · Keerthy
Enable Linear Physical Address Extension mode which is a prerequisite for hypervisor mode.
Signed-off-by Keerthy <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160916/566b4f81/attachment.sig>
PATCH 3/6 configs: am57xx_evm_defconfig: Enable LPAE mode
In reply to KeerthyQuoted 5 lines · Keerthy
Enable Linear Physical Address Extension mode which is a prerequisite for hypervisor mode.
Signed-off-by Keerthy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/fe5025ab/attachment.sig>
PATCH 4/6 configs: dra7xx_evm_defconfig: Enable LPAE mode
In reply to KeerthyEnable Linear Physical Address Extension mode which is a prerequisite for hypervisor mode.
--- configs/dra7xx_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/dra7xx_evm_defconfig +1 -0
@@ -1,6 +1,7 @@ CONFIG_ARM=y CONFIG_OMAP54XX=y CONFIG_TARGET_DRA7XX_EVM=y +CONFIG_ARMV7_LPAE=y CONFIG_SPL_STACK_R_ADDR=0x82000000 CONFIG_DEFAULT_DEVICE_TREE="dra7-evm" CONFIG_SPL=y
Signature · 1 line
1.9.1
PATCH 4/6 configs: dra7xx_evm_defconfig: Enable LPAE mode
Quoted 4 lines · Keerthy
Enable Linear Physical Address Extension mode which is a prerequisite for hypervisor mode.
Signed-off-by Keerthy <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160916/9b2d91e6/attachment.sig>
PATCH 4/6 configs: dra7xx_evm_defconfig: Enable LPAE mode
In reply to KeerthyQuoted 5 lines · Keerthy
Enable Linear Physical Address Extension mode which is a prerequisite for hypervisor mode.
Signed-off-by Keerthy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/7ffc8c96/attachment.sig>
PATCH 5/6 ARM: Introduce function to switch to hypervisor mode
In reply to KeerthyOn 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.
--- arch/arm/cpu/armv7/start.S | 21 +++++++++++++++++++++ arch/arm/include/asm/system.h | 4 ++++ 2 files changed, 25 insertions(+)
arch/arm/cpu/armv7/start.S +21 -0
@@ -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
arch/arm/include/asm/system.h +4 -0
@@ -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__
Signature · 1 line
1.9.1
PATCH 5/6 ARM: Introduce function to switch to hypervisor mode
Quoted 8 lines · Keerthy
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 at googlegroups.comSigned-off-by Keerthy <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160916/a9d33484/attachment.sig>
PATCH 5/6 ARM: Introduce function to switch to hypervisor mode
In reply to KeerthyQuoted 9 lines · Keerthy
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 at googlegroups.comSigned-off-by Keerthy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/130ebdcc/attachment.sig>
PATCH 6/6 ARM: OMAP5+: Override switch_to_hypervisor function
In reply to KeerthyOverride the switch_to_hypervisor function to switch cpu to hypervisor mode using the available ROM code hook early in the boot phase before the boot loader checks for HYP mode.
Based on the work done by Jonathan Bergsagel jbergsagel at ti.com.
--- arch/arm/cpu/armv7/omap-common/lowlevel_init.S | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
arch/arm/cpu/armv7/omap-common/lowlevel_init.S +24 -0
@@ -24,6 +24,30 @@ ENTRY(save_boot_params) str r0, [r1] b save_boot_params_ret ENDPROC(save_boot_params) + +#if !defined(CONFIG_TI_SECURE_DEVICE) && defined(CONFIG_ARMV7_LPAE) +ENTRY(switch_to_hypervisor) + +/* + * Switch to hypervisor mode + */ + adr r0, save_sp + str sp, [r0] + adr r1, restore_from_hyp + ldr r0, =0x102 + b omap_smc1 +restore_from_hyp: + adr r0, save_sp + ldr sp, [r0] + MRC p15, 4, R0, c1, c0, 0 + ldr r1, =0X1004 @Set cache enable bits for hypervisor mode + orr r0, r0, r1 + MCR p15, 4, R0, c1, c0, 0 + b switch_to_hypervisor_ret +save_sp: + .word 0x0 +ENDPROC(switch_to_hypervisor) +#endif #endif ENTRY(omap_smc1)
Signature · 1 line
1.9.1
PATCH 6/6 ARM: OMAP5+: Override switch_to_hypervisor function
Quoted 8 lines · Keerthy
Override the
switch_to_hypervisorfunction to switch cpu to hypervisor mode using the available ROM code hook early in the boot phase before the boot loader checks for HYP mode.Based on the work done by Jonathan Bergsagel jbergsagel at ti.com.
Cc beagleboard-x15 at googlegroups.comSigned-off-by Keerthy <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160916/2755566e/attachment.sig>
PATCH 6/6 ARM: OMAP5+: Override switch_to_hypervisor function
In reply to KeerthyQuoted 9 lines · Keerthy
Override the
switch_to_hypervisorfunction to switch cpu to hypervisor mode using the available ROM code hook early in the boot phase before the boot loader checks for HYP mode.Based on the work done by Jonathan Bergsagel jbergsagel at ti.com.
Cc beagleboard-x15 at googlegroups.comSigned-off-by Keerthy <[email protected]>Reviewed-by Tom Rini <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161008/07eabc39/attachment.sig>
cover ARM: Introduce function to switch to hypervisor mode and enable LPAE
In reply to KeerthyQuoted 6 lines · Keerthy
On SoCs like DRA7, OMAP5 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.
Patch 1-4 enable LPAE.
Quoted 8 lines
Patch 5: Introduces a weak function which can be overridden specific to SoCs to switch to hypervisor mode.
Patch 6: overrides weak function in patch 1 switch cpu to hypervisor mode using the available ROM code hook early in the boot phase before the boot loader checks for hypervisor mode on OMAP5 based SoCs.
Tested on AM57XX-EVM, DRA7XX-EVM.
Tom,
Can you pull this series please.
Regards,
Keerthy
Quoted 17 lines
Keerthy (6):
omap: Remove hardcoding of mmu section shift to 20
omap: Set appropriate cache configuration for LPAE and non-LAPE cases
configs:am57xx_evm_defconfig: Enable LPAE mode
configs:dra7xx_evm_defconfig: Enable LPAE mode
ARM: Introduce function to switch to hypervisor mode
ARM: OMAP5+: Overrideswitch_to_hypervisorfunctionarch/arm/cpu/armv7/omap-common/lowlevel_init.S | 24 +++++++++++++++++++++ arch/arm/cpu/armv7/omap-common/omap-cache.c | 29 ++++++++++++++++++++++---- arch/arm/cpu/armv7/start.S | 21 +++++++++++++++++++ arch/arm/include/asm/system.h | 4 ++++ configs/am57xx_evm_defconfig | 1 + configs/dra7xx_evm_defconfig | 1 + 6 files changed, 76 insertions(+), 4 deletions(-)