[U-Boot] [PATCH 0/9] ARMv7: add PSCI support to u-boot

Marc Zyngier marc.zyngier at arm.com
Thu Nov 21 09:59:53 CET 2013

PSCI is an ARM standard that provides a generic interface that
supervisory software can use to manage power in the following
- Core idle management
- CPU hotplug
- big.LITTLE migration models
- System shutdown and reset

It basically allows the kernel to offload these tasks to the firmware,
and rely on common kernel side code.

More importantly, it gives a way to ensure that CPUs enter the kernel
at the appropriate exception level (ie HYP mode, to allow the use of
the virtualization extensions), even across events like CPUs being
powered off/on or suspended.

The main idea here is to reuse some of the existing u-boot code to
create a separate blob that can live in SRAM (or a reserved page of
memory), containing a secure monitor that will implement the PSCI
operations. This code will still be alive when u-boot is long gone,
hence the need for a piece of memory that will not be touched by the

This patch series contains 3 parts:
- the first four patches are just bug fixes
- the next three contain the generic PSCI code and build infrastructure
- the last two implement the CPU_ON method of the Allwinner A20 (aka sun7i).

I realize the A20 u-boot code is not upstream yet (BTW is anyone
actively working on that?), but hopefully that should give a good idea
of how things are structured so far. The patches are against a merge
of u-boot mainline and the sunxi tree as of ten days ago.

As for using this code, it goes like this:
sun7i# ext2load mmc 0:1 0x40000000 /boot/sunxi-psci.bin
908 bytes read in 18 ms (48.8 KiB/s)
sun7i# cp 0x40000000 0x4000 0x1000
sun7i# ext2load mmc 0:1 40008000 /boot/zImage
3415087 bytes read in 184 ms (17.7 MiB/s)
sun7i# setenv bootargs console=ttyS0,115200 earlyprintk root=/dev/nfs nfsroot=,tcp,v3 rw ip=dhcp
sun7i# bootz 40008000

The kernel now boots in HYP mode, finds its secondary CPU without any
additional SMP code, and runs KVM out of the box. Hopefully, the
Xen/ARM guys can do the same fairly easily.

I'm wildly cross-posting this patch series, including to lists I'm not
subscribed to. Please keep me on Cc for any comment you may have.



Marc Zyngier (9):
  ARM: HYP/non-sec: fix alignment requirements for vectors
  ARM: HYP/non-sec: move switch to non-sec to the last boot phase
  ARM: HYP/non-sec: add a barrier after setting SCR.NS==1
  ARM: non-sec: reset CNTVOFF to zero
  ARM: HYP/non-sec: add generic ARMv7 PSCI code
  ARM: HYP/non-sec: make pen code sections depend on !ARMV7_PSCI
  ARM: HYP/non-sec: add the option for a second-stage monitor
  sunxi: HYP/non-sec: add sun7i PSCI backend
  sunxi: HYP/non-sec: configure CNTFRQ on all CPUs

 Makefile                                 |   5 ++
 arch/arm/cpu/armv7/Makefile              |   4 ++
 arch/arm/cpu/armv7/nonsec_virt.S         |  21 +++++-
 arch/arm/cpu/armv7/psci.S                | 109 ++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/sunxi/Makefile        |   3 +
 arch/arm/cpu/armv7/sunxi/config.mk       |   6 +-
 arch/arm/cpu/armv7/sunxi/psci.S          | 119 +++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/sunxi/u-boot-psci.lds |  63 ++++++++++++++++
 arch/arm/cpu/armv7/virt-v7.c             |   2 +
 arch/arm/lib/bootm.c                     |   5 +-
 include/configs/sun7i.h                  |   7 ++
 psci/Makefile                            |  67 +++++++++++++++++
 12 files changed, 406 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/psci.S
 create mode 100644 arch/arm/cpu/armv7/sunxi/psci.S
 create mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-psci.lds
 create mode 100644 psci/Makefile


More information about the U-Boot mailing list