Q:

Running 32 bits and 64 bits OS with arm v8

I'm reading ARM's documentation about ARM v8 and I have quite some trouble to find the exact mechanics that allows to switch from 32 to 64 bits (and the other way around) when an exception occurs. First of all, if anyone can explain it to me, that would be great. 
Also I am wondering if an hypervisor (in EL2) can run different type of OS, having 32 bits and 64 bits at the same time in EL1 ?
Best,
V

A:

The restrictions on execution state are that a change can only occur at a change of exception level, and that an exception level cannot use wider registers than the one above it. Thus a 64-bit hypervisor using AArch64 at EL2 can support both 64 and 32-bit guests at EL1, just as a 64-bit OS at EL1 supports 64 and 32-bit processes at EL0. If you fancy looking at some real code, the arm64 port of KVM is precisely such a hypervisor. On the other hand, a hypervisor using AArch32 at EL2 could then only host 32-bit guests.
The requirement for a change in exception level means you can't arbitrarily switch back and forth by taking exceptions to your own level - you must have support from the level above to do it for you.
The hardware determines the execution state for the highest implemented exception level (i.e. the reset state), then each EL has a register width bit controlling the one below - if EL3 is implemented, SCR_EL3.RW controls the state of EL2 (or EL1 in the absence of EL2); if EL2 is implemented then HCR.RW controls EL1; and at EL1, PSTATE.nRW controls EL0.
The mechanics of switching are therefore slightly different for EL0, since PSTATE.nRW is in the SPSR - this makes switching the state for different processes effectively automatic as part of the normal exception return from EL1. At higher exception levels, the hypervisor/secure monitor must also take the extra step of programming the relevant configuration register as part of restoring the exception context before dropping down.

