[U-Boot] [PATCH v2 0/7] ARMv7: Add HYP mode switching support

Andre Przywara
2013-06-13T11:01:06Z

(for GIT URL and Changelog see below)

ARM CPUs with the virtualization extension have a new mode called
HYP mode, which allows hypervisors to safely control and monitor
guests. The current hypervisor implementations (KVM and Xen)
require the kernel to be entered in that HYP mode.

This patch series introduces a configuration variable
CONFIG_ARMV7_VIRT which enables code to switch all cores into HYP
mode. This is done automatically during execution of the bootm
command.

The process of switching into HYP mode requires the CPU to be in
secure state initially when entering u-boot, it will then setup some
register and switch to non-secure state. This requires the GIC to be
programmed properly first. Explanations about the details are in the
commit messages of the respective patches.

The patches are structured like this:
1/7: prepare header file
2/7: add monitor handler (assembly)
3/7: add per CPU non-secure switch routine (assembly)
4/7: add system wide non-secure setup and link to bootm command (C)
5/7: add SMP functionality
6/7: add HYP mode switching
7/7: enable code on Versatile Express TC2

So up to patch 5/7 this code should work on non-virtualization
capable CPUs also.

The code aims to be as generic as possible, though currently it has
only been tested on the Versatile Express TC-2 board. The last patch
thus enables the feature for that board.

For convenience there is a GIT tree which you can pull these patches
from ("hypmode_v2" branch):
git://git.linaro.org/people/aprzywara/u-boot.git

Changes RFC..v1
* not a dedicated command anymore, code run by bootm & friends
* protecting code with #ifdefs to avoid unnecessary inclusion and
accidental crashing (when accessing restricted registers)
* moving prototypes to header file to meet checkpatch recommendation
* adding comment as proposed by Christoffer

Changes v1..v2
mostly style and code layout changes
* restructure assembly code to live in a new file and not start.S
* split smp, nonsec_init and hyp_init to be separate functions
* used named constants from common header files
* split C function to be more readable
* extend comments to be more precise and elaborate
* add provision to override GIC base address (needed for Arndale?)
* add configuration variable to enable VExpress specific SMP code
* use writel/readl for MMIO GIC accesses
* remove superfluous isb instructions
* more minor fixes

Please review and comment!
I am pretty sure I missed some of the comments from the earlier
series, so if you find something that was mentioned before, feel
free to repeat it.

Contributions and comments to support other boards are welcome.

Andre Przywara (7):
ARM: prepare armv7.h to be included from assembly source
ARM: add secure monitor handler to switch to non-secure state
ARM: add assembly routine to switch to non-secure state
ARM: switch to non-secure state during bootm execution
ARM: add SMP support for non-secure switch
ARM: extend non-secure switch to also go into HYP mode
ARM: VExpress: enable ARMv7 virt support for VExpress A15

arch/arm/cpu/armv7/Makefile | 4 +
arch/arm/cpu/armv7/nonsec_virt.S | 172 ++++++++++++++++++++++++++++++++++++
arch/arm/include/asm/armv7.h | 33 ++++++-
arch/arm/include/asm/gic.h | 17 ++++
arch/arm/lib/Makefile | 2 +
arch/arm/lib/bootm.c | 26 ++++++
arch/arm/lib/virt-v7.c | 171 +++++++++++++++++++++++++++++++++++
include/configs/vexpress_ca15_tc2.h | 5 +-
8 files changed, 428 insertions(+), 2 deletions(-)
create mode 100644 arch/arm/cpu/armv7/nonsec_virt.S
create mode 100644 arch/arm/include/asm/gic.h
create mode 100644 arch/arm/lib/virt-v7.c

--
1.7.12.1