[U-Boot] [PATCH 3/9] ARM: HYP/non-sec switch in bootm.c

Christoffer Dall
2013-12-30T04:57:18Z

On 29 December 2013 19:10, <TigerLiu@viatech.com.cn> wrote:
> Hi, Dall:
> I have a few questions about switching cpu's state from secure to
> non-sec in uboot.
> 1. I found do_nonsec_virt_switch() function had been integrated in
> uboot_2014_01_RC2.
> This function would switch cpu from secure state to non-sec, even
> into hyp-state.
> So, my question is:
> If a SOC is based on ARMv7 architecture:
> Virt-v7.c / nonsec_virt.S are common files to all kinds of SOCs
> which are produced by different Vendors?

Yes, the aim is to be able to reuse as much of this code for as many
platforms as possible.

>
> 2. Does uboot need to switch its state to non-sec?
> Based on ARM company released doc:
> U-boot should run at non-sec state, so no need to swith to non-sec
> again.
>
It depends on the board. Which ARM doc are you referring to?

In general, there are three options for how u-boot is booted:
1. In secure mode
2. In non-secure hyp mode
3. in non-secure svc mode

for (1) you can just switch to non-secure hyp. for (2) you don't have
to do anything. for (3) you're screwed, unless there's a backdoor
call to enter Hyp mode (typically found on TI hardware).

If we are talking PSCI, that's a different story, and if that's
provided by the board and not U-boot (see Marc's recent work), then I
would expect that board to always boot U-boot in Hyp mode to be
coherent with the documentation.

-Christoffer