On 17.08.20 04:29, Peng Fan wrote:
Subject: Re: [PATCH V2 1/4] arm64: support inmate cell in AArch32 mode
On 14.08.20 15:17, Jan Kiszka wrote:
On 15.08.20 21:09, Alice Guo wrote:
An AArch64 hypervisor can host both AArch32 and AArch64 virtual
machines at the same time. If the inmate cell wants to run in AArch32
mode, the assigned cpu must change to AArch32. Because AArch64
hypervisor and
AArch64 root cell are used, when the AArch32 inmate cell is
destroyed, cpu owned by inmate cell will be reassigned to AArch64
root cell, switch the cpu back to AArch64.
The following is a summary of some of the points when supporting
inmate cell in AArch32 mode:
Define a macro "JAILHOUSE_CELL_AARCH32" to indicate AArch32
execution
state. Add this macro to flags of struct jailhouse_cell_desc, and you
can use it to indicate whether a cell is AArch32.
AArch32 and AArch64 virtual machines use different
ARM_PARKING_CODE.
0xd503207f and 0x17ffffff are used in AArch64 and 0xe320f003 and
0xeafffffd are used in AArch32. Add ARM_PARKING_CODE which is used by
AArch32 in arm64/include/asm/processor.h, and then select which one
to use by arm_cpu_reset().
When an exception occurs, the processor must execute handler code
which corresponds to the exception. When the exception is being taken
at a lower Exception level, the execution state of the next lower
level
(AArch64 or AArch32) will be used. Fill exception handling functions
for Lower EL using AArch32 in hypervisor/arch/arm64/entry.S.
Changing to AArch32 happens after the command "jailhouse cell start 1"
is executed. Changing to AArch64 happens after the command "jailhouse
cell destroy 1". If a cell is AArch32, SPSR_EL2.M[4] will be set to
0b1 which means AArch32 execution state, SPSR_EL2.M[3:0] will be set
to 0b0011 which means Supervisor, and HCR_EL2.RW will be set to 0b0
which means lower levels are all AArch32. If a cell is AArch64, make
sure HCR_EL2.RW is 0 and the other registers are configured according
to the previous code.
After Linux operating system boots up, execute the following commands
to use AArch32 virtual machine on the i.MX8DXL:
./jailhouse enable imx8dxl.cell
./jailhouse cell create imx8dxl-gic-demo-aarch32.cell ./jailhouse
cell load 1 gic-demo.bin (32-bit) ./jailhouse cell start 1
Signed-off-by: Alice Guo <[email protected]>
---
hypervisor/arch/arm-common/control.c | 5 ++++-
hypervisor/arch/arm64/control.c | 10
++++++++++
hypervisor/arch/arm64/entry.S | 8 ++++----
hypervisor/arch/arm64/include/asm/processor.h | 4 +++-
hypervisor/arch/arm64/include/asm/sysregs.h | 4 ++++
include/jailhouse/cell-config.h | 4 ++++
6 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/hypervisor/arch/arm-common/control.c
b/hypervisor/arch/arm-common/control.c
index 70793432..bfd9e710 100644
--- a/hypervisor/arch/arm-common/control.c
+++ b/hypervisor/arch/arm-common/control.c
@@ -32,7 +32,10 @@ void arm_cpu_park(void)
enter_cpu_off(cpu_public);
spin_unlock(&cpu_public->control_lock);
- arm_cpu_reset(0);
+ if (this_cell()->config->flags & JAILHOUSE_CELL_AARCH32)
+ arm_cpu_reset(PARKING_ENTRY_ADDR_AARCH32);
+ else
+ arm_cpu_reset(PARKING_ENTRY_ADDR_AARCH64);
Let's do
arm_cpu_reset(this_cell()->config->flags & JAILHOUSE_CELL_AARCH32 ?
PARKING_ENTRY_ADDR_AARCH32 :
PARKING_ENTRY_ADDR_AARCH64);
Just thought about again, and I think there is an even better way: Pass the
mode as second parameter to arm_cpu_reset
"the mode" you mean "boot aarch64_mode"? or "bool parking"?
I think "bool parking" is reasonable. Because for parking, we could
park in aarch64 mode. For return to aarch32 inmate vm, we need
to configure to run in aarch32 mode.
aarch64 mode: For parking, you would pass aarch64 unconditionally and,
thus, only need to provide one parking code.
Jan
--
You received this message because you are subscribed to the Google Groups
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jailhouse-dev/caf5198b-0cda-1281-800e-470a33ae0163%40web.de.