This prepares ARM to park CPUs in guest mode instead of host mode. It
will allow to reuse many of the control logic of x86 for managing CPUs
that are in emulated shutdown or in waiting state before a cell starts.

In fact, we could make this a generic pattern later on, converting also
the Intel-specific version to this.

Signed-off-by: Jan Kiszka <jan.kis...@siemens.com>
---
 hypervisor/arch/arm/include/asm/control.h |  3 +++
 hypervisor/arch/arm/setup.c               | 27 ++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/hypervisor/arch/arm/include/asm/control.h 
b/hypervisor/arch/arm/include/asm/control.h
index 930f37e..0727d90 100644
--- a/hypervisor/arch/arm/include/asm/control.h
+++ b/hypervisor/arch/arm/include/asm/control.h
@@ -22,8 +22,11 @@
 #ifndef __ASSEMBLY__
 
 #include <jailhouse/cell.h>
+#include <jailhouse/paging.h>
 #include <asm/percpu.h>
 
+extern struct paging_structures parking_mm;
+
 void arch_cpu_dcaches_flush(unsigned int action);
 
 void arch_handle_sgi(struct per_cpu *cpu_data, u32 irqn);
diff --git a/hypervisor/arch/arm/setup.c b/hypervisor/arch/arm/setup.c
index 8f9edca..51af423 100644
--- a/hypervisor/arch/arm/setup.c
+++ b/hypervisor/arch/arm/setup.c
@@ -1,7 +1,7 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2013
+ * Copyright (c) Siemens AG, 2013-2016
  *
  * Authors:
  *  Jan Kiszka <jan.kis...@siemens.com>
@@ -20,7 +20,13 @@
 #include <jailhouse/processor.h>
 #include <jailhouse/string.h>
 
+static u32 __attribute__((aligned(PAGE_SIZE))) parking_code[PAGE_SIZE / 4] = {
+       0xe320f003, /* 1: wfi  */
+       0xeafffffd, /*    b 1b */
+};
+
 unsigned int cache_line_size;
+struct paging_structures parking_mm;
 
 static int arch_check_features(void)
 {
@@ -41,9 +47,24 @@ static int arch_check_features(void)
 
 int arch_init_early(void)
 {
-       int err = 0;
+       int err;
 
-       if ((err = arch_check_features()) != 0)
+       err = arch_check_features();
+       if (err)
+               return err;
+
+       parking_mm.root_paging = cell_paging;
+       parking_mm.root_table =
+               page_alloc_aligned(&mem_pool, ARM_CELL_ROOT_PT_SZ);
+       if (!parking_mm.root_table)
+               return -ENOMEM;
+
+       err = paging_create(&parking_mm, paging_hvirt2phys(parking_code),
+                           PAGE_SIZE, 0,
+                           (PTE_FLAG_VALID | PTE_ACCESS_FLAG |
+                            S2_PTE_ACCESS_RO | S2_PTE_FLAG_NORMAL),
+                           PAGING_COHERENT);
+       if (err)
                return err;
 
        return arm_paging_cell_init(&root_cell);
-- 
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