From: Antonios Motakis <antonios.mota...@huawei.com>

We have now enough implemented functionality to return to the root
cell. We just need to enable guest traps, which will be handled by
the MMU, MMIO, and GIC code we already plugged to the port. Finally,
we restore the state of the root cell that we previously stored in
the stack.

Signed-off-by: Antonios Motakis <antonios.mota...@huawei.com>
[Jan: rebase]
Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 hypervisor/arch/arm64/setup.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/hypervisor/arch/arm64/setup.c b/hypervisor/arch/arm64/setup.c
index 897dad6..82685f2 100644
--- a/hypervisor/arch/arm64/setup.c
+++ b/hypervisor/arch/arm64/setup.c
@@ -49,6 +49,8 @@ int arch_init_early(void)
 
 int arch_cpu_init(struct per_cpu *cpu_data)
 {
+       unsigned long hcr = HCR_VM_BIT | HCR_IMO_BIT | HCR_FMO_BIT
+                               | HCR_TSC_BIT | HCR_TAC_BIT | HCR_RW_BIT;
        int err;
 
        /* switch to the permanent page tables */
@@ -56,6 +58,9 @@ int arch_cpu_init(struct per_cpu *cpu_data)
 
        cpu_data->mpidr = phys_processor_id();
 
+       /* Setup guest traps */
+       arm_write_sysreg(HCR_EL2, hcr);
+
        arm_paging_vcpu_init(&root_cell.arch.mm);
 
        err = irqchip_init();
@@ -79,8 +84,12 @@ int arch_init_late(void)
 
 void __attribute__((noreturn)) arch_cpu_activate_vmm(struct per_cpu *cpu_data)
 {
-       trace_error(-EINVAL);
-       while (1);
+       struct registers *regs = guest_regs(cpu_data);
+
+       /* return to the caller in Linux */
+       arm_write_sysreg(ELR_EL2, regs->usr[30]);
+
+       vmreturn(regs);
 }
 
 void arch_cpu_restore(struct per_cpu *cpu_data, int return_code)
-- 
2.1.4

-- 
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 jailhouse-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to