From: Jan Kiszka <[email protected]>

It is safe to make this the very last step of init_late before
config_commit on all archs: it is only config_commit that depends on it,
and the region setup depends on the IOMMU being ready. And then we can
also fold this function into init_late directly.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/arch/arm-common/setup.c   |  8 +-------
 hypervisor/arch/x86/setup.c          |  4 ----
 hypervisor/include/jailhouse/entry.h |  9 ---------
 hypervisor/setup.c                   | 29 +++++++++++------------------
 4 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/hypervisor/arch/arm-common/setup.c 
b/hypervisor/arch/arm-common/setup.c
index bb5dd6daf..44d9680bd 100644
--- a/hypervisor/arch/arm-common/setup.c
+++ b/hypervisor/arch/arm-common/setup.c
@@ -59,12 +59,6 @@ int arm_cpu_init(struct per_cpu *cpu_data)
 
 int arm_init_late(void)
 {
-       int err;
-
        /* Setup the SPI bitmap */
-       err = irqchip_cell_init(&root_cell);
-       if (err)
-               return err;
-
-       return map_root_memory_regions();
+       return irqchip_cell_init(&root_cell);
 }
diff --git a/hypervisor/arch/x86/setup.c b/hypervisor/arch/x86/setup.c
index 604663677..dc906ff7e 100644
--- a/hypervisor/arch/x86/setup.c
+++ b/hypervisor/arch/x86/setup.c
@@ -225,10 +225,6 @@ int arch_init_late(void)
        if (err)
                return err;
 
-       err = map_root_memory_regions();
-       if (err)
-               return err;
-
        err = ioapic_init();
        if (err)
                return err;
diff --git a/hypervisor/include/jailhouse/entry.h 
b/hypervisor/include/jailhouse/entry.h
index 9357b50dc..c3abbe7e2 100644
--- a/hypervisor/include/jailhouse/entry.h
+++ b/hypervisor/include/jailhouse/entry.h
@@ -77,15 +77,6 @@ int arch_entry(unsigned int cpu_id);
 int entry(unsigned int cpu_id, struct per_cpu *cpu_data);
 
 /**
- * Map the root cell's memory regions.
- *
- * @return 0 on success, negative error code otherwise.
- *
- * Invoked by the architecture-specific setup code.
- */
-int map_root_memory_regions(void);
-
-/**
  * Perform architecture-specific early setup steps.
  *
  * @return 0 on success, negative error code otherwise.
diff --git a/hypervisor/setup.c b/hypervisor/setup.c
index 3038fe8ca..2924a1170 100644
--- a/hypervisor/setup.c
+++ b/hypervisor/setup.c
@@ -129,26 +129,10 @@ failed:
        error = err;
 }
 
-int map_root_memory_regions(void)
-{
-       const struct jailhouse_memory *mem;
-       unsigned int n;
-       int err;
-
-       for_each_mem_region(mem, root_cell.config, n) {
-               if (JAILHOUSE_MEMORY_IS_SUBPAGE(mem))
-                       err = mmio_subpage_register(&root_cell, mem);
-               else
-                       err = arch_map_memory_region(&root_cell, mem);
-               if (err)
-                       return err;
-       }
-       return 0;
-}
-
 static void init_late(void)
 {
-       unsigned int cpu, expected_cpus = 0;
+       unsigned int n, cpu, expected_cpus = 0;
+       const struct jailhouse_memory *mem;
 
        for_each_cpu(cpu, root_cell.cpu_set)
                expected_cpus++;
@@ -165,6 +149,15 @@ static void init_late(void)
        if (error)
                return;
 
+       for_each_mem_region(mem, root_cell.config, n) {
+               if (JAILHOUSE_MEMORY_IS_SUBPAGE(mem))
+                       error = mmio_subpage_register(&root_cell, mem);
+               else
+                       error = arch_map_memory_region(&root_cell, mem);
+               if (error)
+                       return;
+       }
+
        config_commit(&root_cell);
 
        paging_dump_stats("after late setup");
-- 
2.13.6

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to