Re: [PATCH 00/36] AArch64 Linux kernel port

From: Catalin Marinas
Date: Tue Jul 17 2012 - 04:38:01 EST


On Mon, Jul 16, 2012 at 09:24:26AM +0100, Avi Kivity wrote:
> On 07/15/2012 03:16 PM, Catalin Marinas wrote:
> >
> > The AArch32 execution mode is optional, so it depends on the actual CPU
> > implementation (while AArch64 is mandatory). If the implementation
> > supports it, the most likely scenario for AArch32 at kernel level is in
> > virtual machines or the secure OS. I'll explain below why.
> >
> > The exception (or privilege) levels on an ARMv8 architecture look like
> > this:
> >
> > Secure World Normal World
> > +-----+
> > | EL3 | - Secure monitor
> > +-----+
> > +-----+
> > | EL2 | - Hypervisor (normal world only)
> > +-----+
> > +-----+ +-----+
> > | EL1 | | EL1 | - OS kernel (secure or normal)
> > +-----+ +-----+
> > +-----+ +-----+
> > | EL0 | | EL0 | - User apps (secure or normal)
> > +-----+ +-----+
>
> Can the same kernel image run in both EL1 and EL2? I noticed some .if
> ELs in the assembler files. I guess they could be compiled multiple
> times and the correct version chosen at runtime, or patched up like x86
> does with alternative().
>
> One of the advantages kvm has to Linux distributors is that the same
> kernel image can be used the hypervisor, guest, and bare metal. I'd
> like to preserve that for arm64.

On ARM (the same on 32-bit) we can also run the same kernel image as
hypervisor or guest. Linux detects whether it was started in EL2 and
installs some layer for KVM to use later if needed and then drops to
EL1. If started in EL1, it doesn't have access to the virtualisation
features and it just runs as a guest.

The kernel cannot run in EL2 permanently as it cannot access user space
(EL2 has its own MMU tables, though compatible with the other levels).

--
Catalin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/