Re: [U-Boot] [RFC PATCH 0/6] ARMv7: Add HYP mode switching support

2013-04-26 Thread Christoffer Dall
On Fri, Apr 26, 2013 at 7:14 AM, Andre Przywara
 wrote:
> On 04/26/2013 03:42 PM, Peter Maydell wrote:
>> On 26 April 2013 14:24, Andre Przywara  wrote:
>>> On 04/26/2013 03:18 PM, Peter Maydell wrote:
 The obvious question here is "why do we need a new command?".
 The kernel booting specification says "boot the kernel in
 Hyp mode" so we should just always do that for booting Linux,
 surely?
>>
>>> Because it avoids regressions. I kind of feel uneasy to do a lot of
>>> tinkering with secure state and the GIC unconditionally, especially if
>>> enabled on many boards with virt-capable CPUs.
>>
>> There aren't exactly very many of those out there, so if we
>> default to "boot in HYP mode" then (a) KVM will just work
>> out of the box and (b) people doing u-boot ports to their
>> board will find any issues and be able to submit fixes.
>> If we don't turn it on by default then we'll end up stuck
>> in a world where KVM doesn't work on half the virt capable
>> boards out there.
>
> OK, that's a point. I changed the code already and will include it in
> the next revision.
>
I strongly agree with Peter, and in fact I think it should only be a
compile time option, not a run-time option, only for those debugging
u-boot and a kernel on some new platform.

-Christoffer
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 0/6] ARMv7: Add HYP mode switching support

2013-04-26 Thread Peter Maydell
On 26 April 2013 14:14, Andre Przywara  wrote:
> 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 (KVM and Xen) implementations
> require the kernel to be entered in that HYP mode.
>
> This patch series introduces a new U-Boot command called "hypmode"
> which can be used at any time at the U-Boot command prompt to
> switch the CPU into HYP mode - ideally this would be done before
> starting the kernel.

The obvious question here is "why do we need a new command?".
The kernel booting specification says "boot the kernel in
Hyp mode" so we should just always do that for booting Linux,
surely?

thanks
-- PMM
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 0/6] ARMv7: Add HYP mode switching support

2013-04-26 Thread Peter Maydell
On 26 April 2013 14:24, Andre Przywara  wrote:
> On 04/26/2013 03:18 PM, Peter Maydell wrote:
>> The obvious question here is "why do we need a new command?".
>> The kernel booting specification says "boot the kernel in
>> Hyp mode" so we should just always do that for booting Linux,
>> surely?

> Because it avoids regressions. I kind of feel uneasy to do a lot of
> tinkering with secure state and the GIC unconditionally, especially if
> enabled on many boards with virt-capable CPUs.

There aren't exactly very many of those out there, so if we
default to "boot in HYP mode" then (a) KVM will just work
out of the box and (b) people doing u-boot ports to their
board will find any issues and be able to submit fixes.
If we don't turn it on by default then we'll end up stuck
in a world where KVM doesn't work on half the virt capable
boards out there.

I have no objection to a "turn this off" escape hatch if
you think it's useful.

-- PMM
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 0/6] ARMv7: Add HYP mode switching support

2013-04-26 Thread Andre Przywara

On 04/26/2013 03:42 PM, Peter Maydell wrote:

On 26 April 2013 14:24, Andre Przywara  wrote:

On 04/26/2013 03:18 PM, Peter Maydell wrote:

The obvious question here is "why do we need a new command?".
The kernel booting specification says "boot the kernel in
Hyp mode" so we should just always do that for booting Linux,
surely?



Because it avoids regressions. I kind of feel uneasy to do a lot of
tinkering with secure state and the GIC unconditionally, especially if
enabled on many boards with virt-capable CPUs.


There aren't exactly very many of those out there, so if we
default to "boot in HYP mode" then (a) KVM will just work
out of the box and (b) people doing u-boot ports to their
board will find any issues and be able to submit fixes.
If we don't turn it on by default then we'll end up stuck
in a world where KVM doesn't work on half the virt capable
boards out there.


OK, that's a point. I changed the code already and will include it in 
the next revision.


Thanks,
Andre.



I have no objection to a "turn this off" escape hatch if
you think it's useful.

-- PMM



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 0/6] ARMv7: Add HYP mode switching support

2013-04-26 Thread Andre Przywara

On 04/26/2013 03:18 PM, Peter Maydell wrote:

On 26 April 2013 14:14, Andre Przywara  wrote:

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 (KVM and Xen) implementations
require the kernel to be entered in that HYP mode.

This patch series introduces a new U-Boot command called "hypmode"
which can be used at any time at the U-Boot command prompt to
switch the CPU into HYP mode - ideally this would be done before
starting the kernel.


The obvious question here is "why do we need a new command?".
The kernel booting specification says "boot the kernel in
Hyp mode" so we should just always do that for booting Linux,
surely?


Because it avoids regressions. I kind of feel uneasy to do a lot of 
tinkering with secure state and the GIC unconditionally, especially if 
enabled on many boards with virt-capable CPUs.


As written in question 2) later in that mail, I can also live with a 
command to _dis_able the HYP mode switching in case it causes problems.


Regards,
Andre.

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC PATCH 0/6] ARMv7: Add HYP mode switching support

2013-04-26 Thread Andre Przywara
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 (KVM and Xen) implementations
require the kernel to be entered in that HYP mode.

This patch series introduces a new U-Boot command called "hypmode"
which can be used at any time at the U-Boot command prompt to
switch the CPU into HYP mode - ideally this would be done before
starting the kernel. Since U-Boot does not use the MMU, it runs fine
in HYP mode, so you could as well enter HYP mode earlier.

The process of switching into HYP mode requires the CPU to be in
non-secure state, which requires the GIC to be programmed properly
first. Explanations about the details are in the commit messages
of the respective patches.

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 and relies on the Versatile
Express updates patches sent out lately[1]. 

I would like to get some feedback on the patches, especially about:
1) Is the code in the right places? I used arch/arm/lib/ and
arch/arm/cpu/armv7/ as directories for the ARM code and
common/ for the actual command.
2) Is a command to switch to HYP actually the right thing? Should
HYP be entered automatically instead? Or provide an option to skip
HYP mode if requested by the user?
3) Does it make sense to provide a "nonsec" command also? I cannot
name any usecases by now, but the implementation would be rather
easy with basically all the functionality already there.

In general I appreciate any comments about coding style, patch
layout or the actual implementation.

Thanks for watching!

Andre.

[1] http://lists.denx.de/pipermail/u-boot/2013-April/151366.html

Andre Przywara (6):
  ARM: add secure monitor handler to switch to non-secure state
  ARM: add assembly routine to switch to non-secure state
  ARM: add U-Boot command "hypmode" to switch to non-secure state
  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/start.S  | 116 ---
 arch/arm/include/asm/armv7.h|   2 +
 arch/arm/lib/Makefile   |   2 +
 arch/arm/lib/virt-v7.c  | 132 
 common/Makefile |   1 +
 common/cmd_virt.c   |  65 ++
 include/configs/vexpress_ca15_tc2.h |   3 +
 7 files changed, 311 insertions(+), 10 deletions(-)
 create mode 100644 arch/arm/lib/virt-v7.c
 create mode 100644 common/cmd_virt.c

-- 
1.7.12.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot